I have the following models:

class Category(models.Model):
    type = models.CharField(max_length=128)

class CategoryTerm(models.Model):
    term = models.CharField(max_length=128)
    type = models.ForeignKey(Category, related_name='terms')

class CategoryMap(models.Model):
    term = models.ForeignKey(CategoryTerm, db_index=True)
    type = models.ForeignKey(Category, db_index=True)

    content_type = models.ForeignKey(ContentType,
verbose_name='content type', db_index=True)
    object_id = models.PositiveIntegerField(db_index=True)
    content_object = generic.GenericForeignKey('content_type',
'object_id')

I have another class called StaticPage, so I can do:

form = CreatePageForm()

Then I do:

CategoryMapFormSet = generic_inlineformset_factory(CategoryMap,
extra=1, can_delete=False)
cat_formset = CategoryMapFormSet(instance=StaticPage())
gfs = generic_inlineformset_factory(CategoryMap)
print gfs.form().as_p()

u'<p><label for="id_term">Term:</label> <select name="term"
id="id_term">\n<option value="" selected="selected">---------</option>
\n<option value="1">England</option>\n<option value="2">News</option>
\n<option value="3">Loblaws</option>\n</select></p>\n<p><label
for="id_type">Type:</label> <select name="type" id="id_type">\n<option
value="" selected="selected">---------</option>\n<option
value="1">Country</option>\n<option value="2">Topic</option>\n<option
value="3">Store</option>\n</select></p>'

This means that a user can select a term for a category it doesn't
belong to.

So how does one use generic_inlineformset_factory properly?

Thanks

-- 
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