Heya, as i'm playing around i was wondering how to add custom fields
to my form so i can use them while iterating in my templates (e.g.
headings), i so far came up with this:
class MyModel(models.Model):
field = models.IntegerField()
class MyForm(forms.ModelForm):
class Meta:
model = MyModel
def __init__(self, thing, **args, **kwargs):
self.thing = thing
super(MyForm, self).__init__(*args, **kwargs)
class MyFormSet(forms.models.BaseModelFormSet):
def _construct_form(self, i, **kwargs):
kwargs['thing'] = 1
super(MyFormSet, self)._construct_form(i, **kwargs)
but as soon as put all those 3 to modelformset_factory via:
generator = modelformset_factory(MyModel, form = MyForm, formset =
MyFormSet)
formset = generator()
return HttpResponse(formset.as_table())
i get:
<type 'exceptions.AttributeError'>: 'NoneType' object has no
attribute 'as_table'
args = ("'NoneType' object has no attribute 'as_table'",)
message = "'NoneType' object has no attribute 'as_table'"
any help is appreciated, thank you
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---