Re: Preselected Radio button
thanks bruno. and thanks for the advice on tuples too. On 25 May 2011 17:30, "bruno desthuilliers" <bruno.desthuilli...@gmail.com> wrote: > On May 25, 4:12 pm, Ndungi Kyalo <ndu...@gmail.com> wrote: >> Am trying to pre-select a radio button created with the django.forms library : >> >> choices = forms.ChoiceField( >> widget = forms.RadioSelect(), >> choices = [ >> ['a', 'i liked it'], >> ['b', 'i did not like it'] >> ], >> required=True >> ) >> >> How would I go about getting the 'a' choice pre-selected on an unbound form ? > > http://docs.djangoproject.com/en/1.3/ref/forms/api/#dynamic-initial-values > > IIRC, this should be enough. > > As a side note, you'd better use tuples than lists for your choices - > at least for the "value, label" pairs which are semantically tuples, > and possibly for the choices list itself but then it's more of a micro- > optimisation (tuples are lest costly than lists). > > -- > You received this message because you are subscribed to the Google Groups "Django users" group. > To post to this group, send email to django-users@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-users@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 Validation - Redisplay With Error
sorry, i'll repost under the appropriate subject. On 25 May 2011 17:11, Ndungi Kyalo <ndu...@gmail.com> wrote: > Am trying to pre-select a radio button created with the django.forms library > : > vote = forms.ChoiceField( > widget = forms.RadioSelect(), > choices = [ > ['a', 'i liked it'], > ['b', 'i did not like it'] > ], > required=True > ) > How would I go about getting the 'a' choice pre-selected on an unbound form > ? > -- > Ndungi Kyalo -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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.
Preselected Radio button
Am trying to pre-select a radio button created with the django.forms library : choices = forms.ChoiceField( widget = forms.RadioSelect(), choices = [ ['a', 'i liked it'], ['b', 'i did not like it'] ], required=True ) How would I go about getting the 'a' choice pre-selected on an unbound form ? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 Validation - Redisplay With Error
Am trying to pre-select a radio button created with the django.forms library : vote = forms.ChoiceField( widget = forms.RadioSelect(), choices = [ ['a', 'i liked it'], ['b', 'i did not like it'] ], required=True ) How would I go about getting the 'a' choice pre-selected on an unbound form ? -- Ndungi Kyalo -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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: request.user.save() doesnt work
Keep in mind am using this on appengine as django-nonrel. Perhaps someone in the nonrel project or someone with some experience with it could tell us whether this is a known issue On 12 March 2011 12:11, Ndungi Kyalo <ndu...@gmail.com> wrote: > It is a django.contrib.auth.models.User , as you say. > > > On 11 March 2011 22:06, Jason Culverhouse <ja...@mischievous.org> wrote: > >> >> On Mar 11, 2011, at 10:46 AM, Daniel Roseman wrote: >> >> > On Thursday, March 10, 2011 11:59:15 PM UTC-8, Ndungi Kyalo wrote: >> > Hi guys. Am using django non-rel on appengine. I am using django's >> > auth backend for my authentication, since I did not want to have to >> > force my users to use gmail logins, and appengine models >> > {google.appengine.ext.db} for the other models. I have a form where I >> > allow users to edit their email. So : >> > >> > if settings_form.is_valid() : >> > user = request.user >> > user.email = request.POST['email'] >> > user.save() >> > >> > print request.POST['email'] returns the correct data entered in the >> > form. But user.save() just doesnt save! >> > Am I doing it correctly ? Is there something else I shopuld be doing ? >> > -- >> > Regards, >> > Guy-at-the-end-of-the-tether :-) >> > >> > Are you sure that the condition is true - that the form is valid? Put >> some logging in to be sure. >> >> Are you sure that user is a django.contrib.auth.models.User and not at >> django.contrib.auth.models.AnonymousUser. >> >> >> http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.user >> >> if request.user.is_authenticated(): >># Do something for logged-in users. >> else: >># Do something for anonymous users. >> >> >> >> > -- >> > 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-users@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-users@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-users@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: request.user.save() doesnt work
It is a django.contrib.auth.models.User , as you say. On 11 March 2011 22:06, Jason Culverhouse <ja...@mischievous.org> wrote: > > On Mar 11, 2011, at 10:46 AM, Daniel Roseman wrote: > > > On Thursday, March 10, 2011 11:59:15 PM UTC-8, Ndungi Kyalo wrote: > > Hi guys. Am using django non-rel on appengine. I am using django's > > auth backend for my authentication, since I did not want to have to > > force my users to use gmail logins, and appengine models > > {google.appengine.ext.db} for the other models. I have a form where I > > allow users to edit their email. So : > > > > if settings_form.is_valid() : > > user = request.user > > user.email = request.POST['email'] > > user.save() > > > > print request.POST['email'] returns the correct data entered in the > > form. But user.save() just doesnt save! > > Am I doing it correctly ? Is there something else I shopuld be doing ? > > -- > > Regards, > > Guy-at-the-end-of-the-tether :-) > > > > Are you sure that the condition is true - that the form is valid? Put > some logging in to be sure. > > Are you sure that user is a django.contrib.auth.models.User and not at > django.contrib.auth.models.AnonymousUser. > > > http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.user > > if request.user.is_authenticated(): ># Do something for logged-in users. > else: ># Do something for anonymous users. > > > > > -- > > 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-users@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-users@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-users@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: request.user.save() doesnt work
Yes, the form validates and returns true. On 11 March 2011 21:46, Daniel Rosemanwrote: > Are you sure that the condition is true - that the form is valid? Put some > logging in to be sure. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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.
request.user.save() doesnt work
Hi guys. Am using django non-rel on appengine. I am using django's auth backend for my authentication, since I did not want to have to force my users to use gmail logins, and appengine models {google.appengine.ext.db} for the other models. I have a form where I allow users to edit their email. So : if settings_form.is_valid() : user = request.user user.email = request.POST['email'] user.save() print request.POST['email'] returns the correct data entered in the form. But user.save() just doesnt save! Am I doing it correctly ? Is there something else I shopuld be doing ? -- Regards, Guy-at-the-end-of-the-tether :-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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.