Thanks Shawn,

I think i satisfied with this way. It seems a suitable way for Django.
I'll use it. Thanks again,

2011/8/23 Shawn Milochik <sh...@milochik.com>:
> On 08/22/2011 05:44 PM, ozgur yilmaz wrote:
>>
>> Ok. Thank you so much. So, formset is a suitable way to achieve this.
>> But, is it the most django-oriented way? Is there any alternative way?
>> Maybe using popup window to select a product, and handle the return
>> value of popup, then use a hiddenvalue to hold the return value. And
>> repeat this for many times, to add multiple product? Is it a common
>> way? Thanks again,
>>
>
> Given that a Django formset is a feature of Django, I'd say it's a pretty
> django-oriented way. However, the way I suggested doesn't require formsets.
>
> Briefly:
>
>    1. Have JavaScript on your page that can dynamically add elements to your
> HTML form.
>
>    2. Ensure that your JavaScript attaches a unique prefix to each set of
> elements that belong together. Example, if you'll have a product ID and
> quantity, you need to make sure that each pair share the same prefix and no
> other elements share that prefix.
>        Example:
>            <input type="text" id="1-quantity" />
>            <input type="text" id="1-product_id" />
>
>            <input type="text" id="2-quantity" />
>            <input type="text" id="2-product_id" />
>
>    3. In your view, get a list of the prefixes from your request.POST.
>
>    4. For each prefix, create a ModelForm instance passing the prefix kwarg
> with the prefix and request.POST as the data kwarg.
>
> From there it's straightforward.
>
> Shawn
>
> --
> 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.
>
>

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