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.

Things worked fine until I changed to the above form definition so
that I could make mods to the default output.

re "client = forms.ModelChoiceField(User.objects.all())", that is the
line I mentioned above that I commented out because I suspected it
too. I tried your change, still not working

Here is the traceback. Thanks Dan and Andrew, listening while I am
being so verbose, but I wanted to convey as much info as possible. I
am learning django and python together, and it gets to be pretty
boggling sometimes, although it is the most fun developing I have had
in years. I appreciate you taking your time looking at this.

Environment:

Request Method: GET
Request URL: http://localhost:8000/surveyadd/
Django Version: 1.1 pre-alpha SVN-9734
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'generator.surveys']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware')


Traceback:
File "/Library/Python/2.5/site-packages/django/core/handlers/base.py"
in get_response
  86.                 response = callback(request, *callback_args,
**callback_kwargs)
File "/Users/peterbailey/pywork/generator/../generator/surveys/
views.py" in surveyadd
  137.         form = SurveyForm()
File "/Library/Python/2.5/site-packages/django/forms/models.py" in
__init__
  212.             self.instance = opts.model()

Exception Type: TypeError at /surveyadd/
Exception Value: 'NoneType' object is not callable


Hope that is all the traceback info you need.

Peter





On Jan 15, 1:16 pm, Daniel Roseman <roseman.dan...@googlemail.com>
wrote:
> On Jan 15, 5:35 pm, Peter Bailey <p.h.bai...@gmail.com> 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 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 callable". So I am assuming I am trying
> > to use something not in existence yet, but it seems bizarre to me (but
> > I am a form noob and hoping I am doing something stupid (at least 1
> > thing)). Here is my model
>
> <snip code>
>
> > I tried commenting out the foreign key to the user but that made no
> > difference. I must be doing something stupid here (obvious hopefully).
>
> > Can anyone tell me what the problem is?
>
> > Thanks,
>
> > Peter
>
> Why have you repeated all the definitions from the model in your form?
> As you say, that isn't very DRY, but there's no reason to do it at
> all.
>
> It would have been helpful to have posted the full traceback. I
> suspect your error is coming from this line:
>         client = forms.ModelChoiceField(User.objects.all())
> which should be
>         client = forms.ModelChoiceField(queryset=User.objects.all())
> However, as i note above, you don't need the line - or any of the
> field declarations - at all. You do, however, need an inner Meta class
> which defines the model the form belongs to (Survey).
>
> --
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to