Re: Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Peter Bailey
Well I experimented with your tips Daniel, and put this in my forms file: class SurveyForm(forms.ModelForm): name = forms.CharField(max_length=50, widget=forms.TextInput(attrs= {'size':'50'})) class Meta: model = Survey And it works. I assume I just add the ones above that I

Re: Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Peter Bailey
Thanks Andy On Jan 15, 1:50 pm, Andy Mckay wrote: > I don't think you are defining the ModelForm correctly, the whole   > point is that Django creates the fields for you. If you look at: > > http://docs.djangoproject.com/en/dev/topics/forms/modelforms > > This is the key

Re: Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Andy Mckay
I don't think you are defining the ModelForm correctly, the whole point is that Django creates the fields for you. If you look at: http://docs.djangoproject.com/en/dev/topics/forms/modelforms This is the key difference between a ModelForm and a normal form:

Re: Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Peter Bailey
Thanks for the tips Dan, I thought the DRY thing could not be right. Not sure I understand tho - I originally made the form with just the inner Meta class definition - do you do that and then override things that need to change (e.g. where I want to use a longer TextInput widget or whatever.

Re: Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Daniel Roseman
On Jan 15, 5:35 pm, Peter Bailey wrote: > I have just recently started using forms. I was avoiding them because > I thought they were not very DRY, but discovered I need them for added > flexibility such as displaying field lengths for example. > > Anyway, I have created a

Re: Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Andrew Mckay
On 15-Jan-09, at 9:35 AM, Peter Bailey wrote: > Anyway, I have created a Form for a Survey object that I use. If I go > to my edit page for a Survey, everything works perfectly. If I go to > do a simple add new (like right out of the docs), I always receive an > error "NoneType' object is not

Created Form - now code works to edit object but add gets NoneType' object is not callable

2009-01-15 Thread Peter Bailey
I have just recently started using forms. I was avoiding them because I thought they were not very DRY, but discovered I need them for added flexibility such as displaying field lengths for example. Anyway, I have created a Form for a Survey object that I use. If I go to my edit page for a