inline-model-formset help
I have a simple model:
class LineItem(models.Model):
customer = models.ForeignKey(Customer)
merchant = models.ForeignKey(Merchant)
product = models.ForeignKey(Product)
child = models.ForeignKey(Pupil)
amount = models.FloatField(blank=False,editable=False,
default=1.000)
In my view I would like the user to create multiple lineitems, where
the customer and the merchant are already defined. The user should
select from a drop down list of products (filtered by merchant), enter
the name of the child and an amount. If the *default* amount is >
1.000 then that is considered the minimum amount for that combination
(merchant+product).
Here is the relevant other model:
class Pupil(models.Model):
parent = models.ForeignKey(Customer,related_name=_(u'Parent'))
school = models.ForeignKey(Merchant,related_name=_(u'School'))
name = models.CharField(blank=False, max_length=100)
relationship =
models.IntegerField(verbose_name=_(u'Relationship'),
choices=(
(1,_(u'Son')),
(2,_(u'Daughter')))
)
I have "manually" created the front-end forms, but I ran into a wall
when trying to redisplay the form with errors. I can display the
errors fine, but I can't figure out how to pre-populate the fields.
After some digging through the docs I came across inline-formsets but
I'm not sure how to wire it up in my scenario.
Thanks for any guidance.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home