Search Results

Search found 1 results on 1 pages for 'jimbocooper'.

Page 1/1 | 1 

  • Multiple model forms with some pre-populated fields

    - by jimbocooper
    Hi! Hope somebody can help me, since I've been stuck for a while with this... I switched to another task, but now back to the fight I still can't figure out how to come out from the black hole xD The thing is as follows: Let's say I've got a product model, and then a set of Clients which have rights to submit data for the products they've been subscribed (Many to Many from Client to Product). Whenever my client is going to submit data, I need to create as many forms as products he's subscribed, and pre-populate each one of them with the "product" field as long as perform a quite simple validation (some optional fields have to be completed if it's client's first submission). I would like one form "step" for each product submission, so I've tried formWizards... but the problem is you can't pre-assign values to the forms... this can be solved afterwards when submitting, though... but not the problem that it doesn't allow validation either, so at the end of each step I can check some data before rendering next step. Then I've tried model formsets, but then there's no way to pre-populate the needed fields. I came across some django plugins, but I'm not confident yet if any of them will make it.... Did anybody has a similar problem so he can give me a ray of light? Thanks a lot in advance!! :) edit: The code I used in the formsets way is as follows: prods = Products.objects.filter(Q(start_date__lte=today) & Q(end_date__gte=today), requester=client) num = len(prods) PriceSubmissionFormSet = modelformset_factory(PriceSubmission, extra=num) formset = PriceSubmissionFormSet(queryset=PriceSubmission.objects.none())

    Read the article

1