Re: How configure Django to handle /books URL and yet allow access to PDFs/images in subdirs of /books?
On Tuesday, January 4, 2011 2:54:25 PM UTC+11, Chris Seberino wrote: > > How configure Django to handle /books URL and yet allow access to PDFs > and images in subdirs of /books? > > Specifically, I want /books to be a dynamic page with lots of links to > PDFs and images of book covers contained in subdirectories of /books > like /books/some_book_1 and /books/some_book_1/book_cover.jpg. > Depends on how you are hosting Django. If using Apache/mod_wsgi it is quite simple, and wouldn't even need URL rewriting as suggested by others. So, what are you hosting it with. Graham -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: cannot login to admin site with superuser
is there any hope for me? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Contact form doesn't see user as logged in
Thank you, this worked. I appreciate the fast response Łukasz. On Jan 3, 11:38 pm, Łukasz Rekucki wrote: > On 4 January 2011 02:27, Catalyst wrote: > > > I am having trouble with a contact form on my site. Whenever I hit > > the page, it doesn't see that the user is logged in. Here's how my > > code looks. > > How do you check that user is logged in ? If it's via request.user, > then it doesn't work 'cause you > aren't passing the request object to your template's context. The > recomended way to do this is using RequestContext: > > from django.template import RequestContext > > return render_to_response('forms/contact.html', {'form': form}, > context_instance=RequestContext(request)) > > > > > > > > > #forms.py > > > from django import forms > > from django.utils.translation import ungettext, ugettext_lazy as _ > > > class ContactForm(forms.Form): > > subject = forms.CharField() > > email = forms.EmailField(required=False) > > message = > > forms.CharField(widget=forms.Textarea(attrs={'rows':'20', > > 'cols':'75'})) > > > > > > > #urls.py > > from django.conf.urls.defaults import * > > > urlpatterns = patterns('myproject.forms.views', > > (r'^contact-us/$', 'contact'), > > ) > > > > > > > #views.py > > > from django.core.mail import send_mail > > from django.http import HttpResponseRedirect > > from django.shortcuts import render_to_response > > from myproject.forms.forms import ContactForm > > > def contact(request): > > if request.method == 'POST': > > form = ContactForm(request.POST) > > if form.is_valid(): > > cd = form.cleaned_data > > send_mail( > > cd['subject'], > > cd['message']+'\nUser email '+cd['email'], > > ('formemailaddr...@email.com'), > > ['sendaddr...@email.com'], > > ) > > return HttpResponseRedirect('/forms/thanks/') > > else: > > form = ContactForm() > > return render_to_response('forms/contact.html', {'form': form}) > > > > > If I hit another page, the user still shows up as being logged in, > > just this one area (the contact form) doesn't. Even the thank you page > > shows the user as being logged in. > > > Anyone have any ideas? > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > -- > Łukasz Rekucki -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Changing a constraint with live data
Hi everyone, Happy 2011. I am having an interesting problem where I need to change the foreign key on a model (A) to reference a different model. problem is, the table for A is populated with records and MySQL does not seem able to drop it. I ran manage.py sql and would like to drop the existing constraint and add the new one. Is there a straightforward way to do this? -- Regards, Sithembewena Lloyd Dube -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Problem with models
I have model of text, like that: class Text(models.Model): text = models.CharField() user = models.ForeignKey(User) #author And i need to compare two of texts, so i need table like this: class Compare(models.Model): text1 = models.ForeignKey(Text) text2 = models.ForeignKey(Text) user = models.ForeignKey(User) #who compared Now i want to get from Text table two random texts and at least one of them cant be compared yet by given user, how can i do this? if I try reverse relation compares_set, it doesnt work cause' i have two foreignkey of same model. I cant give manaytomanyfield in Text through Compare because i cant make symmetrical reference with intermediate table. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem with models
I have added related_name to text1 and text2, so at least syncdb worked, but how can I now make this query. In manager: self.compare_set.filter(~Q(Q(compare__user=request.user)&Q(Q(compare__text1__id=id)| Q(compare__text2__id=id.all() this doesn't work -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Changing a constraint with live data
I use south for migrations. I have done something like this with south, but with postgres not mysql. I don't know if mysql supports deferrable foreign key constraints. Thomas Sithembewena Lloyd Dube wrote: > Hi everyone, > > Happy 2011. > > I am having an interesting problem where I need to change the foreign > key on a model (A) to reference a different model. problem is, the table > for A > is populated with records and MySQL does not seem able to drop it. I ran > manage.py sql and would like to drop the existing constraint and add the > new one. > Is there a straightforward way to do this? -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django dev server issue
Ok, so i used pdb and did a line by line pass, but i didn't get anything. All data seems to be normal. I even edited socket.py and did a print on data to see what's going on and everything seems normal.. :( so i'm left with no idea I guess i'll have to get used with this hangs. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
models queryset and permissions
Hi people, probably I'm making a mountain out of a molehill but I can't figure how to solve this problem; I've a form with a ModelMultipleChoiceField. The queryset will contains all models for which the user has a particular permission (django.contrib.auth.models.Permission) (can_add). This is the models.py class Esame(models.Model): name = models.CharField(max_length=80) name_model_referenced = models.CharField(max_length=80) class Ecg(models.Model): esame = models.ForeignKey(Esame) patient = models.ForeignKey(Patient, null=True) class Ecg_da_sforzo(models.Model): esame = models.ForeignKey(Esame) patient = models.ForeignKey(Patient, null=True) Supposing we have a user Tom which can add an Ecg but not an Ecg_da_sforzo, can I use the Django Queryset API to obtaing the correct queryset? If yes, how can I construct it? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: models queryset and permissions
The ModelMultipleChoicheField will return Esame objects -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Serialize in django witha query set that contains defer
Hi, i have i little problem, and that is how can serialize a django query with defer ? I have this model : class Evento(models.Model): nome=models.CharField(max_length=100) descricao=models.CharField(max_length=200,null=True) data_inicio= models.DateTimeField() data_fim= models.DateTimeField() preco=models.DecimalField(max_digits=6,decimal_places=2) consumiveis= models.CharField(max_length=5) dress_code= models.CharField(max_length=6) guest_list=models.CharField(max_length=15) local = models.ForeignKey(Local) user= models.ManyToManyField(User,null=True,blank=True) def __unicode__(self): return unicode('%s %s'%(self.nome,self.descricao)) my query is this : eventos_totais = Evento.objects.defer("user").filter(data_inicio__gte=default_inicio, data_fim__lte=default_fim) it works fine i think (how can i check if the query has realy defer the field user ? ) but when i do: json_serializer = serializers.get_serializer("json")() eventos_totais = json_serializer.serialize(eventos_totais, ensure_ascii=False, use_natural_keys=True) it always folow the natural keys for user and local, i need natural keys for this query because of the fields local. But i do not need the field user. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django dev server issue
It sounds like it wasn't able to be reproduced with pdb. I think that should be looked into further. Brian On Tue, Jan 4, 2011 at 6:57 AM, daniels wrote: > Ok, so i used pdb and did a line by line pass, but i didn't get anything. > All data seems to be normal. I even edited socket.py and did a print on > data > to see what's going on and everything seems normal.. :( so i'm left with > no idea > I guess i'll have to get used with this hangs. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- Brian Bouterse ITng Services -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
build application from admin code
Hello, I just started using Django and I am still "marvelling at all the code I didn't have to write". I wonder if this code, the admin interface, could be used for the application itself. I would like to do something like this: Each user of my application gets his very own predefined objects of a certain kind, which he can use, change, delete, and so on. He gets his own urls and views that are but modifications of the automatically generated admin urls and views. Like so: example.org/juan/grammar/verbs/add/ (a modification of example.org/admin/grammar/verbs/add/) or so: example.org/merche/recipes/delete (a modification of example.org/admin/recipes/delete) Juan and Merche are users of example.org, but they can have and administrate their own users. Juan, e.g., might have the users Maria and EmacsGuru. Maria and EmacsGuru can only view and manipulate the pages that Juan allows them to. And Juan can only view and manipulate the pages that the admin of example.org allows him to. Has anyone done something of this kind? Is there example code? Santiago -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
MVC (mtv!) schema...
hi! i'm reading the djangobook, and it ocurred to me this drawing, to graphic the mtv concept. hope you like it, and you are free to use it! http://marcobernich.blogspot.com/2011/01/mvc.html -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
ImportError cannot import name DetailView
While completing "Writing your first Django app, part 4", I ran into an error. I have almost completed the online tutorial, but using the code verbatum, I get this error. I even went as far as to cut and paste the code, rather than typing it as I usually do, just in case I made a simple error I could not see. Exception Location: C:\DjangoProjects\mysite\polls\urls.py in , line 2 Copy of line 2 of urls.py. from django.views.generic import DetailView, ListView Anyone have any ideas? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ImportError cannot import name DetailView
On Tuesday, January 4, 2011 3:07:58 PM UTC, Anthony Pearce wrote: > > While completing "Writing your first Django app, part 4", I ran into > an error. I have almost completed the online tutorial, but using the > code verbatum, I get this error. I even went as far as to cut and > paste the code, rather than typing it as I usually do, just in case I > made a simple error I could not see. > > Exception Location: C:\DjangoProjects\mysite\polls\urls.py in > , line 2 > > Copy of line 2 of urls.py. from django.views.generic import > DetailView, ListView > > Anyone have any ideas? You're using the docs for the development version, but are probably running the released version 1.2. There's a link at the top of each page to the correct documentation for your version. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ImportError cannot import name DetailView
That could be it. I downloaded the latest official version, 1.2.4. I totally overlooked that comment at the top. On Jan 5, 12:13 am, Daniel Roseman wrote: > On Tuesday, January 4, 2011 3:07:58 PM UTC, Anthony Pearce wrote: > > > While completing "Writing your first Django app, part 4", I ran into > > an error. I have almost completed the online tutorial, but using the > > code verbatum, I get this error. I even went as far as to cut and > > paste the code, rather than typing it as I usually do, just in case I > > made a simple error I could not see. > > > Exception Location: C:\DjangoProjects\mysite\polls\urls.py in > > , line 2 > > > Copy of line 2 of urls.py. from django.views.generic import > > DetailView, ListView > > > Anyone have any ideas? > > You're using the docs for the development version, but are probably running > the released version 1.2. There's a link at the top of each page to the > correct documentation for your version. > -- > DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Syntax Error
Can someone explain to me what the following error is trying to tell me: SyntaxError at /polls/1 invalid syntax (urls.py, line 20)Request Method: GET Request URL: http://127.0.0.1:8000/polls/1 Django Version: 1.2.3 Exception Type: SyntaxError Exception Value: invalid syntax (urls.py, line 20) Exception Location: C:\Python27\lib\site-packages\django\utils \importlib.py in import_module, line 35 Python Executable: C:\Python27\python.exe Python Version: 2.7.1 Python Path: ['C:\\Documents and Settings\\hversemann\\djangoprojects\ \mysite', 'C:\\WINDOWS\\system32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\ \lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages'] Server time: Tue, 4 Jan 2011 09:12:32 -0600 The urls.py module that it is referring to looks like this: from django.conf.urls.defaults import * # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() #urlpatterns = patterns('', # Example: # (r'^mysite/', include('mysite.foo.urls')), # Uncomment the admin/doc line below to enable admin documentation: # (r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: # (r'^admin/', include(admin.site.urls)),(r'^polls/$', 'polls.views.index'), #(r'^polls/(?P\d+)/$', 'polls.views.detail'), #(r'^polls/(?P\d+)/results/$', 'polls.views.results'), #(r'^polls/(?P\d+)/vote/$', 'polls.views.vote'), #(r'^admin/', include(admin.site.urls)), #) urlpatterns = patterns('', (r'^polls/', include('polls.urls')), (r'^admin/', include(admin.site.urls)), ) and I thought it had previously worked ok when I last tried to use it back on the 23rd. I would appreciate any help or direction in debugging this since I'm relatively new to both django and python. Thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Syntax Error
what happens if you'remove the commented lines? On 01/04/11 15:22, hank23 wrote: > Can someone explain to me what the following error is trying to tell > me: > > SyntaxError at /polls/1 > invalid syntax (urls.py, line 20)Request Method: GET > Request URL: http://127.0.0.1:8000/polls/1 > Django Version: 1.2.3 > Exception Type: SyntaxError > Exception Value: invalid syntax (urls.py, line 20) > Exception Location: C:\Python27\lib\site-packages\django\utils > \importlib.py in import_module, line 35 > Python Executable: C:\Python27\python.exe > Python Version: 2.7.1 > Python Path: ['C:\\Documents and Settings\\hversemann\\djangoprojects\ > \mysite', 'C:\\WINDOWS\\system32\\python27.zip', 'C:\\Python27\\DLLs', > 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\ > \lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages'] > Server time: Tue, 4 Jan 2011 09:12:32 -0600 > > The urls.py module that it is referring to looks like this: > > from django.conf.urls.defaults import * > > # Uncomment the next two lines to enable the admin: > from django.contrib import admin > admin.autodiscover() > > #urlpatterns = patterns('', > # Example: > # (r'^mysite/', include('mysite.foo.urls')), > # Uncomment the admin/doc line below to enable admin > documentation: > # (r'^admin/doc/', include('django.contrib.admindocs.urls')), > # Uncomment the next line to enable the admin: > # (r'^admin/', include(admin.site.urls)),(r'^polls/$', > 'polls.views.index'), > #(r'^polls/(?P\d+)/$', 'polls.views.detail'), > #(r'^polls/(?P\d+)/results/$', 'polls.views.results'), > #(r'^polls/(?P\d+)/vote/$', 'polls.views.vote'), > #(r'^admin/', include(admin.site.urls)), > #) > > urlpatterns = patterns('', > (r'^polls/', include('polls.urls')), > (r'^admin/', include(admin.site.urls)), > ) > > > and I thought it had previously worked ok when I last tried to use it > back on the 23rd. I would appreciate any help or direction in > debugging this since I'm relatively new to both django and python. > Thanks. > > -- blog http://piotr.zalewa.info jobs http://webdev.zalewa.info twit http://twitter.com/zalun face http://facebook.com/zaloon -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Syntax Error
After removing the commented code, saving urls.py, restarting the server and then requesting the sites admin page now I get the admin login screen. But after I type in my username and pw then it again gives me the following screen: TemplateSyntaxError at /admin/ Caught SyntaxError while rendering: invalid syntax (urls.py, line 20)Request Method: GET Request URL: http://127.0.0.1:8000/admin/ Django Version: 1.2.3 Exception Type: TemplateSyntaxError Exception Value: Caught SyntaxError while rendering: invalid syntax (urls.py, line 20) Exception Location: C:\Python27\lib\site-packages\django\utils \importlib.py in import_module, line 35 Python Executable: C:\Python27\python.exe Python Version: 2.7.1 Python Path: ['C:\\Documents and Settings\\hversemann\\djangoprojects\ \mysite', 'C:\\WINDOWS\\system32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\ \lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages'] Server time: Tue, 4 Jan 2011 09:45:54 -0600 and still references the same line in urls.py, which is confusing because now it shouldn't have a line 20. Here's what urls.py currently looks like: from django.conf.urls.defaults import * # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', (r'^polls/', include('polls.urls')), (r'^admin/', include(admin.site.urls)), ) Could this problem be related to windows 7 environment variables not being set properly? I ask because I was upgraded recently from Win XP to Windows 7 and have been working to set up my environment variables back to where they should be. I thought I had previously fixed all of them, but maybe I missed something. Please advise. Thanks. On Jan 4, 9:36 am, Piotr Zalewa wrote: > what happens if you'remove the commented lines? > > On 01/04/11 15:22, hank23 wrote: > > > > > > > Can someone explain to me what the following error is trying to tell > > me: > > > SyntaxError at /polls/1 > > invalid syntax (urls.py, line 20)Request Method: GET > > Request URL:http://127.0.0.1:8000/polls/1 > > Django Version: 1.2.3 > > Exception Type: SyntaxError > > Exception Value: invalid syntax (urls.py, line 20) > > Exception Location: C:\Python27\lib\site-packages\django\utils > > \importlib.py in import_module, line 35 > > Python Executable: C:\Python27\python.exe > > Python Version: 2.7.1 > > Python Path: ['C:\\Documents and Settings\\hversemann\\djangoprojects\ > > \mysite', 'C:\\WINDOWS\\system32\\python27.zip', 'C:\\Python27\\DLLs', > > 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\ > > \lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages'] > > Server time: Tue, 4 Jan 2011 09:12:32 -0600 > > > The urls.py module that it is referring to looks like this: > > > from django.conf.urls.defaults import * > > > # Uncomment the next two lines to enable the admin: > > from django.contrib import admin > > admin.autodiscover() > > > #urlpatterns = patterns('', > > # Example: > > # (r'^mysite/', include('mysite.foo.urls')), > > # Uncomment the admin/doc line below to enable admin > > documentation: > > # (r'^admin/doc/', include('django.contrib.admindocs.urls')), > > # Uncomment the next line to enable the admin: > > # (r'^admin/', include(admin.site.urls)), (r'^polls/$', > > 'polls.views.index'), > > # (r'^polls/(?P\d+)/$', 'polls.views.detail'), > > # (r'^polls/(?P\d+)/results/$', 'polls.views.results'), > > # (r'^polls/(?P\d+)/vote/$', 'polls.views.vote'), > > # (r'^admin/', include(admin.site.urls)), > > #) > > > urlpatterns = patterns('', > > (r'^polls/', include('polls.urls')), > > (r'^admin/', include(admin.site.urls)), > > ) > > > and I thought it had previously worked ok when I last tried to use it > > back on the 23rd. I would appreciate any help or direction in > > debugging this since I'm relatively new to both django and python. > > Thanks. > > -- > blog http://piotr.zalewa.info > jobs http://webdev.zalewa.info > twit http://twitter.com/zalun > face http://facebook.com/zaloon- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Changing a constraint with live data
You could do this with South in multiple steps. 1. South schema migration: Add the new field for the proper foreign key, but don't make the field required. 2. South data migration: Create a migration that appropriately populates the new field based on whatever rules you have. 3. South schema migration: Make the new field required, and optionally delete the old field. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: build application from admin code
Now that you're luxuriating in the "done for you" aspect of Django, check out the ModelForm object. It gives you the goodness you seek. I don't think that setting up your URL system the way you describe is a good idea. It's a complete security failure, so you'd have to handle permissions anyway. Therefore, there's no benefit to having the username as part of the URL. Shawn On Jan 4, 2011, at 4:53 AM, Santiago Caracol wrote: > Hello, > > I just started using Django and I am still "marvelling at all the code > I didn't have to write". I wonder if this code, the admin interface, > could be used for the application itself. I would like to do something > like this: > > Each user of my application gets his very own predefined objects of a > certain kind, which he can use, change, delete, and so on. He gets his > own urls and views that are but modifications of the automatically > generated admin urls and views. Like so: > > example.org/juan/grammar/verbs/add/ > (a modification of example.org/admin/grammar/verbs/add/) > > or so: > > example.org/merche/recipes/delete > (a modification of example.org/admin/recipes/delete) > > Juan and Merche are users of example.org, but they can have and > administrate their own users. Juan, e.g., might have the users Maria > and EmacsGuru. Maria and EmacsGuru can only view and manipulate the > pages that Juan allows them to. And Juan can only view and manipulate > the pages that the admin of example.org allows him to. > > Has anyone done something of this kind? Is there example code? > > Santiago > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: cannot login to admin site with superuser
On Jan 4, 2011, at 4:15 AM, xpanta wrote: > is there any hope for me? Does your settings.py file do any imports? If there is a problem with an import you'll have a major disaster and the cause may not be obvious from the error message. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How configure Django to handle /books URL and yet allow access to PDFs/images in subdirs of /books?
On Jan 4, 2:48 am, Graham Dumpleton wrote: > If using Apache/mod_wsgi it is quite simple, and wouldn't even need URL > rewriting as suggested by others. > > So, what are you hosting it with. Yes I am using mod_wsgi. The following line sends all URLs to WSGI script WSGIScriptAlias//etc/apache2/wsgi/phil4.com.wsgi I also have other Alias lines like this.. Alias /images /var/www/static/images What is tricky about this current problem is I want to send /books to WSGI but NOT /books/* . cs -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Syntax Error
Is it possible that the problem is not in this urls.py, but rather in 'polls.urls'? I'd check line 20 there, just to see if there's an obvious python syntax error. HTH c On Jan 4, 8:08 am, hank23 wrote: > After removing the commented code, saving urls.py, restarting the > server and then requesting the sites admin page now I get the admin > login screen. But after I type in my username and pw then it again > gives me the following screen: > > TemplateSyntaxError at /admin/ > Caught SyntaxError while rendering: invalid syntax (urls.py, line > 20)Request Method: GET > Request URL:http://127.0.0.1:8000/admin/ > Django Version: 1.2.3 > Exception Type: TemplateSyntaxError > Exception Value: Caught SyntaxError while rendering: invalid syntax > (urls.py, line 20) > Exception Location: C:\Python27\lib\site-packages\django\utils > \importlib.py in import_module, line 35 > Python Executable: C:\Python27\python.exe > Python Version: 2.7.1 > Python Path: ['C:\\Documents and Settings\\hversemann\\djangoprojects\ > \mysite', 'C:\\WINDOWS\\system32\\python27.zip', 'C:\\Python27\\DLLs', > 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\ > \lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages'] > Server time: Tue, 4 Jan 2011 09:45:54 -0600 > > and still references the same line in urls.py, which is confusing > because now it shouldn't have a line 20. Here's what urls.py currently > looks like: > > from django.conf.urls.defaults import * > > # Uncomment the next two lines to enable the admin: > from django.contrib import admin > admin.autodiscover() > > urlpatterns = patterns('', > (r'^polls/', include('polls.urls')), > (r'^admin/', include(admin.site.urls)), > ) > > Could this problem be related to windows 7 environment variables not > being set properly? I ask because I was upgraded recently from Win XP > to Windows 7 and have been working to set up my environment variables > back to where they should be. I thought I had previously fixed all of > them, but maybe I missed something. Please advise. Thanks. > > On Jan 4, 9:36 am, Piotr Zalewa wrote: > > > > > what happens if you'remove the commented lines? > > > On 01/04/11 15:22, hank23 wrote: > > > > Can someone explain to me what the following error is trying to tell > > > me: > > > > SyntaxError at /polls/1 > > > invalid syntax (urls.py, line 20)Request Method: GET > > > Request URL:http://127.0.0.1:8000/polls/1 > > > Django Version: 1.2.3 > > > Exception Type: SyntaxError > > > Exception Value: invalid syntax (urls.py, line 20) > > > Exception Location: C:\Python27\lib\site-packages\django\utils > > > \importlib.py in import_module, line 35 > > > Python Executable: C:\Python27\python.exe > > > Python Version: 2.7.1 > > > Python Path: ['C:\\Documents and Settings\\hversemann\\djangoprojects\ > > > \mysite', 'C:\\WINDOWS\\system32\\python27.zip', 'C:\\Python27\\DLLs', > > > 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\ > > > \lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages'] > > > Server time: Tue, 4 Jan 2011 09:12:32 -0600 > > > > The urls.py module that it is referring to looks like this: > > > > from django.conf.urls.defaults import * > > > > # Uncomment the next two lines to enable the admin: > > > from django.contrib import admin > > > admin.autodiscover() > > > > #urlpatterns = patterns('', > > > # Example: > > > # (r'^mysite/', include('mysite.foo.urls')), > > > # Uncomment the admin/doc line below to enable admin > > > documentation: > > > # (r'^admin/doc/', include('django.contrib.admindocs.urls')), > > > # Uncomment the next line to enable the admin: > > > # (r'^admin/', include(admin.site.urls)), (r'^polls/$', > > > 'polls.views.index'), > > > # (r'^polls/(?P\d+)/$', 'polls.views.detail'), > > > # (r'^polls/(?P\d+)/results/$', 'polls.views.results'), > > > # (r'^polls/(?P\d+)/vote/$', 'polls.views.vote'), > > > # (r'^admin/', include(admin.site.urls)), > > > #) > > > > urlpatterns = patterns('', > > > (r'^polls/', include('polls.urls')), > > > (r'^admin/', include(admin.site.urls)), > > > ) > > > > and I thought it had previously worked ok when I last tried to use it > > > back on the 23rd. I would appreciate any help or direction in > > > debugging this since I'm relatively new to both django and python. > > > Thanks. > > > -- > > blog http://piotr.zalewa.info > > jobs http://webdev.zalewa.info > > twit http://twitter.com/zalun > > face http://facebook.com/zaloon-Hide quoted text - > > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
form handling in views.py
Maybe smbd could give advice how data submitted from custom.html to views.py are handled further? custom.html with method search1 ## {% if Lp %} {% for item in Lp %} {{item.Word}} {{item.dateWord}} {% endfor %} {% endif %} views.py with method search1 ## def search1(request): request.encoding='utf-8' query = request.GET.get( 'q','') The code above works when i have one button and one text area. I do not understand how to find out which input was selected and how to read text from many text areas (how to relate several text areas in row with single button in that row ) . regards, gintare -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Syntax Error
OK. There were some problems with my django installation, due to the OS upgrade on my machine, and things which were missing in at least one environment variable. Since correcting these problems the basic functionality of my tutorial site appears to be working again. Now I appear to have at least one problem in my views.py file. Thanks for the suggestion. It did helpme find the problem(s). hank23 On Jan 4, 11:16 am, cewing wrote: > Is it possible that the problem is not in this urls.py, but rather in > 'polls.urls'? > > I'd check line 20 there, just to see if there's an obvious python > syntax error. > > HTH > > c > > On Jan 4, 8:08 am, hank23 wrote: > > > > > After removing the commented code, saving urls.py, restarting the > > server and then requesting the sites admin page now I get the admin > > login screen. But after I type in my username and pw then it again > > gives me the following screen: > > > TemplateSyntaxError at /admin/ > > Caught SyntaxError while rendering: invalid syntax (urls.py, line > > 20)Request Method: GET > > Request URL:http://127.0.0.1:8000/admin/ > > Django Version: 1.2.3 > > Exception Type: TemplateSyntaxError > > Exception Value: Caught SyntaxError while rendering: invalid syntax > > (urls.py, line 20) > > Exception Location: C:\Python27\lib\site-packages\django\utils > > \importlib.py in import_module, line 35 > > Python Executable: C:\Python27\python.exe > > Python Version: 2.7.1 > > Python Path: ['C:\\Documents and Settings\\hversemann\\djangoprojects\ > > \mysite', 'C:\\WINDOWS\\system32\\python27.zip', 'C:\\Python27\\DLLs', > > 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\ > > \lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages'] > > Server time: Tue, 4 Jan 2011 09:45:54 -0600 > > > and still references the same line in urls.py, which is confusing > > because now it shouldn't have a line 20. Here's what urls.py currently > > looks like: > > > from django.conf.urls.defaults import * > > > # Uncomment the next two lines to enable the admin: > > from django.contrib import admin > > admin.autodiscover() > > > urlpatterns = patterns('', > > (r'^polls/', include('polls.urls')), > > (r'^admin/', include(admin.site.urls)), > > ) > > > Could this problem be related to windows 7 environment variables not > > being set properly? I ask because I was upgraded recently from Win XP > > to Windows 7 and have been working to set up my environment variables > > back to where they should be. I thought I had previously fixed all of > > them, but maybe I missed something. Please advise. Thanks. > > > On Jan 4, 9:36 am, Piotr Zalewa wrote: > > > > what happens if you'remove the commented lines? > > > > On 01/04/11 15:22, hank23 wrote: > > > > > Can someone explain to me what the following error is trying to tell > > > > me: > > > > > SyntaxError at /polls/1 > > > > invalid syntax (urls.py, line 20)Request Method: GET > > > > Request URL:http://127.0.0.1:8000/polls/1 > > > > Django Version: 1.2.3 > > > > Exception Type: SyntaxError > > > > Exception Value: invalid syntax (urls.py, line 20) > > > > Exception Location: C:\Python27\lib\site-packages\django\utils > > > > \importlib.py in import_module, line 35 > > > > Python Executable: C:\Python27\python.exe > > > > Python Version: 2.7.1 > > > > Python Path: ['C:\\Documents and Settings\\hversemann\\djangoprojects\ > > > > \mysite', 'C:\\WINDOWS\\system32\\python27.zip', 'C:\\Python27\\DLLs', > > > > 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\ > > > > \lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages'] > > > > Server time: Tue, 4 Jan 2011 09:12:32 -0600 > > > > > The urls.py module that it is referring to looks like this: > > > > > from django.conf.urls.defaults import * > > > > > # Uncomment the next two lines to enable the admin: > > > > from django.contrib import admin > > > > admin.autodiscover() > > > > > #urlpatterns = patterns('', > > > > # Example: > > > > # (r'^mysite/', include('mysite.foo.urls')), > > > > # Uncomment the admin/doc line below to enable admin > > > > documentation: > > > > # (r'^admin/doc/', include('django.contrib.admindocs.urls')), > > > > # Uncomment the next line to enable the admin: > > > > # (r'^admin/', include(admin.site.urls)), (r'^polls/$', > > > > 'polls.views.index'), > > > > # (r'^polls/(?P\d+)/$', 'polls.views.detail'), > > > > # (r'^polls/(?P\d+)/results/$', 'polls.views.results'), > > > > # (r'^polls/(?P\d+)/vote/$', 'polls.views.vote'), > > > > # (r'^admin/', include(admin.site.urls)), > > > > #) > > > > > urlpatterns = patterns('', > > > > (r'^polls/', include('polls.urls')), > > > > (r'^admin/', include(admin.site.urls)), > > > > ) > > > > > and I thought it had previously worked ok when I last tried to use it > > > > back on the 23rd. I would appreciate any help or direction in > > > > debugging this since I'm relatively new to both django and python. > > > > Thanks. > >
Re: cannot login to admin site with superuser
Thanks, These are my only imports: import os.path import logging And this is my INSTALLED_APPS section INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'myproject.main', ) On 4 Ιαν, 19:06, Shawn Milochik wrote: > On Jan 4, 2011, at 4:15 AM, xpanta wrote: > > > is there any hope for me? > > Does your settings.py file do any imports? If there is a problem with an > import you'll have a major disaster and the cause may not be obvious from the > error message. > > Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Custom queryset on a ModelForm field
Hi, I have a 'project' model class Project(models.Model): title = models.CharField(max_length=100) links = models.ManyToManyField('Link', related_name='link') and a 'link' model class Link(models.Model): label = models.CharField(max_length=50) url = models.URLField(max_length=100) project = models.ForeignKey(Project) I want the user to edit his project properties. I'm using ModelForm class and a UpdateView to put everything together. But I have a problems: I want the form to only show those *link*s who are owned by the project in the MultipleChoisesWidget, hence the ForeignKey in the Link model. Any help on how to achieve this? Thanks! P.S why isn't there a proper API documentation on django like doxygen? I find the django documentation full of content but awful structure! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: cannot login to admin site with superuser
What happens when you try 'manage.py shell'? Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: form handling in views.py
On Tuesday, January 4, 2011 6:31:30 PM UTC, gintare wrote: > > Maybe smbd could give advice how data submitted from custom.html to > views.py are handled further? > > > custom.html with method search1 ## > > > {% if Lp %} > {% for item in Lp %} > > > > > > > value="{{ query.0|escape}}"> {{item.Word}} > > > {{item.dateWord}} > > > > > > {% endfor %} > {% endif %} > > > > views.py with method search1 ## > > > def search1(request): > request.encoding='utf-8' > query = request.GET.get( 'q','') > > The code above works when i have one button and one text area. > > I do not understand > how to find out which input was selected and > how to read text from many text areas (how to relate several text > areas in row with single button in that row ) . > > regards, > gintare Don't do any of that. Instead, read the excellent documentation about the very nice forms framework: http://docs.djangoproject.com/en/1.2/topics/forms/ -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Custom queryset on a ModelForm field
On Tuesday, January 4, 2011 7:42:16 PM UTC, mrmclovin wrote: > > Hi, > > I have a 'project' model > > class Project(models.Model): > title = models.CharField(max_length=100) > links = models.ManyToManyField('Link', related_name='link') > > and a 'link' model > > class Link(models.Model): > label = models.CharField(max_length=50) > url = models.URLField(max_length=100) > project = models.ForeignKey(Project) > > I want the user to edit his project properties. I'm using ModelForm class > and a UpdateView to put everything together. But I have a problems: > > I want the form to only show those *link*s who are owned by the project in > the MultipleChoisesWidget, hence the ForeignKey in the Link model. > > Any help on how to achieve this? Thanks! > > P.S why isn't there a proper API documentation on django like doxygen? I > find the django documentation full of content but awful structure! > class ProjectForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(ProjectForm, self).__init__(*args, **kwargs) if self.instance and self.instance.pk: self.fields['links'].queryset = Link.objects.filter(project=self.instance) class Meta: model = Project -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Setup issue
Hi all, I am having a setup issue on my personal laptop, I got through setup and couple of tutorials on my Mac in work but not having any joy at home. I'm running Ubuntu 10.04 Lucid Lynx. I run "import django" and I don't get any errors back so I thought I was OK, but when I run "django-admin.py startproject projectname" I get back an error saying... "File ", line 1django-admin.py startproject projectname..Error: invalid syntax" I'm running on python 2.6.5, I had python3 installed and got rid of it encase it was conflicting, basically my question is were do I need to start looking, I must be missing something but I'm not sure were to start. Any advice I could get would be magic as it's my new year resolution to be efficient django man by end of year, not off to a great start :( -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Setup issue
Are you running "django-admin.py startproject projectname" within the python interpreter? Its supposed to run outside of the interpreter on the command line. On Jan 4, 3:17 pm, Phil wrote: > Hi all, > > I am having a setup issue on my personal laptop, I got through setup > and couple of tutorials on my Mac in work but not having any joy at > home. I'm running Ubuntu 10.04 Lucid Lynx. > > I run "import django" and I don't get any errors back so I thought I > was OK, but when I run "django-admin.py startproject projectname" I > get back an error saying... > > "File ", line 1django-admin.py startproject > projectname..Error: invalid syntax" > > I'm running on python 2.6.5, I had python3 installed and got rid of it > encase it was conflicting, basically my question is were do I need to > start looking, I must be missing something but I'm not sure were to > start. Any advice I could get would be magic as it's my new year > resolution to be efficient django man by end of year, not off to a > great start :( -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Setup issue
What actual project name are you using? Have you tried using different project names? If you're literally using "projectname" then you may be using a command-line argument and causing a conflict. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How configure Django to handle /books URL and yet allow access to PDFs/images in subdirs of /books?
Nevermind. I figured it out. To only have subdirs by static you need to add a "/" at the end of an Alias line... e.g. Alias /books/ /some/static/dir/ Thanks! cs -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Using A Form
I'm in the process of coding a new screen which I want to use a form on. I'm also currently coding the new form to go with it. The screen will have a dropdown box, a conditional textbox, and a submit button, as well as some other informational fields and a title on it. Since this is my first explicit attempt at using a form I have the following questions: 1. How does my form get recognized by or associated with the html screen file? 2. What form field type do I use to pass a list/collection in the form to the screen (Once I get it there I know I can display its individual items from within a for loop)? 3. Then once the user selects a value from the dropdown box, how can I read the value selected, in my view? 4. Finally how do I conditionally display the textbox only if the user has selected a value from the dropdown box and not display it if a value was not selected? I would appreciate any help with any or all of the above questions. Sorry if they're too simple, but I'm a newbie and almost everything about django is new and not necessarily intuitive to me just yet. Thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Using A Form
On Tuesday, January 4, 2011 8:55:50 PM UTC, hank23 wrote: > > I'm in the process of coding a new screen which I want to use a form > on. I'm also currently coding the new form to go with it. The screen > will have a dropdown box, a conditional textbox, and a submit button, > as well as some other informational fields and a title on it. Since > this is my first explicit attempt at using a form I have the following > questions: > > 1. How does my form get recognized by or associated with the html > screen file? > Via the view, just as with any other type of content. See the documentation on Using a form in a view: http://docs.djangoproject.com/en/1.2/topics/forms/#using-a-form-in-a-view > 2. What form field type do I use to pass a list/collection in the form > to the screen (Once I get it there I know I can display its individual > items from within a for loop)? > forms.ChoiceField or forms.ModelChoiceField. And you don't need to use a for loop, just render the field via {{ form.myfield }}. > 3. Then once the user selects a value from the dropdown box, how can I > read the value selected, in my view? > By instantiating the form with the values from request.POST. Again, the forms documentation explains all this in 'using a form in a view'. > 4. Finally how do I conditionally display the textbox only if the user > has selected a value from the dropdown box and not display it if a > value was not selected? > You'll need to do this in Javascript. > I would appreciate any help with any or all of the above questions. > Sorry if they're too simple, but I'm a newbie and almost everything > about django is new and not necessarily intuitive to me just yet. > Thanks. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
automated testing: how to generate human-verifiable views?
Hi, I'm trying to figure out the best way of doing something I'd like to partially automate staging testing by generating a sequence of human verifiable views, with the goal of making sure my app views/css/ 3rd-party javascript etc. are drawing the way they ought to in more complicated scenarios.While back end code can easily be tested with TestClient, failures in the 'final mile' of rendering are really annoying. It would be nice to have a 'view test mode' that allows a tester to click through a series of database configuration / URL pairs in a relatively painless way. Is there a standard way of doing this, or any existing modules I could use to achieve this? Jennifer -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
A few beginner questions
Hello, I am experienced PHP developer (and by PHP I mean advanced programming with MVC frameworks, TDD, ORM libraries, design patterns and such, so no scoffing please :)) and I would like to try something new. I've chosen Python and Django and I am building my bachelor thesis project with it. I dived directly into django-nonrel fork, because I am building the project on App Engine. However, I have few basic questions that concern basic relational Django as well. 1) Since Python has no object encapsulation, I have no idea how to implement computed columns in its models. E. g. I want to save forum post rating in the "posts" table even if I have related table with all the related post votes because it's faster and no joins are required to get the rating value. 2) I would like to perform some integrity checking before saving object to the database. I found here (http://docs.djangoproject.com/en/ 1.2/topics/db/models/#overriding-predefined-model-methods) that I can override entity save method and stop it's execution before calling parent implementation. However, this didn't work for me for two reasons - it somehow caused 500 error on App Engine (because the app does not know that the object was not saved?) and it does not meet my needs - I would like to "attach" some error message to this application state and I would like this message to bubble up to the form errors (in case it happens when a form is submitted) in a way compatible with Django admin, so the user can fix the problem. 3) I would like to read about some best practices about midsize and large Django projects. How to organize the code, what directory structure to choose etc. Are there any additional layers between model and views widely used? Where should I put my code that is not directly related to model and is used in more than one view? Can you recommend me some articles about this topic? 4) What about dependency injection? From what I saw so far it seems like Django is full of singletons, static attributes and methods and hidden dependencies, which are considered as bad practice. For example how can I use two connections to two different databases to load and save model entities? Are there any "inversion of control" concepts? Thank you very much! And you can expect more questions to come in this thread :) Ondřej Mirtes from Prague, Czech Republic -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: automated testing: how to generate human-verifiable views?
Can you elaborate a bit? Are you interested in having the ui render and generate a screen shot for human review? That's how I interpreted your question. If that's the case, look in to generating a screenshot by leveraging a tool that generates a png from HTML. I am eager to hear what others think. Nick On Tuesday, January 4, 2011, Jennifer Bell wrote: > Hi, > > I'm trying to figure out the best way of doing something I'd like > to partially automate staging testing by generating a sequence of > human verifiable views, with the goal of making sure my app views/css/ > 3rd-party javascript etc. are drawing the way they ought to in more > complicated scenarios. While back end code can easily be tested > with TestClient, failures in the 'final mile' of rendering are really > annoying. > > It would be nice to have a 'view test mode' that allows a tester to > click through a series of database configuration / URL pairs in a > relatively painless way. > > Is there a standard way of doing this, or any existing modules I could > use to achieve this? > > Jennifer > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: automated testing: how to generate human-verifiable views?
OK, to elaborate: I have a open source project with consistent pain points around css and browser testing. Example concrete issues for this project are a) multi-language support, as varying text length will often throw off the aesthetics of the layout, and b) recently, a mysterious failure in geodjango google-map drawing where in some corner-cases, the map silently fails to draw. Really, I'm looking for a framework for a human tester to be able to look at a sequence of html pages generated with different test data in the database. I want the tester to be able make a 'pretty/ugly/ horribly wrong' call without having to do a bunch of clicking or data entry. Ideally, they would just click 'next' on some widget, which would pull up the next URL/test db combination. Jennifer On Jan 4, 5:18 pm, Nick Stinemates wrote: > Can you elaborate a bit? > > Are you interested in having the ui render and generate a screen shot > for human review? That's how I interpreted your question. If that's > the case, look in to generating a screenshot by leveraging a tool that > generates a png from HTML. > > I am eager to hear what others think. > > Nick > > On Tuesday, January 4, 2011, Jennifer Bell wrote: > > Hi, > > > I'm trying to figure out the best way of doing something I'd like > > to partially automate staging testing by generating a sequence of > > human verifiable views, with the goal of making sure my app views/css/ > > 3rd-party javascript etc. are drawing the way they ought to in more > > complicated scenarios. While back end code can easily be tested > > with TestClient, failures in the 'final mile' of rendering are really > > annoying. > > > It would be nice to have a 'view test mode' that allows a tester to > > click through a series of database configuration / URL pairs in a > > relatively painless way. > > > Is there a standard way of doing this, or any existing modules I could > > use to achieve this? > > > Jennifer > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Setup issue
Hi Shawn, When it wasn't working I tried both from command line and from interpreter, from command line just says "command not found". No I wasn't calling the project that, I've tried a few different project names and none seem to work. Thanks for advice/ tips. I'll keep posted when I get to the bottom of it. On Jan 4, 3:33 pm, Shawn Milochik wrote: > What actual project name are you using? Have you tried using different > project names? > > If you're literally using "projectname" then you may be using a command-line > argument and causing a conflict. > > Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
multiple x__search
I'm using __search to boolean search for a list of words within two separate lists (requiredTags, preferredTags). Line 10 is the one I have questions about. I want to see if the list of words (requTags) is found among requiredTags or preferredTags. requTags="" prefeTags="" for i in reqTags: if(i!=""): requTags+="+"+i+" " for i in prefTags: if(i!=""): prefeTags+=i+" " if(requTags!=""): query=query &( Q(requiredTags__search + preferredTags__search = requTags)) if(prefeTags!=""): query=query &( Q(requiredTags__search = prefeTags) | Q(preferredTags__search = prefeTags)) For instance: requTags might be: +beans +rice +cheese. requiredTags might be: beans,rice,tortilla preferredTags might be: cheese I didn't see any way to combine requiredTags and preferredTags in the documentation. Any help would be appreciated. Note: I'm a complete noob. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Redirecting to last view after login.
Anybody? Bueller? On Jan 2, 8:25 pm, keynesiandreamer wrote: > I have wrestled with this one for a bit and googled and looked through > documentation, so I guess its time to ask. > > I am trying make my app redirect to the last viewed page after logging > in. I am running django 1.2.4 and have had no luck so far. > > This Stack Overflow thread seemed like it would do the trick but I > have not had success with > it:http://stackoverflow.com/questions/806835/django-redirect-to-previous... > > Currently after logging in from any view I am redirected > to:http://localhost:1100/accounts/profile/ > > Currently I am trying this in settings.py: > "django.core.context_processors.request", > > With this as my login button link: > login > > I also made sure to import the RequestContext in my views.py file: > from django.template import RequestContext > > Some how I get the impression this is not working. Also I noticed now > login URL has a partial next URL in > it:http://localhost:1100/accounts/login/?next= > > Suggestions? > > Thanks in advance! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Setup issue
On Tuesday, January 04, 2011 03:33:17 pm Phil wrote: > Hi Shawn, > > When it wasn't working I tried both from command line and from > interpreter, from command line just says "command not found". No I > wasn't calling the project that, I've tried a few different project > names and none seem to work. > > Thanks for advice/ tips. I'll keep posted when I get to the bottom of > it. > Sounds like django-admin.py is not in your path. see [1] about setting the path for os x (the same instructions and explanation can go for linux/*nix) The path in this case should have a listing fordjango/bin (note no leading /, I've named a relative path within the django checkout/install[2], you'll want to add the absolute path for your system). You're problem here suggests two things to me, 1. you're a novice to python/django (it's fair, we all got to start somewhere). 2. you have no clue on how any of your operating systems really work (again we have to start somewhere). I would suggest before you run off and make "the next big website", you sit back and take a few weeks to learn the basics of both administration for your operating systems (focusing on what os your site is going to run on in production) and working with python before you start building your site. (if this is a problem, i.e. you've taken a job without the minimum requirements met and need to get this done now, then do them side by side). If you don't, you'll find yourself with many more headaches like file permissions, where files are uploaded and how to access them and store them securly, dealing with module paths and import problems and even figuring out how to get your webserver of choice to serve your django site. These are mainly operating system issues. Also learn the difference between a python module and a python application. In this case django is a python module that provides a few python applications to make the developers life easier. You should be able to recognize them on sight and be able to use them both easily before you begin developing. Also if you google your error and the command name[3] you'll see that the solution for you in the first page of results (in this case the first hit[4]). 99% of most problems are answerable this way... as others have documented or asked a similar question and given a solution from various sources. If your google-fu isn't that great, time to practice this also. It'll save you much time and headaches. For me, these three things are essential: Knowing how a computer works, knowing how your operating system works and knowing how a programming language and the tools work are 3 different things and equally important in development, regardless if it's a website, desktop application, or server/service. IMO a good developer is also a good admin and visa-versa. *being an admin led me to being a developer, from wanting to understand how to debug and trace application issues to get around problems* Mike [1] http://www.tech-recipes.com/rx/2621/os_x_change_path_environment_variable/ [2] http://code.djangoproject.com/browser/django/trunk/django/bin [3] http://www.google.com/search?q=command+not+found+%2Bdjango-admin.py [4] http://code.djangoproject.com/wiki/InstallationPitfalls -- The worst cliques are those which consist of one man. -- G.B. Shaw -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to raise an error on django admin
I think the way to do is: from django.contrib import messages then somewhere... messages.add_message(request, messages.ERROR, "your error message") The message will be displayed in the top of the next admin page On 01/03/2011 09:40 PM, Acorn wrote: > I'd like to know this too. > > On 3 January 2011 17:25, rahul jain wrote: >> Hi, >> >> How to display an error in django admin (the error should be displayed in >> red just like in forms) >> >> Something of this form >> >> http://groups.google.com/group/django-users/browse_thread/thread/68d4ea1915654134/447ef8473cf86672 >> >> Thanks. >> >> Rahul >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-us...@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > signature.asc Description: OpenPGP digital signature
Re: A few beginner questions
Hi Ondřej. For your question #1, you could create a field in the model itself and then use signals[1] to populate it upon the saving of a "vote" instance. #2: The validation should all be done during form validation[2], prior to save. Using a Form or ModelForm. That way, the user can get friendly, useful errors. #3: I have no idea. Maybe someone else has recommendations. #4: There's a whole lot of stuff in that question. Maybe if you broke out some specific examples someone will try to explain the rationale behind the design. [1] http://docs.djangoproject.com/en/1.2/topics/signals/ [2] http://docs.djangoproject.com/en/1.2/ref/forms/validation/ Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Still mystified by mod_wsgi traceback ...
On Mon, Jan 3, 2011 at 4:36 PM, Stephen Waterbury < stephen.c.waterb...@nasa.gov> wrote: > I posted the traceback I'm getting -- http://dpaste.com/293813/ > I'm still completely mystified. The traceback directs me to: > "Edit your MIDDLEWARE_CLASSES setting to insert > 'django.contrib.auth.middleware.AuthenticationMiddleware' > before the RemoteUserMiddleware class." But looking further > up in the traceback, it sees that d.c.a.m.AuthenticationMiddleware > *is* there, and it's true -- I already have it in my > MIDDLEWARE_CLASSES setting before the RemoteUserMiddleware class, > so how could mod_wsgi possibly not be finding it? > The code issuing this message here is guessing about the cause of the real problem it has run into, which is that the request object it has been handed has no user attribute. The most likely reason for no user attribute on the request at this point is missing AuthenticationMiddleware, but if AuthenticationMiddleware is in place then there must be something else causing the problem. I happened to just stumble across one of these other possible problems: some other error in the project code. In my case I had a model with a method with a @Property decorator applied (leftover deliberate error to see what message that would generate -- should be @property). With that error in place, adding RemoteUserMiddleware to my config and trying to access the site via apache/mod_wsgi produced the error message you are seeing. The real error was obvious when I tried running the dev server, which would not even start properly with that error in place. Also, removing the RemoteUserMiddleware from the settings and accessing the site via apache/mod_wsgi showed the true error. Once I removed the erroneous @Property decorator, the RemoteUserMiddleware error went away. I'm not sure why this RemoteUserMiddleware error is having the effect of hiding other errors, and don't have time to dig into that right now. But one possible way to figure out what is going on in your case would be to try removing that middleware and seeing if some other error is reported. Karen -- http://tracey.org/kmt/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: cannot login to admin site with superuser
python manage.py shell works normally. It gives me the interactive console On 4 Ιαν, 22:05, Shawn Milochik wrote: > What happens when you try 'manage.py shell'? > > Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
ContentType does not exist when trying to load auth with loaddata
Hi, We are trying to migrate databases and we are running into problems. We can dump the data: ./manage.py dumpdata --format=xml --natural --all --traceback auth > auth.xml But when we try and load it, we get an exception: ./manage.py loaddata --database=mysql auth.xmlInstalling xml fixture 'auth' from absolute path. Problem installing fixture 'auth.xml': Traceback (most recent call last): File "/mnt/home/django/projects/rf/lib/python2.6/site-packages/django/core/management/commands/loaddata.py", line 167, in handle for obj in objects: File "/mnt/home/django/projects/rf/lib/python2.6/site-packages/django/core/serializers/xml_serializer.py", line 158, in next return self._handle_object(node) File "/mnt/home/django/projects/rf/lib/python2.6/site-packages/django/core/serializers/xml_serializer.py", line 198, in _handle_object data[field.attname] = self._handle_fk_field_node(field_node, field) File "/mnt/home/django/projects/rf/lib/python2.6/site-packages/django/core/serializers/xml_serializer.py", line 222, in _handle_fk_field_node obj = field.rel.to._default_manager.db_manager(self.db).get_by_natural_key(*field_value) File "/mnt/home/django/projects/rf/lib/python2.6/site-packages/django/contrib/contenttypes/models.py", line 15, in get_by_natural_key ct = self.get(app_label=app_label, model=model) File "/mnt/home/django/projects/rf/lib/python2.6/site-packages/django/db/models/manager.py", line 132, in get return self.get_query_set().get(*args, **kwargs) File "/mnt/home/django/projects/rf/lib/python2.6/site-packages/django/db/models/query.py", line 341, in get % self.model._meta.object_name) DoesNotExist: ContentType matching query does not exist. How do we get around this error? Shouldn't syncdb create the ContentTypes? -- Eric Chamberlain -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
PostGISAdapter error
I am getting the following error when the queryset tries to generate the SQL: "'str' object has no attribute 'ewkb'" Here is what I am doing that causes the problem: shapes = Shape.objects.filter(geom__bboverlaps=bbx) shape_info = shape_info.filter(shape__in=shapes) Models are: class Shape(models.Model): … geom = models.PolygonField() color = models.IntegerField() class ShapeInfo(models.Model): … name = models.CharField(max_length=25) shape = models.ForeignKey(Shape) The code causing the problem seems to be: if (len(params) == 1 and params[0] == '' and lookup_type == 'exact' and connection.features.interprets_empty_strings_as_nulls): lookup_type = 'isnull' value_annot = True Is this not an appropriate way to use this? Here is the stacktrace: /Library/Python/2.6/site-packages/django/db/models/query.py in _result_iter self._fill_cache() ... ▶ Local vars /Library/Python/2.6/site-packages/django/db/models/query.py in _fill_cache self._result_cache.append(self._iter.next()) ... ▶ Local vars /Library/Python/2.6/site-packages/django/db/models/query.py in iterator for row in compiler.results_iter(): ... ▶ Local vars /Library/Python/2.6/site-packages/django/db/models/sql/compiler.py in results_iter for rows in self.execute_sql(MULTI): ... ▶ Local vars /Library/Python/2.6/site-packages/django/db/models/sql/compiler.py in execute_sql sql, params = self.as_sql() ... ▶ Local vars /Library/Python/2.6/site-packages/django/db/models/sql/compiler.py in as_sql where, w_params = self.query.where.as_sql(qn=qn, connection=self.connection) ... ▶ Local vars /Library/Python/2.6/site-packages/django/db/models/sql/where.py in as_sql sql, params = child.as_sql(qn=qn, connection=connection) ... ▶ Local vars /Library/Python/2.6/site-packages/django/db/models/sql/where.py in as_sql sql, params = self.make_atom(child, qn, connection) ... ▶ Local vars /Library/Python/2.6/site-packages/django/db/models/sql/where.py in make_atom if (len(params) == 1 and params[0] == '' and lookup_type == 'exact' ... ▶ Local vars /Library/Python/2.6/site-packages/django/contrib/gis/db/backends/postgis/adapter.py in __eq__ return (self.ewkb == other.ewkb) and (self.srid == other.srid) ... ▼ Local vars VariableValue other '' self -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Any Django framework command to freeze/wait/notify ?
Hi all, This is a common scenario which many of you have faced. Say, I created a simple view file, in which user uploads a file and does some processing at backend and after processing is finished I am rendering a html page with some processed result. My problem is that, there should be some kind of a mechanism, by which I can notify user that "processing is going in background, so please wait till the processing finished." So, what are the easy to implement options I have ? Does Django provides something for these scenario ? Will javascript (timer mechanism) work ? Comment/suggestions ? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.