I have the following class:

class QuoteForm( ModelForm ):

    class Meta:
        fields = [ 'user', 'photo', 'created', 'usage', 'complete', ]
        model = Quote

    def __init__(self, *args, **kwargs ):
        import pdb; pdb.set_trace()
        super( QuoteForm, self ).__init__( *args, **kwargs )
        import pdb; pdb.set_trace()
        self.fields.keyOrder = self.Meta.fields

when I debug, I get the following results:

-> super( QuoteForm, self ).__init__( *args, **kwargs )
(Pdb) dir (self.Meta)
['__doc__', '__module__', 'exclude', 'fields', 'model']
(Pdb) p self.Meta.exclude, self.Meta.fields, self.Meta.model
([], None, <class 'website.models.Quote'>)
(Pdb) p self.fields
*** AttributeError: AttributeError("'QuoteForm' object has no
attribute 'fields'",)
(Pdb) c
> c:\development\repositories\jhp\jhp\website\forms.py(58)__init__()
-> self.fields.keyOrder = self.Meta.fields
(Pdb) p self.Meta.exclude, self.Meta.fields, self.Meta.model
([], None, <class 'website.models.Quote'>)
(Pdb) p self.fields
{'user': <django.forms.models.ModelChoiceField object at 0x01609930>,
'photo': <django.forms.models.ModelChoiceField ob
ect at 0x016097B0>, 'usage': <django.forms.fields.CharField object at
0x01609630>, 'created': <django.forms.fields.Spli
DateTimeField object at 0x01609DB0>, 'complete':
<django.forms.fields.BooleanField object at 0x01609B30>}
(Pdb)

django has set Meta.fields to None, ensuring that:
a) fields are not rendered in the correct order, and
b) a 'NoneType' object is not iterable exception occurs on saving

Can anyone explain this problem?
--~--~---------~--~----~------------~-------~--~----~
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