If I remove that line, the "'NoneType' object has no attribute 'widget' " exception is still thrown at if not f.is_valid():. That's why I trid to define it again...
On Oct 1, 11:44 am, Rama Vadakattu <rama.vadaka...@gmail.com> wrote: > 'importance' field is already comming from model. > Why did you defined again in the forms? (remove it and check out > whether error is occurring or not) > > On Oct 1, 2:33 pm, dijxtra <nsko...@gmail.com> wrote: > > > On Sep 30, 5:12 pm, Karen Tracey <kmtra...@gmail.com> wrote: > > > > On Wed, Sep 30, 2009 at 10:53 AM, dijxtra <nsko...@gmail.com> wrote: > > > > > I'm getting "'NoneType' object has no attribute 'widget'" exception > > > > and I just can't figure out where is the problem. Here is my error: > > > > > Django Version: 1.1 > > > > > Traceback: > > > > [snip] > > > > In this form: > > > > 1. class DiaryEntryForm(ModelForm): > > > 2. importance = models.IntegerField(choices=IMPORTANCE_CHOICES) > > > 3. class Meta: > > > 4. model = DiaryEntry > > > 5. fields = ['text', 'date', 'type', 'importance'] > > > > 'importance' has been specified as a model field instead of a form field. > > > It needs to be a form field, since this is a form, not a model. > > > Damn. This one was obvious. But, despite of this bugfix, the error > > still remains. > > > This one:http://pastebin.com/pastebin.php?diff=m1867a8ad > > Gives me this: > > Django Version: 1.1 > > > Traceback: > > File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in > > get_response > > 92. response = callback(request, *callback_args, > > **callback_kwargs) > > File "C:\Python26\lib\site-packages\django\contrib\auth\decorators.py" > > in __call__ > > 78. return self.view_func(request, *args, **kwargs) > > File "C:\Documents and Settings\nick\My Documents\freediary\.. > > \freediary\diary\actions.py" in add_entry > > 11. if not f.is_valid(): > > File "C:\Python26\lib\site-packages\django\forms\forms.py" in is_valid > > 120. return self.is_bound and not bool(self.errors) > > File "C:\Python26\lib\site-packages\django\forms\forms.py" in > > _get_errors > > 111. self.full_clean() > > File "C:\Python26\lib\site-packages\django\forms\forms.py" in > > full_clean > > 234. value = field.widget.value_from_datadict(self.data, > > self.files, self.add_prefix(name)) > > > Exception Value: 'NoneType' object has no attribute 'widget' > > > I also tried this one:http://pastebin.com/pastebin.php?diff=m4c55050 > > And it gives me python exception: > > Validating models... > > Unhandled exception in thread started by <function inner_run at > > 0x0110DAB0> > > Traceback (most recent call last): > > File "C:\Python26\lib\site-packages\django\core\management\commands > > \runserver. > > py", line 48, in inner_run > > self.validate(display_num_errors=True) > > File "C:\Python26\lib\site-packages\django\core\management\base.py", > > line 249, > > in validate > > num_errors = get_validation_errors(s, app) > > File "C:\Python26\lib\site-packages\django\core\management > > \validation.py", lin > > e 28, in get_validation_errors > > for (app_name, error) in get_app_errors().items(): > > File "C:\Python26\lib\site-packages\django\db\models\loading.py", > > line 131, in > > get_app_errors > > self._populate() > > File "C:\Python26\lib\site-packages\django\db\models\loading.py", > > line 58, in > > _populate > > self.load_app(app_name, True) > > File "C:\Python26\lib\site-packages\django\db\models\loading.py", > > line 74, in > > load_app > > models = import_module('.models', app_name) > > File "C:\Python26\lib\site-packages\django\utils\importlib.py", line > > 35, in im > > port_module > > __import__(name) > > File "C:\Documents and Settings\nick\My Documents\freediary\.. > > \freediary\diary > > \models.py", line 47, in <module> > > class DiaryEntryForm(forms.ModelForm): > > File "C:\Documents and Settings\nick\My Documents\freediary\.. > > \freediary\diary > > \models.py", line 49, in DiaryEntryForm > > importance = forms.IntegerField > > (choices=DiaryEntry.IMPORTANCE_CHOICES) > > File "C:\Python26\lib\site-packages\django\forms\fields.py", line > > 173, in __in > > it__ > > super(IntegerField, self).__init__(*args, **kwargs) > > TypeError: __init__() got an unexpected keyword argument 'choices' > > > Any ideas what to do next? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---