Re: get_initial on a ForeignKey on ModelForm not working properly

2013-02-06 Thread Michele Mattioni
Hi Timster, thanks for pointing to the right method. Now it works like a charm. Cheers, Michele On Mon, Feb 4, 2013 at 3:56 PM, Timster wrote: > By setting "initial" on a field, you are not changing the list of > available options. Setting the initial like this determines which of all > the l

Re: get_initial on a ForeignKey on ModelForm not working properly

2013-02-04 Thread Timster
By setting "initial" on a field, you are not changing the list of available options. Setting the initial like this determines which of all the locations are selected when the form is shown for the first time. The default would be to select the location for the event, but you are overriding that

Re: get_initial on a ForeignKey on ModelForm not working properly

2013-02-04 Thread Michele Mattioni
I return initial on the method on my code, I forgot to include it in the example. I just repast to make sure it's clear class EventCreate(CreateView): model = Event def get_initial(self): initial = super(EventCreate, self).get_initial() initial['loca

Re: get_initial on a ForeignKey on ModelForm not working properly

2013-02-04 Thread Timster
You need to return initial from the method. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, sen

get_initial on a ForeignKey on ModelForm not working properly

2013-02-04 Thread Michele Mattioni
Dear all, I'm using generic edit view to create my form, building the form from a ModelForm. Take a look of this quick example code: class Event(models.Model) location = models.ForeignKey(Location) class EventCreate(CreateView): model = Event def get_initial(