Bonjour
je débute dans la prise en main de django.
Il y a pas mal de doc, meme en anglais, c'est assez compréhensible mais je ne voudrais pas faire d'erreur.
notamment sur cette partie " inline formset" :
est ce que l'on peut m'expliquer a quoi sert : inlineformset_factory
merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 Inline formsets is a small abstraction layer on top of model formsets. These simplify the case of working with related objects via a foreign key. Suppose you have these two models: class Author(models.Model): name = models.CharField(max_length=100) class Book(models.Model): author = models.ForeignKey(Author) title = models.CharField(max_length=100) If you want to create a formset that allows you to edit books belonging to a particular author, you could do this: >>> from django.forms.models import inlineformset_factory >>> BookFormSet = inlineformset_factory(Author, Book) >>> author = Author.objects.get(name=u'Mike Royko') >>> formset = BookFormSet(instance=author)
fabien
Partager