Re: How to set the from a ModelChoiceField?
Thank you very much... it took me some time to figure it out. But now it works :) --~--~-~--~~~---~--~~ 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: How to set the from a ModelChoiceField?
class MyForm(...): def __init__(self, *args, **kwargs): super(MyForm, self).__init__(*args, **kwargs) self.fields['myfield'].choices = City.objects.values_list('id', name_field) --~--~-~--~~~---~--~~ 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: How to set the from a ModelChoiceField?
I suspect that bots aren't going to follow form submits like this so it doesn't matter. But if you have these GET queries coded into any html elements, thereby becoming part of the sitemap, then it probably will matter. This is a bit of a common sense punt, i'm not an SEO expert, so standing-by to be corrected! On 22 Dec 2008, at 13:06, mb0...@googlemail.com wrote: > > Hello, > > I have a ModelChoiceField getting filled up by a database queryset. > Works fine this far. > In my template the entries of the select-field look all like this: > Afghanistan > > I know that that the value between the two option tags (Afghanistan) > can be set by changing the model's __str()__-method. But is there also > a way to change the way the value-attribut (3) is set? By now it is > the unique id-field from the database, I guess. > I would like to change it, to get more SE-friendly urls (when > submitting the form with GET). Or am I wrong about this? > > > Kind regards, > Martin > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
How to set the from a ModelChoiceField?
Hello, I have a ModelChoiceField getting filled up by a database queryset. Works fine this far. In my template the entries of the select-field look all like this: Afghanistan I know that that the value between the two option tags (Afghanistan) can be set by changing the model's __str()__-method. But is there also a way to change the way the value-attribut (3) is set? By now it is the unique id-field from the database, I guess. I would like to change it, to get more SE-friendly urls (when submitting the form with GET). Or am I wrong about this? Kind regards, Martin --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---