public
Description: A high-level Python Web framework that encourages rapid development and clean, pragmatic design.
Homepage: http://www.djangoproject.com/
Clone URL: git://github.com/brosner/django.git
Search Repo:
Added a section on using inlineformset_factory.
brosner (author)
Mon May 12 15:48:08 -0700 2008
commit  0c77c91dd7c557cef4c1e2440ddc63bfe424447d
tree    7d3fd0a6e86aafffb1f80842be966fa97ec5f2a2
parent  79b6a8c56ebcb38ffab05ff8f7cea197ce29edc3
...
407
408
409
 
 
 
 
 
 
 
 
 
 
 
 
 
...
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
0
@@ -407,4 +407,17 @@
0
 configurable::
0
 
0
     >>> formset = AuthorFormSet(queryset=Author.objects.filter(name__startswith='O'))
0
+
0
+Using ``inlineformset_factory``
0
+-------------------------------
0
+
0
+The ``inlineformset_factory`` is a helper to a common usage pattern of working
0
+with related objects through a foreign key. Suppose you have two models
0
+``Author`` and ``Book``. You want to create a formset that works with the
0
+books of a specific author. Here is how you could accomplish this::
0
+
0
+ >>> from django.newforms.models import inlineformset_factory
0
+ >>> BookFormSet = inlineformset_factory(Author, Book)
0
+ >>> author = Author.objects.get(name=u'Orson Scott Card')
0
+ >>> formset = BookFormSet(instance=author)

Comments

    No one has commented yet.