Re: Slow page load performance with a large number of formsets (over 25)

2022-02-26 Thread Carlos R. Pacheco F.
The solution is to use select2  with
ajax

El vie, 25 feb 2022 a la(s) 19:58, Jacob Greene (jacobgreene1...@gmail.com)
escribió:

> If you're using model choice fields, it's very likely you are making an
> SQL query for each form set. It should be pretty obvious in the log with
> debug turned on.
>
> On Fri, Feb 25, 2022, 4:31 PM Ryan Nowakowski  wrote:
>
>> Steven, are you using ModelFormSet?  If so, Is it the initial query
>> that's slow?  The form rendering?  Or is it the POST back to the server
>> that's slow?  You can use django-debug-toolbar[1] to profile your page
>> and get these metrics.
>>
>> Once you figure out what part is slowest, then you can optimize.
>>
>> Hope this helps!
>>
>> Ryan N
>>
>> [1] https://django-debug-toolbar.readthedocs.io/en/latest/
>>
>> On Mon, Feb 07, 2022 at 09:12:48AM -0800, Steven Smith wrote:
>> > Did this issue ever get resolved?  I'm experiencing the same thing.
>> Once
>> > it hits 100 forms or so it gets pretty slow.
>> >
>> > On Monday, September 22, 2014 at 10:48:52 AM UTC-5 Collin Anderson
>> wrote:
>> >
>> > > Yes, if you want speed, using javascript and ajax is probably your
>> best
>> > > bet. It will probably also reduce merge-conflicts.
>> > >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/20220225222926.GH11627%40fattuba.com
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAF-Y%3De5Fp7kDtLq47Z3Y4GEjXMne2PcTLYxOJ8St5gkKCkpUpw%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGAbt9M3N%2BU8eewvChkZk9s1r75DQ7t_qnO%2Bm5VMV8Y0VSh6zQ%40mail.gmail.com.


Re: Slow page load performance with a large number of formsets (over 25)

2022-02-26 Thread Antonis Christofides

However, caching the queryset solves only part of the problem.

If you have a formset with 100 forms, and each of these forms has a choice field 
with 100 choices (say 50 bytes each), then you have altogether 10k choices or 
500k bytes of data. While, depending on the particular case, this may be 
manageable, it can get quickly out of hand if the forms become 200 or the 
choices become 200 or more etc.


A technical solution to that problem could be to retrieve the choices only once 
and have some JavaScript fill in the choices in the forms. But this departs from 
the Django formset paradigm and might require significant development.


The alternative I see would be to redesign the UI so that it doesn't need a 
formset (at least such a big formset). While I don't know the specifics of this 
particular case, I would hack my brains to see whether I can present this 
information in a more simple manner to the user (because 100 forms would be 
overwhelming I guess). Once I have a saner UI, the implementation details would 
follow naturally.


Antonis Christofides
+30-6979924665 (mobile)



On 26/02/2022 05.43, Jacob Greene wrote:
You would need to cache the queryset and pass it to each form instance that 
the formset creates. I've done this a few different ways in the past. I've 
never understood why there isn't a more straight forward way to do this. 
Here's a post with a few legit options depending on your use case:


https://stackoverflow.com/questions/8176200/caching-queryset-choices-for-modelchoicefield-or-modelmultiplechoicefield-in-a-d

Hard to be more specific without knowing anything about your code.

On Fri, Feb 25, 2022, 8:53 PM Steve Smith  wrote:

If in fact I am….how do I avoid this?  I have been playing with
alternatives for a week and I’m starting to lose it…lol

Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for Windows

*From: *Jacob Greene <mailto:jacobgreene1...@gmail.com>
*Sent: *Friday, February 25, 2022 5:58 PM
*To: *django-users@googlegroups.com
*Subject: *Re: Slow page load performance with a large number of formsets
(over 25)

If you're using model choice fields, it's very likely you are making an
SQL query for each form set. It should be pretty obvious in the log with
debug turned on.

On Fri, Feb 25, 2022, 4:31 PM Ryan Nowakowski  wrote:

Steven, are you using ModelFormSet?  If so, Is it the initial query
that's slow?  The form rendering?  Or is it the POST back to the server
that's slow?  You can use django-debug-toolbar[1] to profile your page
and get these metrics.

Once you figure out what part is slowest, then you can optimize.

Hope this helps!

Ryan N

[1] https://django-debug-toolbar.readthedocs.io/en/latest/

On Mon, Feb 07, 2022 at 09:12:48AM -0800, Steven Smith wrote:
> Did this issue ever get resolved?  I'm experiencing the same thing. 
Once
> it hits 100 forms or so it gets pretty slow.
>
> On Monday, September 22, 2014 at 10:48:52 AM UTC-5 Collin Anderson
wrote:
>
> > Yes, if you want speed, using javascript and ajax is probably your
best
> > bet. It will probably also reduce merge-conflicts.
> >

-- 
You received this message because you are subscribed to the Google

Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
<mailto:django-users%2bunsubscr...@googlegroups.com>.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/20220225222926.GH11627%40fattuba.com.

-- 
You received this message because you are subscribed to the Google Groups

"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/CAF-Y%3De5Fp7kDtLq47Z3Y4GEjXMne2PcTLYxOJ8St5gkKCkpUpw%40mail.gmail.com

<https://groups.google.com/d/msgid/django-users/CAF-Y%3De5Fp7kDtLq47Z3Y4GEjXMne2PcTLYxOJ8St5gkKCkpUpw%40mail.gmail.com?utm_medium=email_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups

"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/CH0PR18MB42923C9432F56E071FA9716CD23F9%40CH0PR18MB4292.namprd18.prod.outlook.com

<https://groups.google.com/d/msgid/django-users/CH0PR18MB42923C9432F56E071FA9716CD23F9%40CH0PR18MB4292.namprd18.p

Re: Slow page load performance with a large number of formsets (over 25)

2022-02-25 Thread Steve Smith
Thanks for the suggestion.  I really appreciate it.

Steve

From: django-users@googlegroups.com  on behalf 
of Jacob Greene 
Sent: Friday, February 25, 2022 9:43 PM
To: django-users@googlegroups.com 
Subject: Re: Slow page load performance with a large number of formsets (over 
25)

You would need to cache the queryset and pass it to each form instance that the 
formset creates. I've done this a few different ways in the past. I've never 
understood why there isn't a more straight forward way to do this. Here's a 
post with a few legit options depending on your use case:

https://stackoverflow.com/questions/8176200/caching-queryset-choices-for-modelchoicefield-or-modelmultiplechoicefield-in-a-d

Hard to be more specific without knowing anything about your code.

On Fri, Feb 25, 2022, 8:53 PM Steve Smith 
mailto:stevesmith0...@hotmail.com>> wrote:

If in fact I am….how do I avoid this?  I have been playing with alternatives 
for a week and I’m starting to lose it…lol



Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows



From: Jacob Greene<mailto:jacobgreene1...@gmail.com>
Sent: Friday, February 25, 2022 5:58 PM
To: django-users@googlegroups.com<mailto:django-users@googlegroups.com>
Subject: Re: Slow page load performance with a large number of formsets (over 
25)



If you're using model choice fields, it's very likely you are making an SQL 
query for each form set. It should be pretty obvious in the log with debug 
turned on.



On Fri, Feb 25, 2022, 4:31 PM Ryan Nowakowski 
mailto:tuba...@fattuba.com>> wrote:

Steven, are you using ModelFormSet?  If so, Is it the initial query
that's slow?  The form rendering?  Or is it the POST back to the server
that's slow?  You can use django-debug-toolbar[1] to profile your page
and get these metrics.

Once you figure out what part is slowest, then you can optimize.

Hope this helps!

Ryan N

[1] https://django-debug-toolbar.readthedocs.io/en/latest/

On Mon, Feb 07, 2022 at 09:12:48AM -0800, Steven Smith wrote:
> Did this issue ever get resolved?  I'm experiencing the same thing.  Once
> it hits 100 forms or so it gets pretty slow.
>
> On Monday, September 22, 2014 at 10:48:52 AM UTC-5 Collin Anderson wrote:
>
> > Yes, if you want speed, using javascript and ajax is probably your best
> > bet. It will probably also reduce merge-conflicts.
> >

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users%2bunsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20220225222926.GH11627%40fattuba.com.

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAF-Y%3De5Fp7kDtLq47Z3Y4GEjXMne2PcTLYxOJ8St5gkKCkpUpw%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAF-Y%3De5Fp7kDtLq47Z3Y4GEjXMne2PcTLYxOJ8St5gkKCkpUpw%40mail.gmail.com?utm_medium=email_source=footer>.



--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CH0PR18MB42923C9432F56E071FA9716CD23F9%40CH0PR18MB4292.namprd18.prod.outlook.com<https://groups.google.com/d/msgid/django-users/CH0PR18MB42923C9432F56E071FA9716CD23F9%40CH0PR18MB4292.namprd18.prod.outlook.com?utm_medium=email_source=footer>.

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAF-Y%3De4E3zFuzmK_UOf9exaEc5pM5FNun7xJXhn_yVbHyWqiWg%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAF-Y%3De4E3zFuzmK_UOf9exaEc5pM5FNun7xJXhn_yVbHyWqiWg%40mail.gmail.com?utm_medium=email_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CH0PR18MB429297C1C7D04F4094D10D8CD23F9%40CH0PR18MB4292.namprd18.prod.outlook.com.


Re: Slow page load performance with a large number of formsets (over 25)

2022-02-25 Thread Jacob Greene
You would need to cache the queryset and pass it to each form instance that
the formset creates. I've done this a few different ways in the past. I've
never understood why there isn't a more straight forward way to do this.
Here's a post with a few legit options depending on your use case:

https://stackoverflow.com/questions/8176200/caching-queryset-choices-for-modelchoicefield-or-modelmultiplechoicefield-in-a-d

Hard to be more specific without knowing anything about your code.

On Fri, Feb 25, 2022, 8:53 PM Steve Smith 
wrote:

> If in fact I am….how do I avoid this?  I have been playing with
> alternatives for a week and I’m starting to lose it…lol
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows
>
>
>
> *From: *Jacob Greene 
> *Sent: *Friday, February 25, 2022 5:58 PM
> *To: *django-users@googlegroups.com
> *Subject: *Re: Slow page load performance with a large number of formsets
> (over 25)
>
>
>
> If you're using model choice fields, it's very likely you are making an
> SQL query for each form set. It should be pretty obvious in the log with
> debug turned on.
>
>
>
> On Fri, Feb 25, 2022, 4:31 PM Ryan Nowakowski  wrote:
>
> Steven, are you using ModelFormSet?  If so, Is it the initial query
> that's slow?  The form rendering?  Or is it the POST back to the server
> that's slow?  You can use django-debug-toolbar[1] to profile your page
> and get these metrics.
>
> Once you figure out what part is slowest, then you can optimize.
>
> Hope this helps!
>
> Ryan N
>
> [1] https://django-debug-toolbar.readthedocs.io/en/latest/
>
> On Mon, Feb 07, 2022 at 09:12:48AM -0800, Steven Smith wrote:
> > Did this issue ever get resolved?  I'm experiencing the same thing.
> Once
> > it hits 100 forms or so it gets pretty slow.
> >
> > On Monday, September 22, 2014 at 10:48:52 AM UTC-5 Collin Anderson wrote:
> >
> > > Yes, if you want speed, using javascript and ajax is probably your
> best
> > > bet. It will probably also reduce merge-conflicts.
> > >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/20220225222926.GH11627%40fattuba.com
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAF-Y%3De5Fp7kDtLq47Z3Y4GEjXMne2PcTLYxOJ8St5gkKCkpUpw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAF-Y%3De5Fp7kDtLq47Z3Y4GEjXMne2PcTLYxOJ8St5gkKCkpUpw%40mail.gmail.com?utm_medium=email_source=footer>
> .
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CH0PR18MB42923C9432F56E071FA9716CD23F9%40CH0PR18MB4292.namprd18.prod.outlook.com
> <https://groups.google.com/d/msgid/django-users/CH0PR18MB42923C9432F56E071FA9716CD23F9%40CH0PR18MB4292.namprd18.prod.outlook.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAF-Y%3De4E3zFuzmK_UOf9exaEc5pM5FNun7xJXhn_yVbHyWqiWg%40mail.gmail.com.


RE: Slow page load performance with a large number of formsets (over 25)

2022-02-25 Thread Steve Smith
If in fact I am….how do I avoid this?  I have been playing with alternatives 
for a week and I’m starting to lose it…lol

Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows

From: Jacob Greene<mailto:jacobgreene1...@gmail.com>
Sent: Friday, February 25, 2022 5:58 PM
To: django-users@googlegroups.com<mailto:django-users@googlegroups.com>
Subject: Re: Slow page load performance with a large number of formsets (over 
25)

If you're using model choice fields, it's very likely you are making an SQL 
query for each form set. It should be pretty obvious in the log with debug 
turned on.

On Fri, Feb 25, 2022, 4:31 PM Ryan Nowakowski 
mailto:tuba...@fattuba.com>> wrote:
Steven, are you using ModelFormSet?  If so, Is it the initial query
that's slow?  The form rendering?  Or is it the POST back to the server
that's slow?  You can use django-debug-toolbar[1] to profile your page
and get these metrics.

Once you figure out what part is slowest, then you can optimize.

Hope this helps!

Ryan N

[1] https://django-debug-toolbar.readthedocs.io/en/latest/

On Mon, Feb 07, 2022 at 09:12:48AM -0800, Steven Smith wrote:
> Did this issue ever get resolved?  I'm experiencing the same thing.  Once
> it hits 100 forms or so it gets pretty slow.
>
> On Monday, September 22, 2014 at 10:48:52 AM UTC-5 Collin Anderson wrote:
>
> > Yes, if you want speed, using javascript and ajax is probably your best
> > bet. It will probably also reduce merge-conflicts.
> >

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users%2bunsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20220225222926.GH11627%40fattuba.com.
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAF-Y%3De5Fp7kDtLq47Z3Y4GEjXMne2PcTLYxOJ8St5gkKCkpUpw%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAF-Y%3De5Fp7kDtLq47Z3Y4GEjXMne2PcTLYxOJ8St5gkKCkpUpw%40mail.gmail.com?utm_medium=email_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CH0PR18MB42923C9432F56E071FA9716CD23F9%40CH0PR18MB4292.namprd18.prod.outlook.com.


Re: Slow page load performance with a large number of formsets (over 25)

2022-02-25 Thread Jacob Greene
If you're using model choice fields, it's very likely you are making an SQL
query for each form set. It should be pretty obvious in the log with debug
turned on.

On Fri, Feb 25, 2022, 4:31 PM Ryan Nowakowski  wrote:

> Steven, are you using ModelFormSet?  If so, Is it the initial query
> that's slow?  The form rendering?  Or is it the POST back to the server
> that's slow?  You can use django-debug-toolbar[1] to profile your page
> and get these metrics.
>
> Once you figure out what part is slowest, then you can optimize.
>
> Hope this helps!
>
> Ryan N
>
> [1] https://django-debug-toolbar.readthedocs.io/en/latest/
>
> On Mon, Feb 07, 2022 at 09:12:48AM -0800, Steven Smith wrote:
> > Did this issue ever get resolved?  I'm experiencing the same thing.
> Once
> > it hits 100 forms or so it gets pretty slow.
> >
> > On Monday, September 22, 2014 at 10:48:52 AM UTC-5 Collin Anderson wrote:
> >
> > > Yes, if you want speed, using javascript and ajax is probably your
> best
> > > bet. It will probably also reduce merge-conflicts.
> > >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/20220225222926.GH11627%40fattuba.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAF-Y%3De5Fp7kDtLq47Z3Y4GEjXMne2PcTLYxOJ8St5gkKCkpUpw%40mail.gmail.com.


Re: Slow page load performance with a large number of formsets (over 25)

2022-02-25 Thread Ryan Nowakowski
Steven, are you using ModelFormSet?  If so, Is it the initial query
that's slow?  The form rendering?  Or is it the POST back to the server
that's slow?  You can use django-debug-toolbar[1] to profile your page
and get these metrics.

Once you figure out what part is slowest, then you can optimize.

Hope this helps!

Ryan N

[1] https://django-debug-toolbar.readthedocs.io/en/latest/

On Mon, Feb 07, 2022 at 09:12:48AM -0800, Steven Smith wrote:
> Did this issue ever get resolved?  I'm experiencing the same thing.  Once 
> it hits 100 forms or so it gets pretty slow.
> 
> On Monday, September 22, 2014 at 10:48:52 AM UTC-5 Collin Anderson wrote:
> 
> > Yes, if you want speed, using javascript and ajax is probably your best 
> > bet. It will probably also reduce merge-conflicts.
> >

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20220225222926.GH11627%40fattuba.com.


Re: Formsets?!?!?!?!?!?!?!?!?!?

2022-02-12 Thread Antonis Christofides

Hello,


I have also seen some discussions about formsets recently. I think it's not as 
simple as that. I don't believe there's any rule that applies to all cases. Each 
case is probably different.



You say you have 100 rows with 12 fields each, and that it takes 19 seconds to 
render. Where are these 19 seconds spent? It could be that the data is fetched 
from the database instantly and that the 19 seconds are spent in order for some 
template to render. Or it could be that even this is done quite fast and that 
the resulting html is too complicated and the browser takes too long to render 
it. Or something else.



While I don't have much experience with formsets, I've made some pretty 
complicated stuff in the admin (which makes heavy use of formsets). I once had a 
database of scientific publications, and each publication could have an 
indefinite number of authors. If a publication had, say, 10 authors, then the 
author formset would repeat itself 10 times (plus two or three more empty ones 
for any additional you'd want to register). Each of these 12-13 formsets had an 
"author" dropdown field. There were hundreds of authors in the database, so each 
of the 12-13 dropdowns had hundreds of options. Imagine this:



  

    Antonis Christofides

    Steve Smith


    [... 300 more options here]


  


all this repeated 13 times. There wasn't that anything in there that was 
particularly slow, it was the sheer volume of information that made it slow. In 
that case the solution was obvious—I just needed to use the admin's 
raw_id_fields option.



So there's no generic way to diagnose the problem. You need to investigate. 
Start with the Django Debug Toolbar and check where this time is spent. Then try 
reducing the code gradually to arrive at a minimal example. When you have 
identified what causes the delay, you will be able either to solve it yourself 
or to ask us a more specific question. (Either way tell us what happened.)



Regards,


Antonis

Antonis Christofides
+30-6979924665 (mobile)



On 12/02/2022 07.38, Steve Smith wrote:

Hello all....

I have formsets workingbut I seem to be encountering some performance 
issues if I have more than 25 rows.  I've looked at my database 
callsselect_related...prefetch_related...and I've polled several 
audiences...SOFacebook Groupsand the consensus seems to be that 
Formsets are bad if you have a lot of rows.  I'm having trouble accepting that 
because if that was the case why do they exist?  And why is the default like 
1000 forms?  I really like the formset conceptbut I'm having a hard time 
accepting that if you have more than 25 rows it's just gonna be "slow".  And 
by slow I mean when I try to render the form using formsets and I have 100 
rows of data with like 12 fields each...it takes 19 seconds or so for the form 
to render. Does this sound like normal behavior?  I'm legitimately asking as I 
honestly don't know.


Thanks in advance for any thoughts or feedback.

Steve

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an 
email to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CH0PR18MB4292692992A37BD51AAEB0AFD2319%40CH0PR18MB4292.namprd18.prod.outlook.com 
<https://groups.google.com/d/msgid/django-users/CH0PR18MB4292692992A37BD51AAEB0AFD2319%40CH0PR18MB4292.namprd18.prod.outlook.com?utm_medium=email_source=footer>.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e70386b4-b00c-a1b6-7fc0-dd43df984cbb%40antonischristofides.com.


Formsets?!?!?!?!?!?!?!?!?!?

2022-02-11 Thread Steve Smith
Hello all

I have formsets workingbut I seem to be encountering some performance 
issues if I have more than 25 rows.  I've looked at my database 
callsselect_related...prefetch_related...and I've polled several 
audiences...SOFacebook Groupsand the consensus seems to be that 
Formsets are bad if you have a lot of rows.  I'm having trouble accepting that 
because if that was the case why do they exist?  And why is the default like 
1000 forms?  I really like the formset conceptbut I'm having a hard time 
accepting that if you have more than 25 rows it's just gonna be "slow".  And by 
slow I mean when I try to render the form using formsets and I have 100 rows of 
data with like 12 fields each...it takes 19 seconds or so for the form to 
render.  Does this sound like normal behavior?  I'm legitimately asking as I 
honestly don't know.

Thanks in advance for any thoughts or feedback.

Steve

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CH0PR18MB4292692992A37BD51AAEB0AFD2319%40CH0PR18MB4292.namprd18.prod.outlook.com.


Re: Slow page load performance with a large number of formsets (over 25)

2022-02-08 Thread Steven Smith

What is hard reload?
On Monday, February 7, 2022 at 12:43:08 PM UTC-6 abdouli...@gmail.com wrote:

> Try hard reload it's little bit faster
>
> On Mon, Feb 7, 2022, 18:12 Steven Smith  wrote:
>
>> Did this issue ever get resolved?  I'm experiencing the same thing.  Once 
>> it hits 100 forms or so it gets pretty slow.
>>
>> On Monday, September 22, 2014 at 10:48:52 AM UTC-5 Collin Anderson wrote:
>>
>>> Yes, if you want speed, using javascript and ajax is probably your best 
>>> bet. It will probably also reduce merge-conflicts.
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/48609393-cb83-4eea-845b-d353e41af1e7n%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/65b3ee86-64bb-4f64-894a-76fd62079097n%40googlegroups.com.


Re: Slow page load performance with a large number of formsets (over 25)

2022-02-07 Thread Abdulrahman Abbas
Try hard reload it's little bit faster

On Mon, Feb 7, 2022, 18:12 Steven Smith  wrote:

> Did this issue ever get resolved?  I'm experiencing the same thing.  Once
> it hits 100 forms or so it gets pretty slow.
>
> On Monday, September 22, 2014 at 10:48:52 AM UTC-5 Collin Anderson wrote:
>
>> Yes, if you want speed, using javascript and ajax is probably your best
>> bet. It will probably also reduce merge-conflicts.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/48609393-cb83-4eea-845b-d353e41af1e7n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGGqo0MmDhjk8apreK4j-ORyWM1SeGbjZR3AXGb%3DPPjSJF28hQ%40mail.gmail.com.


Re: Slow page load performance with a large number of formsets (over 25)

2022-02-07 Thread Steven Smith
Did this issue ever get resolved?  I'm experiencing the same thing.  Once 
it hits 100 forms or so it gets pretty slow.

On Monday, September 22, 2014 at 10:48:52 AM UTC-5 Collin Anderson wrote:

> Yes, if you want speed, using javascript and ajax is probably your best 
> bet. It will probably also reduce merge-conflicts.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/48609393-cb83-4eea-845b-d353e41af1e7n%40googlegroups.com.


Re: Formsets

2022-02-06 Thread Steve Smith
HI Steve!

Thanks for the reply.  I have tried select related and prefetch relatedbut 
didn't know about deferwill look into...my current formset scenario is 
440ish queries and it takes about 19 seconds to load.  Some have suggested 
Celery and RabbitMQ and other alternatives which I'm not familiar with.  I need 
to explore those things further.  I have used the debug toolbar as wellit 
shows me that there are lots of duplicate queries...but I'm unclear on how to 
go about fixing them...as the select related and prefetch hasn't seemed to help 
either.

I'm using class based views with formsets and just kind of at a loss right now 
as to if there is anything that can be done to speed up these queries.  I 
opened up a SO on the issue...and got some suggestions on how to go about 
improving my dictionary look up...but after trying some of those suggestions 
the performance issue remains.

Thanks again for taking the time to respond.

Steve

From: django-users@googlegroups.com  on behalf 
of Steven Mapes 
Sent: Sunday, February 6, 2022 11:47 AM
To: Django users 
Subject: Re: Formsets

For me using select_related, prefetch_related and defer generally soft the 
issues. If that's still too slow then, if possible, you could look at using 
caching the queryset(s) you need the values. Have you run debug toolbar on the 
page to check what queries are running?

On Saturday, 5 February 2022 at 20:27:10 UTC stevesm...@hotmail.com wrote:
Hello all!

I find formsets wildly useful...but very difficult to architect.  I have them 
working...But I am running into a commonly documented problem...They are slow 
as you build up the number of fields and queries.  Are there any general tips 
that can be used or share on how to improve this issue?  I have tried all of 
the commonly prescribed 
solutions...select_related...prefetch_related...etc...But nothing seems to help.

I realize that Queries take timebut I'm just trying to see if there is a 
way to streamline them a bit.  It seems to me that formsets use a lot of 
queries depending on the amount of data and that's the trade off.

Again thanks for any thoughts or comments.

Steve


--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6513c105-8151-4c7a-8fd2-e692d5c5dcb5n%40googlegroups.com<https://groups.google.com/d/msgid/django-users/6513c105-8151-4c7a-8fd2-e692d5c5dcb5n%40googlegroups.com?utm_medium=email_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CH0PR18MB42921F540CB239D4F5E250CCD22B9%40CH0PR18MB4292.namprd18.prod.outlook.com.


Re: Formsets

2022-02-06 Thread Steven Mapes
For me using select_related, prefetch_related and defer generally soft the 
issues. If that's still too slow then, if possible, you could look at using 
caching the queryset(s) you need the values. Have you run debug toolbar on 
the page to check what queries are running?

On Saturday, 5 February 2022 at 20:27:10 UTC stevesm...@hotmail.com wrote:

> Hello all!   
>
> I find formsets wildly useful...but very difficult to architect.  I have 
> them working...But I am running into a commonly documented problem...They 
> are slow as you build up the number of fields and queries.  Are there any 
> general tips that can be used or share on how to improve this issue?  I 
> have tried all of the commonly prescribed 
> solutions...select_related...prefetch_related...etc...But nothing seems to 
> help.  
>
> I realize that Queries take timebut I'm just trying to see if there is 
> a way to streamline them a bit.  It seems to me that formsets use a lot of 
> queries depending on the amount of data and that's the trade off. 
>
> Again thanks for any thoughts or comments.
>
> Steve
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6513c105-8151-4c7a-8fd2-e692d5c5dcb5n%40googlegroups.com.


Formsets

2022-02-05 Thread Steven Smith
Hello all!   

I find formsets wildly useful...but very difficult to architect.  I have 
them working...But I am running into a commonly documented problem...They 
are slow as you build up the number of fields and queries.  Are there any 
general tips that can be used or share on how to improve this issue?  I 
have tried all of the commonly prescribed 
solutions...select_related...prefetch_related...etc...But nothing seems to 
help.  

I realize that Queries take timebut I'm just trying to see if there is 
a way to streamline them a bit.  It seems to me that formsets use a lot of 
queries depending on the amount of data and that's the trade off. 

Again thanks for any thoughts or comments.

Steve

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/178a8ba4-e00c-44ac-ad29-b1b39bdea54fn%40googlegroups.com.


Specifying the value format for a DateTimeInput using type=datetime-local, especially when using inline formsets

2022-01-22 Thread bnmng
I think I found a fix to a bug that I don't know was affecting anyone other 
than me.

You can see a better formatted version of what I've typed below at 
https://bnmng.wordpress.com/2022/01/22/make-sure-the-widget-is-correct-in-a-django-inline-model-formset/

TL;DR: For a DateTimeInput widget where type=’datetime-local’, specify the 
default format to include the T in the middle of the date-time string:
widgets={ 'when':forms.DateTimeInput( format='%Y-%m-%dT%H:%M:%S', 
attrs={'type':'datetime-local'} ), ... } 

This was driving me crazy!

I had a model inline formset using a form:

forms.py:
TicketNoteFormset = inlineformset_factory(Ticket, TicketNote, 
form=TicketNoteForm, extra=10) 

The specified form (TicketNoteForm) had a widget specified for a DateTime 
field:

forms.py:
class TicketTicketNoteForm(forms.ModelForm): class Meta: model = TicketNote 
fields = [ 'when', 'text', ] widgets={ 
'when':forms.DateInput(attrs={'type':'date'}), 
'text':forms.TextInput(attrs={'class':'len100'}) } 

My mistake was using DateInput for the field ‘when’, which was a 
DateTimeField, not a DateField
models.py:
class TicketNote(models.Model): when = models.DateTimeField( 'when', 
default=datetime.now, help_text='The date that the note was submitted' ) 

In the HTML forms, the initial value, as expected, was a date-time value 
but the value attribute of the field was a date value without the time
  

The difference between initial and non-initial caused a record to be 
created even if the form was blank

*But it was still broken after I fixed it*

Leaving out the widget declaration works, but then I just get a plain text 
field and I want to take advantage of the browser’s popup calendar 

I thought I had the problem fixed by specifying the widget as 

forms.py:
DateTimeInput(attrs={'type':'datetime-local 
'}),
 


but that’s still giving me some problems. It worked fine in Firefox, but 
Chrome ignored the value attribute. So in Chrome
 

displays a blank datetime input and submits an empty string if not updated 

I’ll update if I find a good solution.

Update: This works in Firefox and Chrome:
forms.py:
widgets={ 'when':forms.DateTimeInput( format='%Y-%m-%dT%H:%M:%S', 
attrs={'type':'datetime-local'} ), ... } 

What Chrome was rejecting was having the value specified without the T 
between the date portion and the time portion. Django was producing the 
value without the T. By adding the format argument, I was able to make 
Django produce a default value that Chrome accepts. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d4b3bb1f-d296-4928-9e69-a0774acc5886n%40googlegroups.com.


Re: How to avoid select lists on formsets and ManyToMany?

2021-04-01 Thread Ryan Nowakowski
Django admin does something like this with raw_id_fields[1]. I think it works 
by just swapping out the form widget. But you could take a look at the admin 
code to see for sure.

[1] 
https://docs.djangoproject.com/en/3.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields

On April 1, 2021 10:23:03 PM CDT, Clive Bruton  wrote:
>I have a ManyToMany model set, that on the edit uses a formset to add/ 
>edit rows. I have this working, but the unfortunate part of it is  
>that the select that results from the ManyToMany relationship  
>populates with 16,000 records.
>
>What I would like to do is, once the records are added, just have the  
>delete checkbox and show the 'description' field (uneditable) next to  
>it), and, rather than add records through a huge select list, add the  
>records by id.
>
>To sketch it out, this is how it is:
>
>
> <'Profile.directory-optin' checkbox>
>
> <'Profile.directory-desc'>
>
> <'Class.description' huge select>
>
> 
>
> 
>
> <'Class.description' huge select>
>
> 
>
> 
>
> <'Class.description' huge select>
>
> 
>
> 
>
> 
>
> <'Class.description' huge select>
>
> 
>
> 
>
> 
>
>
>
>And I'd rather it was something like:
>
>
> <'Profile.directory-optin' checkbox>
>
> <'Profile.directory-desc'>
>
>  
>
> 
>
>  
>
> 
>
>  
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
>
>The database tables look something like:
>
>
>Profile  Join table   Class
>===  ==   =
>
>id   id   id
>directory-optin  profile-id   description
>directory-desc   class-id
>
>
>
>Hope someone can help me out!
>
>
>-- Clive
>
>-- 
>You received this message because you are subscribed to the Google
>Groups "Django users" group.
>To unsubscribe from this group and stop receiving emails from it, send
>an email to django-users+unsubscr...@googlegroups.com.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/django-users/E30F44E6-07DA-4703-BAB1-BE295C72EF22%40indx.co.uk.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/75F0A15E-150A-4F74-BC98-2AE067B843AB%40fattuba.com.


How to avoid select lists on formsets and ManyToMany?

2021-04-01 Thread Clive Bruton
I have a ManyToMany model set, that on the edit uses a formset to add/ 
edit rows. I have this working, but the unfortunate part of it is  
that the select that results from the ManyToMany relationship  
populates with 16,000 records.


What I would like to do is, once the records are added, just have the  
delete checkbox and show the 'description' field (uneditable) next to  
it), and, rather than add records through a huge select list, add the  
records by id.


To sketch it out, this is how it is:


<'Profile.directory-optin' checkbox>

<'Profile.directory-desc'>

<'Class.description' huge select>





<'Class.description' huge select>





<'Class.description' huge select>







<'Class.description' huge select>









And I'd rather it was something like:


<'Profile.directory-optin' checkbox>

<'Profile.directory-desc'>

 



 



 














The database tables look something like:


Profile  Join table   Class
===  ==   =

id   id   id
directory-optin  profile-id   description
directory-desc   class-id



Hope someone can help me out!


-- Clive

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/E30F44E6-07DA-4703-BAB1-BE295C72EF22%40indx.co.uk.


Re: Serializing forms and formsets to pass to Celery task

2020-02-29 Thread Integr@te System
Hi Bernd,

You could take a look at serializers section on Note part, for more
information, and may be your own answer.

http://docs.celeryproject.org/en/master/userguide/calling.html#calling-serializers





On Sat, Feb 29, 2020, 23:56 Naveen Arora  wrote:

> Yes that would work well. You can always find a completely different way
> of achieving what you are trying to achieve.
>
> On Saturday, 29 February 2020 18:52:24 UTC+5:30, Jason wrote:
>>
>> As said before, you really can't do that too well with celery.  Its a
>> good practice to keep the message body between django -> broker -> worker
>> to be as small as possible because we don't know what your configuration
>> for the broker is.  In addition, you should never, ever, put sensitive
>> information in a message, just the identifier of a thing and let
>> celery/django pull from a data store when the task starts.
>>
>> what I would do is save the form data to some intermediate data store,
>> and pass in the identifier to the celery task for retrieval.  That ensures
>> your data integrity and security is high.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3f1b4374-ca68-4fcd-a33a-555bc72cbae8%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP5HUWoh-tyPwwZviSpzu85G_eawSRkhnuDp5AzgkbW5zeogxg%40mail.gmail.com.


Re: Serializing forms and formsets to pass to Celery task

2020-02-29 Thread Naveen Arora
Yes that would work well. You can always find a completely different way of 
achieving what you are trying to achieve.

On Saturday, 29 February 2020 18:52:24 UTC+5:30, Jason wrote:
>
> As said before, you really can't do that too well with celery.  Its a good 
> practice to keep the message body between django -> broker -> worker to be 
> as small as possible because we don't know what your configuration for the 
> broker is.  In addition, you should never, ever, put sensitive information 
> in a message, just the identifier of a thing and let celery/django pull 
> from a data store when the task starts.
>
> what I would do is save the form data to some intermediate data store, and 
> pass in the identifier to the celery task for retrieval.  That ensures your 
> data integrity and security is high.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3f1b4374-ca68-4fcd-a33a-555bc72cbae8%40googlegroups.com.


Re: Serializing forms and formsets to pass to Celery task

2020-02-29 Thread Jason
As said before, you really can't do that too well with celery.  Its a good 
practice to keep the message body between django -> broker -> worker to be 
as small as possible because we don't know what your configuration for the 
broker is.  In addition, you should never, ever, put sensitive information 
in a message, just the identifier of a thing and let celery/django pull 
from a data store when the task starts.

what I would do is save the form data to some intermediate data store, and 
pass in the identifier to the celery task for retrieval.  That ensures your 
data integrity and security is high.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b5cc2ff0-a4f4-4522-a562-770d392a60a9%40googlegroups.com.


Re: Serializing forms and formsets to pass to Celery task

2020-02-28 Thread Naveen Arora
Hi Bernd,

You can't serialize a form data object this way.
All the solution i can see is to save data temporarily and use it.

Cheers,

On Friday, 28 February 2020 14:58:50 UTC+5:30, Bernd Wechner wrote:
>
> I'm using Celery quite effectively with Django as many are. It's just 
> awesome for running time consuming background tasks, and providing progress 
> bar updates to a web page. Love it.
>
> Now I would like a celery task to do some form processing. That is in a 
> Django view, where I have access to the form (or formset) that's just been 
> submitted, with all its data (in form.request.POST) and methods (like 
> form.save() which saves it to the database as a Django object or objects 
> (in the case of a formset). 
>
> Of course anything we pass to a Celery task must be serialized (as it's 
> passed through the broker) and there is plenty of help around on 
> serializing Django data objects but I can't find diddly squat on serialzing 
> forms and every effort I've tried, JSON, pickle, dill, all fails.
>
> I can serialize the POST data of course, and that great but I can't see 
> how the Celery task can then re-instantiate a form object from that.
>
> I posted this on stackoverflow as well with some richer detail: 
> https://stackoverflow.com/questions/60433090/processing-a-django-form-in-a-celery-task-how-can-the-celery-task-see-the-form
>
> I wonder if anyone has any experience to share here. Essentially I see two 
> possible solutions:
>
>1. Serialize the form or formsets somehow. Anything better than dill 
>out there that might?
>2. Serialize some part of the form or formsets (eg the POST data) and 
>re-instantiate a form or formset at the other end using it. 
>
> Either approach would work, 1. would seem less hassle if it has a 
> solution, and 2. seems more likely to provide one to me right now.
>
> Kind regards,
>
> Bernd.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7ea98dbe-ba20-4b74-bc0f-40f6babe52e1%40googlegroups.com.


Serializing forms and formsets to pass to Celery task

2020-02-28 Thread Bernd Wechner
I'm using Celery quite effectively with Django as many are. It's just 
awesome for running time consuming background tasks, and providing progress 
bar updates to a web page. Love it.

Now I would like a celery task to do some form processing. That is in a 
Django view, where I have access to the form (or formset) that's just been 
submitted, with all its data (in form.request.POST) and methods (like 
form.save() which saves it to the database as a Django object or objects 
(in the case of a formset). 

Of course anything we pass to a Celery task must be serialized (as it's 
passed through the broker) and there is plenty of help around on 
serializing Django data objects but I can't find diddly squat on serialzing 
forms and every effort I've tried, JSON, pickle, dill, all fails.

I can serialize the POST data of course, and that great but I can't see how 
the Celery task can then re-instantiate a form object from that.

I posted this on stackoverflow as well with some richer detail: 
https://stackoverflow.com/questions/60433090/processing-a-django-form-in-a-celery-task-how-can-the-celery-task-see-the-form

I wonder if anyone has any experience to share here. Essentially I see two 
possible solutions:

   1. Serialize the form or formsets somehow. Anything better than dill out 
   there that might?
   2. Serialize some part of the form or formsets (eg the POST data) and 
   re-instantiate a form or formset at the other end using it. 
   
Either approach would work, 1. would seem less hassle if it has a solution, 
and 2. seems more likely to provide one to me right now.

Kind regards,

Bernd.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20830f05-bd64-40a5-b096-d7e00cb00271%40googlegroups.com.


Testing the validity of a form which has inline formsets from a View subclass

2019-09-03 Thread Shaheed Haque
Hi all,

I have a set of views in a superclass/subclass hierarchy like this:

   - mobile_view is a subclass of
   - generic___view is a subclass of
   - django-extra-views formset support view

As expected, the django-extra-views formset support's "post()" logic does a
"if form.is_valid() then form.save(commit=False)", and then proceeds to
save the contents of the formsets after testing them with formset
"is_valid" logic, before returning an HttpResponse. AFAICS, no exceptions
are raised to signal the error.

Let's say I now want to do some additional work in generic_object_view,
based on whether the superclass had an error or not:

   - I could construct the form again, and the formsets again, and
   basically redo what the superclass did
   - And of course, it would need redoing again one layer up in
   "mobile_view".

Or have I missed something I can test in the view itself (i.e.
self.) or the return HTTPResponse?

Thanks, Shaheed

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHAc2jd842he83j77xP4phU4-CfyiqvNWhQ3T2wd2yWoGFuNJA%40mail.gmail.com.


Re: Multiple formsets and when posting associating them with an instance

2018-08-21 Thread David
Changing all modelformset factories to inlineformsets and then specifying 
an instance on both the post and get methods resolved this issue.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8f38004e-fe59-4d9d-b772-88c3b64886a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Multiple formsets and when posting associating them with an instance

2018-08-21 Thread David
Hi

I don't know if this is a common question, but I couldn't find anything 
resembling my problem.

I have a page called "Case". On this page some basic information is added 
along with the creation of 1 or 2 clients (fixed) Client's are FK to the 
Case model. These are added using inlineformset factory.

On the subsequent page, and the one with the problem, I need to query my 
Client model to see how many clients are associated with the Case. That 
determines how many formsets I should show. ie. 1 for 1 client, or 2 for 2 
clients.

I chose to use modelformset factory, instead of inline as I don't know how 
many clients exist.

Each formset is designed to associate family relatives to each client and 
are therefor FK'd to the Client. eg: Parent model contains FK to Client.

My very rudamentary code below achieves this, however my modelformset 
factories that I am using to generate the forms don't respect the 
"unique_together" constraint. I suspect this is because I am not passing an 
instance to the formset on post. But because for the sake of argument 
"Parent" instance may not exist and instead is being POST'd to create, I 
cannot specify an instance.


@login_required
def create_new_family(request, case_pk):
case = Case.objects.get(pk=case_pk)
clients = Client.objects.filter(case=case_pk)[:2]
formset = {}

for client in clients:
formset[client.pk] = {}
formset[client.pk] = {}

if request.method == 'POST':

for client in clients:
formset[client.pk]['parents'] = ParentsFormset(request.POST, prefix=
'parents_' + str(client.pk),)
formset[client.pk]['siblings'] = SiblingsFormset(request.POST, prefix=
'siblings_' + str(client.pk))
formset[client.pk]['children'] = ChildrenFormset(request.POST, prefix=
'children_' + str(client.pk))
formset[client.pk]['stepchildren'] = StepChildrenFormset(request.POST, 
prefix='stepchildren_' + str(client.pk))

err = 0
for client_id, fs_dict in formset.items():
if not all(form.is_valid() for fs_type, form in fs_dict.items()):
err = err + 1

if err == 0:
for client_id, fs_dict in formset.items(): # a is client_id ## b is formset 
dict
if all(form.is_valid() for fs_type, form in fs_dict.items()):
for idx, fs in fs_dict.items(): # at this point all fs are formset instances
if fs.is_valid():
instances = fs.save(commit=False)
for instance in instances:
instance.client = Client.objects.get(pk=client_id)
instance.save()

return HttpResponseRedirect(reverse('family-create', kwargs={'case_pk': 
case_pk}))
else:
for client in clients:
formset[client.pk]['parents'] = ParentsFormset(prefix='parents_' + 
str(client.pk),
queryset=Parent.objects.filter(client=client))
formset[client.pk]['siblings'] = SiblingsFormset(prefix='siblings_' + 
str(client.pk),
queryset=Sibling.objects.filter(client=client))
formset[client.pk]['children'] = ChildrenFormset(prefix='children_' + 
str(client.pk),
queryset=Children.objects.filter(client=client))
formset[client.pk]['stepchildren'] = StepChildrenFormset(prefix=
'stepchildren_' + str(client.pk),
queryset=StepChildren.objects.filter(client=client))

return render(request, 'clients/client_form.html', {
'formsets': formset,
'clients': clients,
'case': case,
'breadcrumbs': 'Family & Dependants'
})


I appreciate this might be difficult to comprehend, as it is for me to 
explain.

Any help would be much appreciated.

Thank you 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/17499d8a-c18f-4a68-9173-216a08649871%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Updating TimeField in forms/formsets returns value without microseconds

2018-03-26 Thread Tim Graham
You need to set support_microseconds=True on the widget.
https://docs.djangoproject.com/en/stable/ref/forms/widgets/#django.forms.Widget.supports_microseconds

On Sunday, March 25, 2018 at 9:03:18 AM UTC-4, Rafał Szymczuk wrote:
>
> I have problem with updating TimeField in my models - when I want to edit 
> objects using forms/formsets the input field on my site is always cutting 
> microseconds.
> I made ex. class with TimeField:
>
> class Participant(models.Model):
> surname = models.CharField(max_length = 256)
> name = models.CharField(max_length = 256)
> birth = models.DateField(blank = True, null = True)
> entry_time = models.TimeField(blank = True, null = True)
>   ...
>
> Then I made a form:
>
> class ParticipantForm(forms.ModelForm):
>
>entry_time = forms.TimeField(initial="HH:MM:SS.00", 
>required = False, 
>widget=forms.TimeInput(format=('%H:%M:%S.%f')))
>
>
> When I am adding new Participant via my form everything is OK. Value of 
> entry_time is saving in my database (SQLite) with properly 
> format(hours:minutes:seconds.microseconds). But there is a problem when I 
> want to update my participants using this form or formsets. Data loaded to 
> form is always without microseconds (hours:minutes:seconds).
>
> The output on my site looks like this:
>
> [image: 
> https://lh3.googleusercontent.com/-FKuX_loplIU/WreCImNW33I/LoM/6MA-z2LnD6MIhknumZNZTYOK5iif1KdbwCLcBGAs/s1600/timeformat.PNG]
>  
> <https://lh3.googleusercontent.com/-FKuX_loplIU/WreCImNW33I/LoM/6MA-z2LnD6MIhknumZNZTYOK5iif1KdbwCLcBGAs/s1600/timeformat.PNG>
>
> first generated by: {{ formset.time_score }} 
> second:  }}">
>
> It doesn't metter if I use form or formset - results are the same.
>
> Hope for your help guys, i can't figure it out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c29adb01-f40d-47ff-8ad4-8dba369e7c9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Updating TimeField in forms/formsets returns value without microseconds

2018-03-25 Thread Rafał Szymczuk
I have problem with updating TimeField in my models - when I want to edit 
objects using forms/formsets the input field on my site is always cutting 
microseconds.
I made ex. class with TimeField:

class Participant(models.Model):
surname = models.CharField(max_length = 256)
name = models.CharField(max_length = 256)
birth = models.DateField(blank = True, null = True)
entry_time = models.TimeField(blank = True, null = True)
  ...

Then I made a form:

class ParticipantForm(forms.ModelForm):
   
   entry_time = forms.TimeField(initial="HH:MM:SS.00", 
   required = False, 
   widget=forms.TimeInput(format=('%H:%M:%S.%f')))
   

When I am adding new Participant via my form everything is OK. Value of 
entry_time is saving in my database (SQLite) with properly 
format(hours:minutes:seconds.microseconds). But there is a problem when I 
want to update my participants using this form or formsets. Data loaded to 
form is always without microseconds (hours:minutes:seconds).

The output on my site looks like this:

[image: 
https://lh3.googleusercontent.com/-FKuX_loplIU/WreCImNW33I/LoM/6MA-z2LnD6MIhknumZNZTYOK5iif1KdbwCLcBGAs/s1600/timeformat.PNG]
 
<https://lh3.googleusercontent.com/-FKuX_loplIU/WreCImNW33I/LoM/6MA-z2LnD6MIhknumZNZTYOK5iif1KdbwCLcBGAs/s1600/timeformat.PNG>

first generated by: {{ formset.time_score }} 
second: 

It doesn't metter if I use form or formset - results are the same.

Hope for your help guys, i can't figure it out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d2e27fec-3f2f-4f97-9981-bcf475104a04%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Unable to save forms to the database for inline formsets using form wizard

2017-12-02 Thread Vishal Vincent


I am currently working on building a survey. The parent model 'Person' is 
linked to a 'Question' model via ManytoMany relationship. Both Question and 
Person model are linked to an 'Answer' model via foreign key.


Currently, I am having issues using the Form Wizard which consists of two 
steps: First step is the Person form and the second step is the form 
consisting of an inline formset linking the Person and Answer model.


On saving the forms to the database in the 'done' function of the wizard, I 
seem to be getting the error "*save() prohibited to prevent data loss due 
to unsaved related object 'person*."


I guess this error is due to the foreign key relationship between Person 
and Answer models but I am unclear on how to implement this in the 
WizardView.


Thanks in advance for any help provided.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b9d2fa4d-73e0-4372-8da6-fdc6f87870cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problm using FileField with inline formsets (inlineformset_factory)

2017-10-05 Thread YusufSalahAdDin
You saved my ass, thanks!!!

El miércoles, 10 de septiembre de 2008, 13:46:20 (UTC+4), Daniel Roseman 
escribió:
>
> On Sep 10, 9:50 am, "c.poll...@bangor.ac.uk" <c.poll...@bangor.ac.uk> 
> wrote: 
> > Hi 
> > 
> > I'm having a problem with inline formsets containing file field, i've 
> > had a good google but couldn't find an answer, so apolgies if this is 
> > a stupid or repetative question. 
> > 
> > I have a model Applicatant, which has a one to many relation with 
> > Education which contains a filefeild. My problem is that when django 
> > comes to validate the inline form education it reports that the field 
> > is empty, if i tell the model to allow empty feilds then the file is 
> > not saved 
> > 
> > Is it possible to use file fields with the inlineformset_factory or do 
> > i need to go at this another way? 
> > 
> > I have included my code, pretty simple and pretty much copied from the 
> > documentation: 
> > 
> > def myview(request): 
> > InlineFormSet = inlineformset_factory(Applicant, Education) 
> > applicant = Applicant.objects.get(pk=1) 
> > if request.method == 'POST': 
> > formset = InlineFormSet(request.POST, request.FILES, 
> > instance=applicant) 
> > if formset.is_valid(): 
> >Do stuff 
> >else: 
> >formset = InlineFormSet(instance=applicant) 
> > 
> >return render_to_response("mytemplate.html", { "formset": 
> > formset,}) 
> > 
> > where mytemplate.html is simply 
> > 
> >  
> > 
> > {{ formset.management_form }} 
> >  
> > {% for form in formset.forms %} 
> > {{ form.as_ul }} 
> > {% endfor %} 
> >  
> > 
> >  
> >  
> > 
> > Many than ks 
> > Charlotte 
>
>
> The problem isn't with Formsets, it's just that you haven't set your 
> enctype in the HTML form element. It should be: 
>  
>
> See 
> http://docs.djangoproject.com/en/dev/ref/forms/api/#binding-uploaded-files-to-a-form
>  
> -- 
> DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/87f723fa-9938-4472-b53e-a03111f0c946%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Hidden fields in formsets

2015-03-31 Thread aRkadeFR

Hello,

I read very quickly, but you sure you want to *render* and get the value
of "user_create" from the client?
It can be modified by any client...

aRkadeFR

On 03/31/2015 10:45 AM, François GUÉRIN wrote:

Hi,

I'm using multiple formsets in Create / Update views, and I want to 
set some *hidden* fields in it : user_create, date_create on creation, 
user_update, date_update on update.


I've created a MultiFormsetMixin, which provide machinery to 
initialize those formsets in my CreateView / UpdateView.
Basicaly, the mixin fill a formset_list containing dicts with 
{'formset': , 'name': , 'verbose_name': 
}... The rendering of the formsets uses the same 
rendering than 'normal' formsets, via a {%for formset in formset_list 
%}{# formset rendering #}[% endfor %}. The formsets display normaly.


Data initialization is performed through the 'initial' dict. Every 
forms in the formsets have the same values for those fields, at 
initialization, so I update each form of the formsets with those values.


My problem is that those hidden fields are not rendered in the 
template, even in a 'hidden_field'. I've tryed to set 'exclude' and 
'hidden_fields' Meta option in my ModelForm object, but it doesn't work.


When I go through the 'form.hidden_fields' I have my formset 
administrative normal data (id, parent) but not my fields.


Is it possible to render those fields in the template ?

Thanks !

--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com 
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com 
<mailto:django-users@googlegroups.com>.

Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/13de9082-3dd5-4b3c-bb72-7393e3f0884c%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/13de9082-3dd5-4b3c-bb72-7393e3f0884c%40googlegroups.com?utm_medium=email_source=footer>.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/551ACE9D.3050008%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Hidden fields in formsets

2015-03-31 Thread François GUÉRIN
Hi, 

I'm using multiple formsets in Create / Update views, and I want to set 
some *hidden* fields in it : user_create, date_create on creation, 
user_update, date_update on update.

I've created a MultiFormsetMixin, which provide machinery to initialize 
those formsets in my CreateView / UpdateView. 
Basicaly, the mixin fill a formset_list containing dicts with {'formset': 
, 'name': , 'verbose_name': }... The rendering of the formsets uses the same rendering than 
'normal' formsets, via a {%for formset in formset_list %}{# formset 
rendering #}[% endfor %}. The formsets display normaly.

Data initialization is performed through the 'initial' dict. Every forms in 
the formsets have the same values for those fields, at initialization, so I 
update each form of the formsets with those values.

My problem is that those hidden fields are not rendered in the template, 
even in a 'hidden_field'. I've tryed to set 'exclude' and 'hidden_fields' 
Meta option in my ModelForm object, but it doesn't work.

When I go through the 'form.hidden_fields' I have my formset administrative 
normal data (id, parent) but not my fields.

Is it possible to render those fields in the template ?

Thanks !

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/13de9082-3dd5-4b3c-bb72-7393e3f0884c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Struggling with formsets

2015-02-19 Thread Werner Brand
Thanks for the reponse!  My template looks like this:


{{ formset.management_form }}

{{ formset }}

{% csrf_token %}

 

Here is the print request.POST:

form-1-salaryform-MAX_NUM_FORMSform-0-surnameform-0-nameform-TOTAL_FORMSform-MIN_NUM_FORMSform-0-idform-1-nameform-INITIAL_FORMScsrfmiddlewaretokenform-0-salaryform-1-idform-1-surname

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/74e6d086-5ec7-41f2-be04-edcf4f6d8aaa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Struggling with formsets

2015-02-19 Thread aRkadeFR

Hello,

Can we have the template?

Did you rendered the hidden fields id of your forms ?

Dump (by printing) the request.POST informations to see
if you received any "id" :)



On 02/19/2015 04:25 PM, Werner Brand wrote:
I cannot seem to figure this, although I suspects it is really 
elementary:


I have two models:

class Employee(models.Model):

id_number = models.CharField(max_length=13)

surname = models.CharField(max_length=100)

name =  models.CharField(max_length=100)


class Payslip(models.Model):

surname = models.CharField(max_length=100)
name =  models.CharField(max_length=100)

salary = models.DecimalField(max_digits=20, decimal_places=2)


In my forms:

class PayslipForm(ModelForm):

class Meta:

model = Payslip

fields = ['surname', 'name', 'salary']


PayslipFormSet = modelformset_factory(Payslip, extra=0)


In views.py:

def Payslip(request):

employee = Employee.objects.all()

formset = PayslipFormSet(queryset=employee)

context = {'formset': formset}

return render(request, 'file.html', context)


def PayslipSubmit(request):

f = PayslipFormSet(request.POST)

if f.is_valid():

f.save()

return HttpResponse('Submitted')

else:

return HttpResponse(f.errors)


The problem is that when I submit I get the following each form in 
formset:


  * id
  o Select a valid choice. That choice is not one of the available
choices.

I hope someone can help!

--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com 
.
To post to this group, send email to django-users@googlegroups.com 
.

Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8c766350-f426-475c-aac5-15f42952ce00%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54E61AC4.8040504%40arkade.info.
For more options, visit https://groups.google.com/d/optout.


Struggling with formsets

2015-02-19 Thread Werner Brand
I cannot seem to figure this, although I suspects it is really elementary:

I have two models:

class Employee(models.Model):

id_number = models.CharField(max_length=13)

surname = models.CharField(max_length=100)

name =  models.CharField(max_length=100)


class Payslip(models.Model):

surname = models.CharField(max_length=100)
name =  models.CharField(max_length=100)

salary = models.DecimalField(max_digits=20, decimal_places=2)


In my forms:

class PayslipForm(ModelForm):

class Meta:

model = Payslip

fields = ['surname', 'name', 'salary']


PayslipFormSet = modelformset_factory(Payslip, extra=0)


In views.py:

def Payslip(request):

employee = Employee.objects.all()

formset = PayslipFormSet(queryset=employee)

context = {'formset': formset}

return render(request, 'file.html', context)


def PayslipSubmit(request):

f = PayslipFormSet(request.POST)

if f.is_valid():

f.save()

return HttpResponse('Submitted')

else:

return HttpResponse(f.errors) 


The problem is that when I submit I get the following each form in formset:

   - id
  - Select a valid choice. That choice is not one of the available 
  choices.
   
I hope someone can help!
 

 

 

 

 

 

 

 

 

 

 

 

 

 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8c766350-f426-475c-aac5-15f42952ce00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Class-Based CreateView and UpdateView with multiple inline formsets

2015-01-10 Thread Edgar Gabaldi
Use the django-extra-views[1]. You can easily manage multiple inline
formsets with CreateViews and UpdateViews.

[1] https://github.com/AndrewIngram/django-extra-views

On Sat, Jan 10, 2015 at 11:23 AM, Dan Gentry <d...@gentryville.net> wrote:

> I would suggest that in the UpdateView you should set the object to the
> master record being updated rather than to none for both get() and post().
>
>
> On Saturday, January 10, 2015 at 8:08:47 AM UTC-5, Ranjith Kumar wrote:
>>
>> Hello all,
>> I have been trying to do Django class-based CreateView and UpdateView
>> with multiple inline formsets
>>
>> CreateView works fine but UpdateView is not working properly, If anyone
>> tried UpdateView with multiple inline formsets, please point me right
>> approach.
>>
>> *models.py*
>> from django.db import models
>>
>> class Recipe(models.Model):
>> title = models.CharField(max_length=255)
>> description = models.TextField()
>>
>> class Ingredient(models.Model):
>> recipe = models.ForeignKey(Recipe)
>> description = models.CharField(max_length=255)
>>
>> class Instruction(models.Model):
>> recipe = models.ForeignKey(Recipe)
>> number = models.PositiveSmallIntegerField()
>> description = models.TextField()
>>
>> *forms.py*
>> from django.forms import ModelForm
>> from django.forms.models import inlineformset_factory
>> from .models import Recipe, Ingredient, Instruction
>>
>> class RecipeForm(ModelForm):
>> class Meta:
>> model = Recipe
>>
>> IngredientFormSet = inlineformset_factory(Recipe, Ingredient, extra=0)
>> InstructionFormSet = inlineformset_factory(Recipe, Instruction, extra=0)
>>
>> *views.py*
>> from django.http import HttpResponseRedirect
>> from django.views.generic.edit import CreateView, UpdateView
>> from django.shortcuts import get_object_or_404
>>
>> from .forms import IngredientFormSet, InstructionFormSet, RecipeForm
>> from .models import Recipe
>>
>> class RecipeCreateView(CreateView):
>> template_name = 'recipe_add.html'
>> model = Recipe
>> form_class = RecipeForm
>> success_url = '/account/dashboard/'
>>
>> def get(self, request, *args, **kwargs):
>> self.object = None
>> form_class = self.get_form_class()
>> form = self.get_form(form_class)
>> ingredient_form = IngredientFormSet()
>> instruction_form = InstructionFormSet()
>> return self.render_to_response(
>> self.get_context_data(form=form,
>>   ingredient_form=ingredient_form,
>>   instruction_form=instruction_form))
>>
>> def post(self, request, *args, **kwargs):
>> self.object = None
>> form_class = self.get_form_class()
>> form = self.get_form(form_class)
>> ingredient_form = IngredientFormSet(self.request.POST)
>> instruction_form = InstructionFormSet(self.request.POST)
>> if (form.is_valid() and ingredient_form.is_valid() and
>> instruction_form.is_valid()):
>> return self.form_valid(form, ingredient_form,
>> instruction_form)
>> else:
>> return self.form_invalid(form, ingredient_form,
>> instruction_form)
>>
>> def form_valid(self, form, ingredient_form, instruction_form):
>> self.object = form.save()
>> ingredient_form.instance = self.object
>> ingredient_form.save()
>> instruction_form.instance = self.object
>> instruction_form.save()
>> return HttpResponseRedirect(self.get_success_url())
>>
>> def form_invalid(self, form, ingredient_form, instruction_form):
>> return self.render_to_response(
>> self.get_context_data(form=form,
>>   ingredient_form=ingredient_form,
>>   instruction_form=instruction_form))
>>
>> class RecipeUpdateView(UpdateView):
>> template_name = 'recipe_add.html'
>> model = Recipe
>> form_class = RecipeForm
>>
>> def get_success_url(self):
>> self.success_url = '/account/dashboard/'
>> return self.success_url
>>
>> def get_context_data(self, **kwargs):
>> context = super(RecipeUpdateView, self).get_context_data(**
>> kwargs)
>> if self.request.POST:
>> context['form'] = RecipeForm(self.re

Re: Django Class-Based CreateView and UpdateView with multiple inline formsets

2015-01-10 Thread Dan Gentry
I would suggest that in the UpdateView you should set the object to the 
master record being updated rather than to none for both get() and post().  


On Saturday, January 10, 2015 at 8:08:47 AM UTC-5, Ranjith Kumar wrote:
>
> Hello all,
> I have been trying to do Django class-based CreateView and UpdateView with 
> multiple inline formsets
>
> CreateView works fine but UpdateView is not working properly, If anyone 
> tried UpdateView with multiple inline formsets, please point me right 
> approach.
>
> *models.py*
> from django.db import models
>
> class Recipe(models.Model):
> title = models.CharField(max_length=255)
> description = models.TextField()
>
> class Ingredient(models.Model):
> recipe = models.ForeignKey(Recipe)
> description = models.CharField(max_length=255)
>
> class Instruction(models.Model):
> recipe = models.ForeignKey(Recipe)
> number = models.PositiveSmallIntegerField()
> description = models.TextField()
>
> *forms.py*
> from django.forms import ModelForm
> from django.forms.models import inlineformset_factory
> from .models import Recipe, Ingredient, Instruction
>
> class RecipeForm(ModelForm):
> class Meta:
> model = Recipe
>
> IngredientFormSet = inlineformset_factory(Recipe, Ingredient, extra=0)
> InstructionFormSet = inlineformset_factory(Recipe, Instruction, extra=0)
>
> *views.py*
> from django.http import HttpResponseRedirect
> from django.views.generic.edit import CreateView, UpdateView
> from django.shortcuts import get_object_or_404
>
> from .forms import IngredientFormSet, InstructionFormSet, RecipeForm
> from .models import Recipe
>
> class RecipeCreateView(CreateView):
> template_name = 'recipe_add.html'
> model = Recipe
> form_class = RecipeForm
> success_url = '/account/dashboard/'
>
> def get(self, request, *args, **kwargs):
> self.object = None
> form_class = self.get_form_class()
> form = self.get_form(form_class)
> ingredient_form = IngredientFormSet()
> instruction_form = InstructionFormSet()
> return self.render_to_response(
> self.get_context_data(form=form,
>   ingredient_form=ingredient_form,
>   instruction_form=instruction_form))
>
> def post(self, request, *args, **kwargs):
> self.object = None
> form_class = self.get_form_class()
> form = self.get_form(form_class)
> ingredient_form = IngredientFormSet(self.request.POST)
> instruction_form = InstructionFormSet(self.request.POST)
> if (form.is_valid() and ingredient_form.is_valid() and
> instruction_form.is_valid()):
> return self.form_valid(form, ingredient_form, instruction_form)
> else:
> return self.form_invalid(form, ingredient_form, 
> instruction_form)
>
> def form_valid(self, form, ingredient_form, instruction_form):
> self.object = form.save()
> ingredient_form.instance = self.object
> ingredient_form.save()
> instruction_form.instance = self.object
> instruction_form.save()
> return HttpResponseRedirect(self.get_success_url())
>
> def form_invalid(self, form, ingredient_form, instruction_form):
> return self.render_to_response(
> self.get_context_data(form=form,
>   ingredient_form=ingredient_form,
>   instruction_form=instruction_form))
>
> class RecipeUpdateView(UpdateView):
> template_name = 'recipe_add.html'
> model = Recipe
> form_class = RecipeForm
>
> def get_success_url(self):
> self.success_url = '/account/dashboard/'
> return self.success_url
>
> def get_context_data(self, **kwargs):
> context = super(RecipeUpdateView, self).get_context_data(**kwargs)
> if self.request.POST:
> context['form'] = RecipeForm(self.request.POST, 
> instance=self.object)
> context['ingredient_form'] = 
> IngredientFormSet(self.request.POST, instance=self.object)
> context['instruction_form'] = 
> InstructionFormSet(self.request.POST, instance=self.object)
> else:
> context['form'] = RecipeForm(instance=self.object)
> context['ingredient_form'] = 
> IngredientFormSet(instance=self.object)
> context['instruction_form'] = 
> InstructionFormSet(instance=self.object)
> return context
>
> def post(self, request, *args, **kwargs):
> self.object = None
> form_class = self.get_form_class()
>  

Django Class-Based CreateView and UpdateView with multiple inline formsets

2015-01-10 Thread Ranjith Kumar
Hello all,
I have been trying to do Django class-based CreateView and UpdateView with
multiple inline formsets

CreateView works fine but UpdateView is not working properly, If anyone
tried UpdateView with multiple inline formsets, please point me right
approach.

*models.py*
from django.db import models

class Recipe(models.Model):
title = models.CharField(max_length=255)
description = models.TextField()

class Ingredient(models.Model):
recipe = models.ForeignKey(Recipe)
description = models.CharField(max_length=255)

class Instruction(models.Model):
recipe = models.ForeignKey(Recipe)
number = models.PositiveSmallIntegerField()
description = models.TextField()

*forms.py*
from django.forms import ModelForm
from django.forms.models import inlineformset_factory
from .models import Recipe, Ingredient, Instruction

class RecipeForm(ModelForm):
class Meta:
model = Recipe

IngredientFormSet = inlineformset_factory(Recipe, Ingredient, extra=0)
InstructionFormSet = inlineformset_factory(Recipe, Instruction, extra=0)

*views.py*
from django.http import HttpResponseRedirect
from django.views.generic.edit import CreateView, UpdateView
from django.shortcuts import get_object_or_404

from .forms import IngredientFormSet, InstructionFormSet, RecipeForm
from .models import Recipe

class RecipeCreateView(CreateView):
template_name = 'recipe_add.html'
model = Recipe
form_class = RecipeForm
success_url = '/account/dashboard/'

def get(self, request, *args, **kwargs):
self.object = None
form_class = self.get_form_class()
form = self.get_form(form_class)
ingredient_form = IngredientFormSet()
instruction_form = InstructionFormSet()
return self.render_to_response(
self.get_context_data(form=form,
  ingredient_form=ingredient_form,
  instruction_form=instruction_form))

def post(self, request, *args, **kwargs):
self.object = None
form_class = self.get_form_class()
form = self.get_form(form_class)
ingredient_form = IngredientFormSet(self.request.POST)
instruction_form = InstructionFormSet(self.request.POST)
if (form.is_valid() and ingredient_form.is_valid() and
instruction_form.is_valid()):
return self.form_valid(form, ingredient_form, instruction_form)
else:
return self.form_invalid(form, ingredient_form,
instruction_form)

def form_valid(self, form, ingredient_form, instruction_form):
self.object = form.save()
ingredient_form.instance = self.object
ingredient_form.save()
instruction_form.instance = self.object
instruction_form.save()
return HttpResponseRedirect(self.get_success_url())

def form_invalid(self, form, ingredient_form, instruction_form):
return self.render_to_response(
self.get_context_data(form=form,
  ingredient_form=ingredient_form,
  instruction_form=instruction_form))

class RecipeUpdateView(UpdateView):
template_name = 'recipe_add.html'
model = Recipe
form_class = RecipeForm

def get_success_url(self):
self.success_url = '/account/dashboard/'
return self.success_url

def get_context_data(self, **kwargs):
context = super(RecipeUpdateView, self).get_context_data(**kwargs)
if self.request.POST:
context['form'] = RecipeForm(self.request.POST,
instance=self.object)
context['ingredient_form'] =
IngredientFormSet(self.request.POST, instance=self.object)
context['instruction_form'] =
InstructionFormSet(self.request.POST, instance=self.object)
else:
context['form'] = RecipeForm(instance=self.object)
context['ingredient_form'] =
IngredientFormSet(instance=self.object)
context['instruction_form'] =
InstructionFormSet(instance=self.object)
return context

def post(self, request, *args, **kwargs):
self.object = None
form_class = self.get_form_class()
form = self.get_form(form_class)
ingredient_form = IngredientFormSet(self.request.POST)
instruction_form = InstructionFormSet(self.request.POST)
if (form.is_valid() and ingredient_form.is_valid() and
instruction_form.is_valid()):
return self.form_valid(form, ingredient_form, instruction_form)
else:
return self.form_invalid(form, ingredient_form,
instruction_form)

def form_valid(self, form, ingredient_form, instruction_form):
self.object = form.save()
ingredient_form.instance = self.object
ingredient_form.save()
instruction_form.instance = self.object
instruction_form.save()
return HttpResponseRedirect(self.get_success_url())

def form_invalid(self, form, ingredient_form

Re: FormSets with arbitary number of forms

2015-01-02 Thread Some Developer

On 01/01/15 19:52, Edgar Gabaldi wrote:

The formset allow you create many instances of an object. What you need
is the inline formset. When you create a Album, you can create one or
more songs.



Ah!

Thank you. I must have missed that. I'll check it out.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54A74E2A.9070101%40googlemail.com.
For more options, visit https://groups.google.com/d/optout.


Re: FormSets with arbitary number of forms

2015-01-01 Thread Edgar Gabaldi
The formset allow you create many instances of an object. What you need is
the inline formset. When you create a Album, you can create one or more
songs.

On Wed, Dec 31, 2014 at 4:59 PM, Some Developer <someukdevelo...@gmail.com>
wrote:

> I've been reading the documentation on FormSets and must admit that I am a
> bit confused.
>
> I have a model called Album that contains many Songs. But when a user
> creates a new album I have no idea how many songs the Album will contain.
>
> So I want to create a FormSet that has an Album form and many Song forms
> but I need the user to be able to decide how many Song forms there are in
> advance. Is this possible?
>
> I might be misunderstanding the documentation but I couldn't see anything.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/54A447A2.4010804%40googlemail.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGjPPHk3xZ3r_ugBLA_crVWe4dym8nd0-q029B_-A2fP%2BYS9Rw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


FormSets with arbitary number of forms

2014-12-31 Thread Some Developer
I've been reading the documentation on FormSets and must admit that I am 
a bit confused.


I have a model called Album that contains many Songs. But when a user 
creates a new album I have no idea how many songs the Album will contain.


So I want to create a FormSet that has an Album form and many Song forms 
but I need the user to be able to decide how many Song forms there are 
in advance. Is this possible?


I might be misunderstanding the documentation but I couldn't see anything.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54A447A2.4010804%40googlemail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Slow page load performance with a large number of formsets (over 25)

2014-09-22 Thread Collin Anderson
Yes, if you want speed, using javascript and ajax is probably your best 
bet. It will probably also reduce merge-conflicts.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/139835dd-1705-4e58-a300-b40706418601%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Slow page load performance with a large number of formsets (over 25)

2014-09-21 Thread bobhaugen
We have had the same problem, but with a large number of forms. I have 
profiled the situation and the load time is dominated by form rendering on 
the server. 

I remember vaguely something about caching forms so they don't need to be 
re-rendered, but can't find it now. And I don't understand the tradeoffs 
anyway. (Maybe somebody does?)

We're looking at moving away from Django forms to passing Json back and 
forth between Javascript thingies. Recently used http://handsontable.com/ 
to replace a formset. Much faster, much more flexible. You lose some of the 
niceties of model forms, need to do a lot of javascript validations which 
can be cranky, and of course need to do all of your updating in procedural 
code in views.  As always, tradeoffs.

On Friday, September 19, 2014 10:26:04 PM UTC-5, Jason wrote:
>
> We are new to the Django framework and are currently building an 
> application in PythonAnywhere. We have a couple of html pages where the 
> volume of formsets that we are loading up varies from 25 to 100. We find 
> that when we use a small number of formsets, the page loads very quickly. 
> However, performance seems to degrade as the numbers increase. 
>
> It's not an issue with our SQL queries as when we load the same data into 
> a HTML table instead of using formsets, it loads very quickly. 
>
> We need to load the data using formsets because we expect updates to each 
> row from the user.
>
> Has anyone encountered this problem? If so, is there a way to improve the 
> performance of the formsets or are formsets not intended to be used with 
> large volumes of data? If not, are there alternative options that we can 
> use that allow users to modify the data in multiple rows returned by the 
> query? Note - we don't want to send the user to a 'Pop-Up' or another 
> screen to update data. Note 2 - We are using "Model" formsets, in 
> particular "inlineformset_factory".
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3929fd47-cd26-40c2-a6d7-93483ad59b34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Slow page load performance with a large number of formsets (over 25)

2014-09-20 Thread Jason


We are new to the Django framework and are currently building an 
application in PythonAnywhere. We have a couple of html pages where the 
volume of formsets that we are loading up varies from 25 to 100. We find 
that when we use a small number of formsets, the page loads very quickly. 
However, performance seems to degrade as the numbers increase. 

It's not an issue with our SQL queries as when we load the same data into a 
HTML table instead of using formsets, it loads very quickly. 

We need to load the data using formsets because we expect updates to each 
row from the user.

Has anyone encountered this problem? If so, is there a way to improve the 
performance of the formsets or are formsets not intended to be used with 
large volumes of data? If not, are there alternative options that we can 
use that allow users to modify the data in multiple rows returned by the 
query? Note - we don't want to send the user to a 'Pop-Up' or another 
screen to update data. Note 2 - We are using "Model" formsets, in 
particular "inlineformset_factory".

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9ff27ba5-25e5-4c82-92ca-6b8ab5f1a38b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Formsets, adding new forms and autocomplete/ajax selects

2014-05-28 Thread Sanjay Bhangar
hey Lachlan,

So this had driven me a bit crazy some years ago ..

On Wed, May 28, 2014 at 8:42 AM, Lachlan Musicman <data...@gmail.com> wrote:
> Hola,
>
> I am trying to get two different "extras" to work.
>
> I have a form with an inline_formset, which I would like to be able to
> add multiple formsets of on the fly.
>
> Each of those formsets has another FK to a model with a very large
> dataset, so I would also like to implement some sort of
> autocomplete/ajax/select2/typeahead solution to prevent an unusably
> large select
>

I had two additional extras :):

i> The FK could also be an m2m that should be handled by select2.

ii> There should also be an Add + button next to the select2 to add a
new instance, which opens up a pop-up to add a new item, like it does
in the Django admin.

And then I needed this on a whole bunch of models / forms, so I needed
it abstracted / generalized in some way. Unfortunately, the solution I
came up with involves some ugly hacks, so I'm slightly embarassed by
it, haha - its also for a much older version of Django, etc. (1.3,
iirc).

However, I still think this is a really kick-ass and useful thing to
be able to do simply - I'd be happy to try and catch up with you
off-list (which we've been meaning to do anyways, ha!) and see if we
can have some fun rolling a little django app for this or so.

> Here is my basic set up.
>
> models.py
> 
> class PartNumber(models.Model):
> name = models.CharField("Description", max_length=100)
> supplier_part_number = models.CharField(max_length=30,
> unique=True, blank=True, null=True)
>
> class PurchaseOrder(models.Model):
> po_number = models.CharField('PO number', max_length=10, unique=True)
> ordered_date = models.DateField(default=today)
>
> class PurchaseOrderPart(models.Model):
> part_number = models.ForeignKey(PartNumber, related_name='purchases')
> po_number = models.ForeignKey(PurchaseOrder, related_name='partslist')
> delivery_date = models.DateField(null=True, blank=True)
> qty_ordered = models.IntegerField('Quantity
> ordered',validators=[MinValueValidator(1)])
> cost = models.DecimalField('Unit Cost',
> max_digits=10,decimal_places=2,blank=True,null=True)
>
>
> forms.py
> -
>
> class PurchaseOrderPartForm(forms.ModelForm):
> class Meta:
>   fields = ('part_numbers', 'delivery_date', 'qty_ordered', 'cost')
>   model = PurchaseOrderPart
>   widgets={
> 'part_numbers': forms.Select(attrs={'class':'form-control'}),
> 'delivery_date': CalendarWidget(attrs={'class':'input-append
> form-control'}),
> 'qty_ordered': forms.NumberInput(attrs={'class':'form-control'}),
> 'cost': forms.NumberInput(attrs={'class':'form-control'}),
> }
>
> POPartFormset = inlineformset_factory(PurchaseOrder,
> PurchaseOrderPart, form=PurchaseOrderPartForm, extra=1,
> can_delete=True)
>
>
> I have successfully implemented jquery.formset.js (
> https://github.com/elo80ka/django-dynamic-formset ) to create "add"
> and "remove" buttons - this allows for a variable number of
> PurchaseOrderParts on a PurchaseOrder.
>
>
> When I then implemented django-select2 I was mostly successful, except
> for one problem - the way that django-select2 implements field is by
> adding some js on render.
>
> Since the jquery.formset.js was creating forms on the fly, any
> formsets added via it's add button did not have the required
> django-select2 container, and hence had no widget at all.
>
> jquery.formset.js has an "added" function that allows for something
> like this, but then I would need to glue it all together and it
> doesn't seem clean enough.
>

So, I used a similar approach - jquery.formset.js and select2. What I
did was I created a little jquery plugin / wrapper around select2 to
be able to instantiate it with a simple call to like
$('#select_field_id_foo').mySelect2();. I then also created a custom
widget for the autocompletes, which would ensure their custom options
were in the html to be read by the plugin.

So, this is the custom widget class I made:
http://code.camputer.org/itf/annotate/head%3A/itf/app/forms.py#L42

This is its template:
http://code.camputer.org/itf/annotate/head%3A/itf/templates/formwidgets/select2.html

Then I can simply instantiate the widget in my form definition like so:

group = forms.ModelChoiceField(TheatreGroup.objects.all(),
widget=AutocompleteAddWidget(model_class=TheatreGroup))
See for eg: 
http://code.camputer.org/itf/annotate/head%3A/itf/itfprofiles/forms.py#L129

So far so good. Where the ugly hackery lies is the javascript - as you
mention, to work around the problem of instantiating when adding a new
formset and othe

Formsets, adding new forms and autocomplete/ajax selects

2014-05-27 Thread Lachlan Musicman
Hola,

I am trying to get two different "extras" to work.

I have a form with an inline_formset, which I would like to be able to
add multiple formsets of on the fly.

Each of those formsets has another FK to a model with a very large
dataset, so I would also like to implement some sort of
autocomplete/ajax/select2/typeahead solution to prevent an unusably
large select

Here is my basic set up.

models.py

class PartNumber(models.Model):
name = models.CharField("Description", max_length=100)
supplier_part_number = models.CharField(max_length=30,
unique=True, blank=True, null=True)

class PurchaseOrder(models.Model):
po_number = models.CharField('PO number', max_length=10, unique=True)
ordered_date = models.DateField(default=today)

class PurchaseOrderPart(models.Model):
part_number = models.ForeignKey(PartNumber, related_name='purchases')
po_number = models.ForeignKey(PurchaseOrder, related_name='partslist')
delivery_date = models.DateField(null=True, blank=True)
qty_ordered = models.IntegerField('Quantity
ordered',validators=[MinValueValidator(1)])
cost = models.DecimalField('Unit Cost',
max_digits=10,decimal_places=2,blank=True,null=True)


forms.py
-

class PurchaseOrderPartForm(forms.ModelForm):
class Meta:
  fields = ('part_numbers', 'delivery_date', 'qty_ordered', 'cost')
  model = PurchaseOrderPart
  widgets={
'part_numbers': forms.Select(attrs={'class':'form-control'}),
'delivery_date': CalendarWidget(attrs={'class':'input-append
form-control'}),
'qty_ordered': forms.NumberInput(attrs={'class':'form-control'}),
'cost': forms.NumberInput(attrs={'class':'form-control'}),
}

POPartFormset = inlineformset_factory(PurchaseOrder,
PurchaseOrderPart, form=PurchaseOrderPartForm, extra=1,
can_delete=True)


I have successfully implemented jquery.formset.js (
https://github.com/elo80ka/django-dynamic-formset ) to create "add"
and "remove" buttons - this allows for a variable number of
PurchaseOrderParts on a PurchaseOrder.


When I then implemented django-select2 I was mostly successful, except
for one problem - the way that django-select2 implements field is by
adding some js on render.

Since the jquery.formset.js was creating forms on the fly, any
formsets added via it's add button did not have the required
django-select2 container, and hence had no widget at all.

jquery.formset.js has an "added" function that allows for something
like this, but then I would need to glue it all together and it
doesn't seem clean enough.

I had previously looked at typeahead, django-ajax-selects and
django-autocomplete-light but struggled to implement them. I will
likely go back to try again.

Surely I'm not the first person that's had this need - can anyone
offer tips on a good or better solution?

cheers
L.



-- 
The idea is that a beautiful image is frameable. Everything you need
to see is there: It’s everything you want, and it’s very pleasing
because there’s no extra information that you don’t get to see.
Everything’s in a nice package for you. But sublime art is
unframeable: It’s an image or idea that implies that there’s a bigger
image or idea that you can’t see: You’re only getting to look at a
fraction of it, and in that way it’s both beautiful and scary, because
it’s reminding you that there’s more that you don’t have access to.
It’s now sort of left the piece itself and it’s become your own
invention, so it’s personal as well as being scary as well as being
beautiful, which is what I really like about art like that.
---
Adventure Time http://theholenearthecenteroftheworld.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGBeqiONWsyKP8xymqCV1Y26kqV7ikA9sDxOaqfciG_LNEw0Sg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Dynamic Formsets

2014-04-12 Thread Venkatraman S
Can you try with this : https://gist.github.com/venkasub/10544716
It works for me. Let me know if you have trouble.

-V


On Wed, Apr 9, 2014 at 4:58 PM, Leandro Alves <ldal...@gmail.com> wrote:

> Hi again,
>
> So I followed the documentation and created a formset as we have there.
> https://docs.djangoproject.com/en/1.6/topics/forms/formsets/
>
> Then I followed the documentation and included the django-formset-js:
> https://pypi.python.org/pypi/django-formset-js/
>
> But I can't get the buttons "Add another" neither "Delete" working.
> And I'm sure I'm missing something that I don't know yet.
>
> This is what I have so far:
>
>
> *forms.py*
>
> from django import forms
> from django.forms.formsets import formset_factory
>
> class ArticleForm(forms.Form):
> title = forms.CharField()
> pub_date = forms.DateField()
>
>
> *views.py*
>
> from django.forms.formsets import formset_factory
> from django.shortcuts import render_to_response
> from formsets.djdocs.forms import ArticleForm
>
> def manage_articles(request):
> ArticleFormSet = formset_factory(ArticleForm, can_delete=True, extra=2)
> if request.method == 'POST':
> formset = ArticleFormSet(request.POST, request.FILES)
> if formset.is_valid():
> # do something with the formset.cleaned_data
> for form in formset:
> print(form.as_table())
> pass
> else:
> formset = ArticleFormSet()
>
> return render_to_response('djdocs/manage_articles.html', {'formset':
> formset})
>
>
> *urls.py*
>
> from django.conf.urls import patterns, include, url
> from formsets.djdocs.views import manage_articles
>
> urlpatterns = patterns('djdocs.views',
> url(r'^$', manage_articles),
> )
>
>
> *template manage_articles.html*
>
> {% extends "index.html" %}
> {% block content %}
>
> {% load formset_tags %}
> 
> {{ formset.management_form }}
>
> 
> 
> {% for form in formset %}
> 
> {{ form }}
> {{ form.DELETE }}
> Delete
> form
> 
> {% endfor %}
> 
>
> 
> 
> {% escapescript %}
> <div data-formset-form>
> {{ formset.empty_form }}
> <button type="button" data-formset-delete-button>Delete
> form</button>
> </div>
> {% endescapescript %}
> 
>
> 
> 
>
> jQuery(function($) {
> $("#formset").formset({
> animateForms: true
> });
> });
>
> 
>
> {% endblock %}
>
> In the index.html file I'm loading the .js like:
>
> {% load staticfiles %}
> 
> 
>
>
> Any advice? :)
>
> Best regards,
>
> Leandro
>
>
>
> On Wednesday, April 9, 2014 7:19:11 AM UTC+2, Venkatraman.S. wrote:
>
>> Actually, there is nothing more to it. Include the js and create the
>> formset_factory and start using it in the template by iterating over it. In
>> the view, post-POST, again iterate over the formsets. Bulk of the work is
>> done by the js and you dont have to do much in django. There is a minor bug
>> in the js which lets even one row in the UI to get deleted, but its not a
>> show-stopper :)
>>
>> Let me know if its still trouble and I shall write something up.
>>
>> On Tue, Apr 8, 2014 at 10:16 PM, Leandro Alves <lda...@gmail.com> wrote:
>>
>>> Hello Venkatraman,
>>>
>>> Yes.. I saw this one was well... and I want to try it.. but I'm still
>>> learning about Formsets...
>>> Would you have any basic simple foo example to share? :)
>>>
>>> Best,
>>>
>>> Leandro
>>>
>>>
>>>
>>> On Tuesday, April 8, 2014 2:48:15 AM UTC+2, Venkatraman.S. wrote:
>>>
>>>> Have you tried the jquery formset - works like a breeze for me.
>>>>
>>>>
>>>> On Mon, Apr 7, 2014 at 10:43 PM, Leandro Alves <lda...@gmail.com>wrote:
>>>>
>>>>>  Hi,
>>>>>
>>>>> I wonder if anyone knows of any example of django-dynamic-formsets [1]
>>>>> that works with Django 1.6?
>>>>>
>>>>> So far all I found on the internet are over 3 years old and they don't
>>>>> work with Django version 1.6.
>>>>>
>>>>> I am willing to pay for any example that works if necessary. :)
>>>>>
>>>>> Thanks in advance,
&g

Re: Django Dynamic Formsets

2014-04-09 Thread Leandro Alves
Hi again, 

So I followed the documentation and created a formset as we have there. 
https://docs.djangoproject.com/en/1.6/topics/forms/formsets/

Then I followed the documentation and included the django-formset-js:
https://pypi.python.org/pypi/django-formset-js/

But I can't get the buttons "Add another" neither "Delete" working.  
And I'm sure I'm missing something that I don't know yet.  

This is what I have so far: 


*forms.py*

from django import forms
from django.forms.formsets import formset_factory

class ArticleForm(forms.Form):
title = forms.CharField()
pub_date = forms.DateField()


*views.py*

from django.forms.formsets import formset_factory
from django.shortcuts import render_to_response
from formsets.djdocs.forms import ArticleForm

def manage_articles(request):
ArticleFormSet = formset_factory(ArticleForm, can_delete=True, extra=2)
if request.method == 'POST':
formset = ArticleFormSet(request.POST, request.FILES)
if formset.is_valid():
# do something with the formset.cleaned_data
for form in formset:
print(form.as_table())
pass
else:
formset = ArticleFormSet()

return render_to_response('djdocs/manage_articles.html', {'formset': 
formset})


*urls.py*

from django.conf.urls import patterns, include, url
from formsets.djdocs.views import manage_articles

urlpatterns = patterns('djdocs.views',
url(r'^$', manage_articles),
)


*template manage_articles.html*

{% extends "index.html" %}
{% block content %}

{% load formset_tags %}

{{ formset.management_form }}



{% for form in formset %}

{{ form }}
{{ form.DELETE }}
Delete 
form

{% endfor %}




{% escapescript %}
<div data-formset-form>
{{ formset.empty_form }}
<button type="button" data-formset-delete-button>Delete 
form</button>
</div>
{% endescapescript %}





jQuery(function($) {
$("#formset").formset({
animateForms: true
});
});



{% endblock %}

In the index.html file I'm loading the .js like:

{% load staticfiles %}




Any advice? :)

Best regards, 

Leandro



On Wednesday, April 9, 2014 7:19:11 AM UTC+2, Venkatraman.S. wrote:
>
> Actually, there is nothing more to it. Include the js and create the 
> formset_factory and start using it in the template by iterating over it. In 
> the view, post-POST, again iterate over the formsets. Bulk of the work is 
> done by the js and you dont have to do much in django. There is a minor bug 
> in the js which lets even one row in the UI to get deleted, but its not a 
> show-stopper :)
>
> Let me know if its still trouble and I shall write something up.
>
> On Tue, Apr 8, 2014 at 10:16 PM, Leandro Alves <lda...@gmail.com
> > wrote:
>
>> Hello Venkatraman,
>>
>> Yes.. I saw this one was well... and I want to try it.. but I'm still 
>> learning about Formsets...
>> Would you have any basic simple foo example to share? :)
>>
>> Best, 
>>
>> Leandro
>>
>>
>>
>> On Tuesday, April 8, 2014 2:48:15 AM UTC+2, Venkatraman.S. wrote:
>>
>>> Have you tried the jquery formset - works like a breeze for me. 
>>>
>>>
>>> On Mon, Apr 7, 2014 at 10:43 PM, Leandro Alves <lda...@gmail.com> wrote:
>>>
>>>>  Hi, 
>>>>
>>>> I wonder if anyone knows of any example of django-dynamic-formsets [1] 
>>>> that works with Django 1.6?
>>>>
>>>> So far all I found on the internet are over 3 years old and they don't 
>>>> work with Django version 1.6. 
>>>>
>>>> I am willing to pay for any example that works if necessary. :)
>>>>
>>>> Thanks in advance, 
>>>>
>>>> Leandro
>>>>
>>>>
>>>> [1] - https://code.google.com/p/django-dynamic-formset/
>>>>  
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to django-users...@googlegroups.com.
>>>> To post to this group, send email to django...@googlegroups.com.
>>>>
>>>> Visit this group at http://groups.google.com/group/django-users.
>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>> msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%
>>>> 40googlegroups.com<https://groups.g

Re: Django Dynamic Formsets

2014-04-08 Thread Venkatraman S
Actually, there is nothing more to it. Include the js and create the
formset_factory and start using it in the template by iterating over it. In
the view, post-POST, again iterate over the formsets. Bulk of the work is
done by the js and you dont have to do much in django. There is a minor bug
in the js which lets even one row in the UI to get deleted, but its not a
show-stopper :)

Let me know if its still trouble and I shall write something up.

On Tue, Apr 8, 2014 at 10:16 PM, Leandro Alves <ldal...@gmail.com> wrote:

> Hello Venkatraman,
>
> Yes.. I saw this one was well... and I want to try it.. but I'm still
> learning about Formsets...
> Would you have any basic simple foo example to share? :)
>
> Best,
>
> Leandro
>
>
>
> On Tuesday, April 8, 2014 2:48:15 AM UTC+2, Venkatraman.S. wrote:
>
>> Have you tried the jquery formset - works like a breeze for me.
>>
>>
>> On Mon, Apr 7, 2014 at 10:43 PM, Leandro Alves <lda...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I wonder if anyone knows of any example of django-dynamic-formsets [1]
>>> that works with Django 1.6?
>>>
>>> So far all I found on the internet are over 3 years old and they don't
>>> work with Django version 1.6.
>>>
>>> I am willing to pay for any example that works if necessary. :)
>>>
>>> Thanks in advance,
>>>
>>> Leandro
>>>
>>>
>>> [1] - https://code.google.com/p/django-dynamic-formset/
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>>
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%
>>> 40googlegroups.com<https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5784f512-3a99-419e-8e06-1bfe5ef1ba55%40googlegroups.com<https://groups.google.com/d/msgid/django-users/5784f512-3a99-419e-8e06-1bfe5ef1ba55%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7tdFRJecrQLtOAtuDM%3DDw83Y3Sr9R_oeLS14q89BsvTvCUKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Dynamic Formsets

2014-04-08 Thread Leandro Alves
Hello Venkatraman,

Yes.. I saw this one was well... and I want to try it.. but I'm still 
learning about Formsets...
Would you have any basic simple foo example to share? :)

Best, 

Leandro



On Tuesday, April 8, 2014 2:48:15 AM UTC+2, Venkatraman.S. wrote:
>
> Have you tried the jquery formset - works like a breeze for me. 
>
>
> On Mon, Apr 7, 2014 at 10:43 PM, Leandro Alves <lda...@gmail.com
> > wrote:
>
>> Hi, 
>>
>> I wonder if anyone knows of any example of django-dynamic-formsets [1] 
>> that works with Django 1.6?
>>
>> So far all I found on the internet are over 3 years old and they don't 
>> work with Django version 1.6. 
>>
>> I am willing to pay for any example that works if necessary. :)
>>
>> Thanks in advance, 
>>
>> Leandro
>>
>>
>> [1] - https://code.google.com/p/django-dynamic-formset/
>>  
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com<https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5784f512-3a99-419e-8e06-1bfe5ef1ba55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Dynamic Formsets

2014-04-08 Thread Leandro Alves
Hello Alejandro!!!

Man...I swear, if I had it I would be sooo happy to share... :)

I still couldn't get a normal Formset example to work.. Do you have any 
simple foo example to share? hehehe
I'm trying 
from https://docs.djangoproject.com/en/1.6/topics/forms/formsets/.

I also tried to make the "demo" example from django-dynamic-formsets works 
with Django 1.6. But not luck...

But I keep trying and I will post here If I got any news. :)

Best regards, 

Leandro



On Tuesday, April 8, 2014 3:32:44 PM UTC+2, Alejandro Perez wrote:
>
> Hey Leandro, I'm looking for something like that and your topic question 
> is rolling in my head.. Could you please share your solution with the 
> community? :D
> Thanks !!! :)
>
> El lunes, 7 de abril de 2014 15:53:13 UTC-4, Leandro Alves escribió:
>>
>> Done. :)
>>
>> Thanks!!!
>>
>>
>> On Monday, April 7, 2014 9:42:53 PM UTC+2, Gladson Simplício Brito wrote:
>>>
>>> Okay, send email here:
>>>
>>> gla...@immensa.com.br
>>>
>>>
>>> 2014-04-07 15:24 GMT-04:00 Leandro Alves <lda...@gmail.com>:
>>>
>>>> Brother, I think I have tried all of those already and some other 
>>>> around the internet... 
>>>> I couldn't find anyone that works with Django 1.6. 
>>>>
>>>> I will send you an email with what I need, ok? :)
>>>>
>>>> Thanks again!
>>>>
>>>> Leandro
>>>>
>>>>
>>>>
>>>> On Monday, April 7, 2014 8:43:06 PM UTC+2, Gladson Simplício Brito 
>>>> wrote:
>>>>
>>>>> Try these:
>>>>> https://pypi.python.org/pypi?%3Aaction=search=formset;
>>>>> submit=search
>>>>>
>>>>> If not, tell your need.
>>>>> :D
>>>>>
>>>>>
>>>>> 2014-04-07 14:16 GMT-04:00 Leandro Alves <lda...@gmail.com>:
>>>>>
>>>>>> Yes.. I have tried that one as well.. but the example still doesn't 
>>>>>> work... =/
>>>>>>
>>>>>> Any freelance available for this? 
>>>>>>
>>>>>> Thanks for the feedback!
>>>>>>
>>>>>> Leandro
>>>>>>
>>>>>>
>>>>>> On Mon, Apr 7, 2014 at 7:33 PM, Gladson Simplício Brito <
>>>>>> gladso...@gmail.com> wrote:
>>>>>>
>>>>>>> The project was migrated to another repository:
>>>>>>>
>>>>>>> https://github.com/elo80ka/django-dynamic-formset
>>>>>>>  
>>>>>>>
>>>>>>> 2014-04-07 13:13 GMT-04:00 Leandro Alves <lda...@gmail.com>:
>>>>>>>
>>>>>>>>  Hi, 
>>>>>>>>
>>>>>>>> I wonder if anyone knows of any example of django-dynamic-formsets 
>>>>>>>> [1] that works with Django 1.6?
>>>>>>>>
>>>>>>>> So far all I found on the internet are over 3 years old and they 
>>>>>>>> don't work with Django version 1.6. 
>>>>>>>>
>>>>>>>> I am willing to pay for any example that works if necessary. :)
>>>>>>>>
>>>>>>>> Thanks in advance, 
>>>>>>>>
>>>>>>>> Leandro
>>>>>>>>
>>>>>>>>
>>>>>>>> [1] - https://code.google.com/p/django-dynamic-formset/
>>>>>>>>  
>>>>>>>> -- 
>>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>>> Groups "Django users" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>>> send an email to django-users...@googlegroups.com.
>>>>>>>>
>>>>>>>> To post to this group, send email to django...@googlegroups.com.
>>>>>>>>
>>>>>>>> Visit this group at http://groups.google.com/group/django-users.
>>>>>>>> To view this discussion on the web visit 
>>>>>>>> https://groups.google.com/d/msgid/django-users/95dc89cb-
>>>>>>>> cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com<https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com

Re: Django Dynamic Formsets

2014-04-08 Thread Alejandro Perez
Hey Leandro, I'm looking for something like that and your topic question is 
rolling in my head.. Could you please share your solution with the 
community? :D
Thanks !!! :)

El lunes, 7 de abril de 2014 15:53:13 UTC-4, Leandro Alves escribió:
>
> Done. :)
>
> Thanks!!!
>
>
> On Monday, April 7, 2014 9:42:53 PM UTC+2, Gladson Simplício Brito wrote:
>>
>> Okay, send email here:
>>
>> gla...@immensa.com.br
>>
>>
>> 2014-04-07 15:24 GMT-04:00 Leandro Alves <lda...@gmail.com>:
>>
>>> Brother, I think I have tried all of those already and some other around 
>>> the internet... 
>>> I couldn't find anyone that works with Django 1.6. 
>>>
>>> I will send you an email with what I need, ok? :)
>>>
>>> Thanks again!
>>>
>>> Leandro
>>>
>>>
>>>
>>> On Monday, April 7, 2014 8:43:06 PM UTC+2, Gladson Simplício Brito wrote:
>>>
>>>> Try these:
>>>> https://pypi.python.org/pypi?%3Aaction=search=formset;
>>>> submit=search
>>>>
>>>> If not, tell your need.
>>>> :D
>>>>
>>>>
>>>> 2014-04-07 14:16 GMT-04:00 Leandro Alves <lda...@gmail.com>:
>>>>
>>>>> Yes.. I have tried that one as well.. but the example still doesn't 
>>>>> work... =/
>>>>>
>>>>> Any freelance available for this? 
>>>>>
>>>>> Thanks for the feedback!
>>>>>
>>>>> Leandro
>>>>>
>>>>>
>>>>> On Mon, Apr 7, 2014 at 7:33 PM, Gladson Simplício Brito <
>>>>> gladso...@gmail.com> wrote:
>>>>>
>>>>>> The project was migrated to another repository:
>>>>>>
>>>>>> https://github.com/elo80ka/django-dynamic-formset
>>>>>>  
>>>>>>
>>>>>> 2014-04-07 13:13 GMT-04:00 Leandro Alves <lda...@gmail.com>:
>>>>>>
>>>>>>>  Hi, 
>>>>>>>
>>>>>>> I wonder if anyone knows of any example of django-dynamic-formsets 
>>>>>>> [1] that works with Django 1.6?
>>>>>>>
>>>>>>> So far all I found on the internet are over 3 years old and they 
>>>>>>> don't work with Django version 1.6. 
>>>>>>>
>>>>>>> I am willing to pay for any example that works if necessary. :)
>>>>>>>
>>>>>>> Thanks in advance, 
>>>>>>>
>>>>>>> Leandro
>>>>>>>
>>>>>>>
>>>>>>> [1] - https://code.google.com/p/django-dynamic-formset/
>>>>>>>  
>>>>>>> -- 
>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>> Groups "Django users" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>> send an email to django-users...@googlegroups.com.
>>>>>>>
>>>>>>> To post to this group, send email to django...@googlegroups.com.
>>>>>>>
>>>>>>> Visit this group at http://groups.google.com/group/django-users.
>>>>>>> To view this discussion on the web visit 
>>>>>>> https://groups.google.com/d/msgid/django-users/95dc89cb-
>>>>>>> cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com<https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com?utm_medium=email_source=footer>
>>>>>>> .
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>>
>>>>>>  -- 
>>>>>> You received this message because you are subscribed to a topic in 
>>>>>> the Google Groups "Django users" group.
>>>>>> To unsubscribe from this topic, visit https://groups.google.com/d/
>>>>>> topic/django-users/_sfhHrcDJBs/unsubscribe.
>>>>>>  To unsubscribe from this group and all its topics, send an email to 
>>>>>> django-users...@googlegroups.com.
>>>>>> To post to this group, send email to django...@googlegroups.com.
>>>>>>
>>>>>> Visit this group at http://groups.google.com/group/django-users.
>>>>>> T

Re: Django Dynamic Formsets

2014-04-07 Thread Venkatraman S
Have you tried the jquery formset - works like a breeze for me.


On Mon, Apr 7, 2014 at 10:43 PM, Leandro Alves <ldal...@gmail.com> wrote:

> Hi,
>
> I wonder if anyone knows of any example of django-dynamic-formsets [1]
> that works with Django 1.6?
>
> So far all I found on the internet are over 3 years old and they don't
> work with Django version 1.6.
>
> I am willing to pay for any example that works if necessary. :)
>
> Thanks in advance,
>
> Leandro
>
>
> [1] - https://code.google.com/p/django-dynamic-formset/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com<https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN7tdFRV9FkLVKSa%2Bbac84OxkEQD0eBF4_fR-98A1vC66%3DXiAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Dynamic Formsets

2014-04-07 Thread Leandro Alves
Done. :)

Thanks!!!


On Monday, April 7, 2014 9:42:53 PM UTC+2, Gladson Simplício Brito wrote:
>
> Okay, send email here:
>
> gla...@immensa.com.br 
>
>
> 2014-04-07 15:24 GMT-04:00 Leandro Alves <lda...@gmail.com >:
>
>> Brother, I think I have tried all of those already and some other around 
>> the internet... 
>> I couldn't find anyone that works with Django 1.6. 
>>
>> I will send you an email with what I need, ok? :)
>>
>> Thanks again!
>>
>> Leandro
>>
>>
>>
>> On Monday, April 7, 2014 8:43:06 PM UTC+2, Gladson Simplício Brito wrote:
>>
>>> Try these:
>>> https://pypi.python.org/pypi?%3Aaction=search=formset=search
>>>
>>> If not, tell your need.
>>> :D
>>>
>>>
>>> 2014-04-07 14:16 GMT-04:00 Leandro Alves <lda...@gmail.com>:
>>>
>>>> Yes.. I have tried that one as well.. but the example still doesn't 
>>>> work... =/
>>>>
>>>> Any freelance available for this? 
>>>>
>>>> Thanks for the feedback!
>>>>
>>>> Leandro
>>>>
>>>>
>>>> On Mon, Apr 7, 2014 at 7:33 PM, Gladson Simplício Brito <
>>>> gladso...@gmail.com> wrote:
>>>>
>>>>> The project was migrated to another repository:
>>>>>
>>>>> https://github.com/elo80ka/django-dynamic-formset
>>>>>  
>>>>>
>>>>> 2014-04-07 13:13 GMT-04:00 Leandro Alves <lda...@gmail.com>:
>>>>>
>>>>>>  Hi, 
>>>>>>
>>>>>> I wonder if anyone knows of any example of django-dynamic-formsets 
>>>>>> [1] that works with Django 1.6?
>>>>>>
>>>>>> So far all I found on the internet are over 3 years old and they 
>>>>>> don't work with Django version 1.6. 
>>>>>>
>>>>>> I am willing to pay for any example that works if necessary. :)
>>>>>>
>>>>>> Thanks in advance, 
>>>>>>
>>>>>> Leandro
>>>>>>
>>>>>>
>>>>>> [1] - https://code.google.com/p/django-dynamic-formset/
>>>>>>  
>>>>>> -- 
>>>>>> You received this message because you are subscribed to the Google 
>>>>>> Groups "Django users" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>> send an email to django-users...@googlegroups.com.
>>>>>>
>>>>>> To post to this group, send email to django...@googlegroups.com.
>>>>>>
>>>>>> Visit this group at http://groups.google.com/group/django-users.
>>>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>>>> msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%
>>>>>> 40googlegroups.com<https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com?utm_medium=email_source=footer>
>>>>>> .
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>  -- 
>>>>> You received this message because you are subscribed to a topic in the 
>>>>> Google Groups "Django users" group.
>>>>> To unsubscribe from this topic, visit https://groups.google.com/d/
>>>>> topic/django-users/_sfhHrcDJBs/unsubscribe.
>>>>>  To unsubscribe from this group and all its topics, send an email to 
>>>>> django-users...@googlegroups.com.
>>>>> To post to this group, send email to django...@googlegroups.com.
>>>>>
>>>>> Visit this group at http://groups.google.com/group/django-users.
>>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>>> msgid/django-users/CAKN-GttJ2YrMgc7gRNdhm7H0jg3yanH_
>>>>> rYV9Z%3Df2SwLJ3L%2BX1Q%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAKN-GttJ2YrMgc7gRNdhm7H0jg3yanH_rYV9Z%3Df2SwLJ3L%2BX1Q%40mail.gmail.com?utm_medium=email_source=footer>
>>>>> .
>>>>>
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>  -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Django users" gr

Re: Django Dynamic Formsets

2014-04-07 Thread Gladson Simplício Brito
Okay, send email here:

glad...@immensa.com.br


2014-04-07 15:24 GMT-04:00 Leandro Alves <ldal...@gmail.com>:

> Brother, I think I have tried all of those already and some other around
> the internet...
> I couldn't find anyone that works with Django 1.6.
>
> I will send you an email with what I need, ok? :)
>
> Thanks again!
>
> Leandro
>
>
>
> On Monday, April 7, 2014 8:43:06 PM UTC+2, Gladson Simplício Brito wrote:
>
>> Try these:
>> https://pypi.python.org/pypi?%3Aaction=search=formset=search
>>
>> If not, tell your need.
>> :D
>>
>>
>> 2014-04-07 14:16 GMT-04:00 Leandro Alves <lda...@gmail.com>:
>>
>>> Yes.. I have tried that one as well.. but the example still doesn't
>>> work... =/
>>>
>>> Any freelance available for this?
>>>
>>> Thanks for the feedback!
>>>
>>> Leandro
>>>
>>>
>>> On Mon, Apr 7, 2014 at 7:33 PM, Gladson Simplício Brito <
>>> gladso...@gmail.com> wrote:
>>>
>>>> The project was migrated to another repository:
>>>>
>>>> https://github.com/elo80ka/django-dynamic-formset
>>>>
>>>>
>>>> 2014-04-07 13:13 GMT-04:00 Leandro Alves <lda...@gmail.com>:
>>>>
>>>>>  Hi,
>>>>>
>>>>> I wonder if anyone knows of any example of django-dynamic-formsets [1]
>>>>> that works with Django 1.6?
>>>>>
>>>>> So far all I found on the internet are over 3 years old and they don't
>>>>> work with Django version 1.6.
>>>>>
>>>>> I am willing to pay for any example that works if necessary. :)
>>>>>
>>>>> Thanks in advance,
>>>>>
>>>>> Leandro
>>>>>
>>>>>
>>>>> [1] - https://code.google.com/p/django-dynamic-formset/
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Django users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to django-users...@googlegroups.com.
>>>>>
>>>>> To post to this group, send email to django...@googlegroups.com.
>>>>>
>>>>> Visit this group at http://groups.google.com/group/django-users.
>>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>>> msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%
>>>>> 40googlegroups.com<https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com?utm_medium=email_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to a topic in the
>>>> Google Groups "Django users" group.
>>>> To unsubscribe from this topic, visit https://groups.google.com/d/
>>>> topic/django-users/_sfhHrcDJBs/unsubscribe.
>>>> To unsubscribe from this group and all its topics, send an email to
>>>> django-users...@googlegroups.com.
>>>> To post to this group, send email to django...@googlegroups.com.
>>>>
>>>> Visit this group at http://groups.google.com/group/django-users.
>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>> msgid/django-users/CAKN-GttJ2YrMgc7gRNdhm7H0jg3yanH_
>>>> rYV9Z%3Df2SwLJ3L%2BX1Q%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAKN-GttJ2YrMgc7gRNdhm7H0jg3yanH_rYV9Z%3Df2SwLJ3L%2BX1Q%40mail.gmail.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>>
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/django-users/CAA-sWORBDh6Bi_Ts9LL4ygAMksCQShNQoQSpS%
>>> 3DuQKiXTxafvkw%40mail.gmail.com<https://groups.googl

Re: Django Dynamic Formsets

2014-04-07 Thread Leandro Alves
Brother, I think I have tried all of those already and some other around 
the internet... 
I couldn't find anyone that works with Django 1.6. 

I will send you an email with what I need, ok? :)

Thanks again!

Leandro



On Monday, April 7, 2014 8:43:06 PM UTC+2, Gladson Simplício Brito wrote:
>
> Try these:
> https://pypi.python.org/pypi?%3Aaction=search=formset=search
>
> If not, tell your need.
> :D
>
>
> 2014-04-07 14:16 GMT-04:00 Leandro Alves <lda...@gmail.com >:
>
>> Yes.. I have tried that one as well.. but the example still doesn't 
>> work... =/
>>
>> Any freelance available for this? 
>>
>> Thanks for the feedback!
>>
>> Leandro
>>
>>
>> On Mon, Apr 7, 2014 at 7:33 PM, Gladson Simplício Brito <
>> gladso...@gmail.com > wrote:
>>
>>> The project was migrated to another repository:
>>>
>>> https://github.com/elo80ka/django-dynamic-formset
>>>  
>>>
>>> 2014-04-07 13:13 GMT-04:00 Leandro Alves <lda...@gmail.com 
>>> >:
>>>
>>>>  Hi, 
>>>>
>>>> I wonder if anyone knows of any example of django-dynamic-formsets [1] 
>>>> that works with Django 1.6?
>>>>
>>>> So far all I found on the internet are over 3 years old and they don't 
>>>> work with Django version 1.6. 
>>>>
>>>> I am willing to pay for any example that works if necessary. :)
>>>>
>>>> Thanks in advance, 
>>>>
>>>> Leandro
>>>>
>>>>
>>>> [1] - https://code.google.com/p/django-dynamic-formset/
>>>>  
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to django-users...@googlegroups.com .
>>>>
>>>> To post to this group, send email to 
>>>> django...@googlegroups.com
>>>> .
>>>> Visit this group at http://groups.google.com/group/django-users.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com<https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com?utm_medium=email_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>  -- 
>>> You received this message because you are subscribed to a topic in the 
>>> Google Groups "Django users" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/django-users/_sfhHrcDJBs/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> django-users...@googlegroups.com .
>>> To post to this group, send email to django...@googlegroups.com
>>> .
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/CAKN-GttJ2YrMgc7gRNdhm7H0jg3yanH_rYV9Z%3Df2SwLJ3L%2BX1Q%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAKN-GttJ2YrMgc7gRNdhm7H0jg3yanH_rYV9Z%3Df2SwLJ3L%2BX1Q%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CAA-sWORBDh6Bi_Ts9LL4ygAMksCQShNQoQSpS%3DuQKiXTxafvkw%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAA-sWORBDh6Bi_Ts9LL4ygAMksCQShNQoQSpS%3DuQKiXTxafvkw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/02005c60-1be6-427d-9d12-6c8b83811b39%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Dynamic Formsets

2014-04-07 Thread Gladson Simplício Brito
Try these:
https://pypi.python.org/pypi?%3Aaction=search=formset=search

If not, tell your need.
:D


2014-04-07 14:16 GMT-04:00 Leandro Alves <ldal...@gmail.com>:

> Yes.. I have tried that one as well.. but the example still doesn't
> work... =/
>
> Any freelance available for this?
>
> Thanks for the feedback!
>
> Leandro
>
>
> On Mon, Apr 7, 2014 at 7:33 PM, Gladson Simplício Brito <
> gladsonbr...@gmail.com> wrote:
>
>> The project was migrated to another repository:
>>
>> https://github.com/elo80ka/django-dynamic-formset
>>
>>
>> 2014-04-07 13:13 GMT-04:00 Leandro Alves <ldal...@gmail.com>:
>>
>>>  Hi,
>>>
>>> I wonder if anyone knows of any example of django-dynamic-formsets [1]
>>> that works with Django 1.6?
>>>
>>> So far all I found on the internet are over 3 years old and they don't
>>> work with Django version 1.6.
>>>
>>> I am willing to pay for any example that works if necessary. :)
>>>
>>> Thanks in advance,
>>>
>>> Leandro
>>>
>>>
>>> [1] - https://code.google.com/p/django-dynamic-formset/
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>>
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com<https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/django-users/_sfhHrcDJBs/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAKN-GttJ2YrMgc7gRNdhm7H0jg3yanH_rYV9Z%3Df2SwLJ3L%2BX1Q%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAKN-GttJ2YrMgc7gRNdhm7H0jg3yanH_rYV9Z%3Df2SwLJ3L%2BX1Q%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAA-sWORBDh6Bi_Ts9LL4ygAMksCQShNQoQSpS%3DuQKiXTxafvkw%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAA-sWORBDh6Bi_Ts9LL4ygAMksCQShNQoQSpS%3DuQKiXTxafvkw%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKN-GttOeoeS30xggcY6MnkUAXRTpPJvpuixAfqJ3oyAoL5DRA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Dynamic Formsets

2014-04-07 Thread Leandro Alves
Yes.. I have tried that one as well.. but the example still doesn't work...
=/

Any freelance available for this?

Thanks for the feedback!

Leandro


On Mon, Apr 7, 2014 at 7:33 PM, Gladson Simplício Brito <
gladsonbr...@gmail.com> wrote:

> The project was migrated to another repository:
>
> https://github.com/elo80ka/django-dynamic-formset
>
>
> 2014-04-07 13:13 GMT-04:00 Leandro Alves <ldal...@gmail.com>:
>
>> Hi,
>>
>> I wonder if anyone knows of any example of django-dynamic-formsets [1]
>> that works with Django 1.6?
>>
>> So far all I found on the internet are over 3 years old and they don't
>> work with Django version 1.6.
>>
>> I am willing to pay for any example that works if necessary. :)
>>
>> Thanks in advance,
>>
>> Leandro
>>
>>
>> [1] - https://code.google.com/p/django-dynamic-formset/
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>>
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com<https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/_sfhHrcDJBs/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAKN-GttJ2YrMgc7gRNdhm7H0jg3yanH_rYV9Z%3Df2SwLJ3L%2BX1Q%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAKN-GttJ2YrMgc7gRNdhm7H0jg3yanH_rYV9Z%3Df2SwLJ3L%2BX1Q%40mail.gmail.com?utm_medium=email_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAA-sWORBDh6Bi_Ts9LL4ygAMksCQShNQoQSpS%3DuQKiXTxafvkw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Dynamic Formsets

2014-04-07 Thread Gladson Simplício Brito
The project was migrated to another repository:

https://github.com/elo80ka/django-dynamic-formset


2014-04-07 13:13 GMT-04:00 Leandro Alves <ldal...@gmail.com>:

> Hi,
>
> I wonder if anyone knows of any example of django-dynamic-formsets [1]
> that works with Django 1.6?
>
> So far all I found on the internet are over 3 years old and they don't
> work with Django version 1.6.
>
> I am willing to pay for any example that works if necessary. :)
>
> Thanks in advance,
>
> Leandro
>
>
> [1] - https://code.google.com/p/django-dynamic-formset/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com<https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKN-GttJ2YrMgc7gRNdhm7H0jg3yanH_rYV9Z%3Df2SwLJ3L%2BX1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django Dynamic Formsets

2014-04-07 Thread Leandro Alves
Hi, 

I wonder if anyone knows of any example of django-dynamic-formsets [1] that 
works with Django 1.6?

So far all I found on the internet are over 3 years old and they don't work 
with Django version 1.6. 

I am willing to pay for any example that works if necessary. :)

Thanks in advance, 

Leandro


[1] - https://code.google.com/p/django-dynamic-formset/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/95dc89cb-cdd7-43c5-adca-da0a1aaf9573%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.5.1 and formsets with more than 1000 initials

2013-04-25 Thread Carsten Fuchs

Hi Xavier,

thank you very much for your reply!  :)

Am 25.04.2013 07:31, schrieb Xavier Ordoquy:

I'm not sure whether the FormSet could extends itself this number if the 
initial_data is larger than 1000.


If I understand the documentation correctly, the purpose of the 
`max_num` parameter is to prevent that someone sends a manipulated, 
excessively large value in the hidden form field that states the number 
of (extra) forms that are submitted, whereas it is not (directly) 
related to the number of forms that are *actually* POSTed, or 
initialized via parameter `initials`.


(Thus my surprise when my application that worked without problems in 
Django 1.4 stopped working with Django 1.5.1, because the Formset 
factory was created as shown (with extra=0) and pruned to the default of 
1000 elements.)



You probably could open a ticket about that.


Well, recently I posted to the wrong list (a question that went 
unanswered here) and was promptly corrected (friendly, but firmly), so I 
rather wait a few more days if maybe someone else has additional info 
about this.


Best regards,
Carsten

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django 1.5.1 and formsets with more than 1000 initials

2013-04-24 Thread Xavier Ordoquy
Hi Carsten,

When you create your FormSet with formset_factory, the max_number is set to the 
max of 1000 and max_num.
The fact that you set a bigger number of initials doesn't affect this number.
I'm not sure whether the FormSet could extends itself this number if the 
initial_data is larger than 1000. You probably could open a ticket about that.

Please note that a more flexible workaround would be:
> >>> ArticleFormSet = formset_factory(ArticleForm, max_num=len(MyInitials), 
> >>> extra=0)


Regards,
Xavier Ordoquy,
Linovia.


Le 24 avr. 2013 à 21:42, Carsten Fuchs <carsten.fu...@cafu.de> a écrit :

> Hi all,
> 
> using Django 1.5.1, having read 
> <https://docs.djangoproject.com/en/1.5/topics/forms/formsets/#limiting-the-maximum-number-of-forms>,
>  I still have trouble creating a formset with more than 1000 initial forms:
> 
> Following the example at that page, what I'd like to do is, with MyInitials 
> being a list of e.g. 1500 initial values:
> 
> >>> ArticleFormSet = formset_factory(ArticleForm, extra=0)
> >>> formset = ArticleFormSet(initial=MyInitials)
> 
> Now, accessing formset.forms[1000] throws an IndexError exception.
> 
> I understand that this is related to the "Formset denial-of-service" issue 
> mentioned at https://www.djangoproject.com/weblog/2013/feb/19/security/, but 
> isn't max_num supposed to limited the number of *extra* formsets only?
> 
> It is relatively easy to work-around my original problem:
> 
> >>> ArticleFormSet = formset_factory(ArticleForm, max_num=3, extra=0)
> 
> but shouldn't a larger number of initials automatically extend the max_num?
> 
> Best regards,
> Carsten
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Django 1.5.1 and formsets with more than 1000 initials

2013-04-24 Thread Carsten Fuchs

Hi all,

using Django 1.5.1, having read 
<https://docs.djangoproject.com/en/1.5/topics/forms/formsets/#limiting-the-maximum-number-of-forms>, 
I still have trouble creating a formset with more than 1000 initial forms:


Following the example at that page, what I'd like to do is, with MyInitials being a list 
of e.g. 1500 initial values:


>>> ArticleFormSet = formset_factory(ArticleForm, extra=0)
>>> formset = ArticleFormSet(initial=MyInitials)

Now, accessing formset.forms[1000] throws an IndexError exception.

I understand that this is related to the "Formset denial-of-service" issue mentioned at 
https://www.djangoproject.com/weblog/2013/feb/19/security/, but isn't max_num supposed 
to limited the number of *extra* formsets only?


It is relatively easy to work-around my original problem:

>>> ArticleFormSet = formset_factory(ArticleForm, max_num=3, extra=0)

but shouldn't a larger number of initials automatically extend the max_num?

Best regards,
Carsten

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: cleaned_data returning empty in formsets

2013-04-09 Thread Tom Evans
On Tue, Apr 9, 2013 at 6:09 AM, Nora Olsen  wrote:
>
> The following snippet is returning an empty dictionary for the 2nd form:
>
> …
>
> How does initial work with data= in a formset?  Without the initial, there
> will be cleaned data for the 2nd form.
>

I see you found your error, but to answer the question above, it
behaves the same as a form - a form that is provided with both 'data'
and 'initial' will ignore 'initial', even if a field that is present
in 'initial' is missing in 'data'.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: cleaned_data returning empty in formsets

2013-04-08 Thread Nora Olsen
Just found the culprit:

'form-INITIAL_FORMS': u'1', it must be 2. 


On Tuesday, April 9, 2013 1:09:10 PM UTC+8, Nora Olsen wrote:
>
>
> The following snippet is returning an empty dictionary for the 2nd form:
>
>  
>
>> dct = {'form-0-attachment': u'',
>>  'form-0-id': u'1',
>>  'form-0-name': u'1',
>>  'form-1-attachment': u'',
>>  'form-1-id': u'2',
>>  'form-1-name': u'2',
>>  'form-INITIAL_FORMS': u'1',
>>  'form-MAX_NUM_FORMS': u'1000',
>>  'form-TOTAL_FORMS': 2}
>> PictureFormSet = formset_factory(PictureForm)
>> picture_formset = PictureFormSet(dct, None,
>>  initial = [ model_to_dict(a) for a in 
>> Picture.objects.filter(pk__in = [1,2])])
>> for form in picture_formset.forms:
>> if form.is_valid():
>> print form.cleaned_data
>> print '---'
>> Output:
>> {'id': 1, 'name': u'1', 'attachment': None}
>> ---
>> {}
>> ---
>
>
> How does initial work with data= in a formset?  Without the initial, there 
> will be cleaned data for the 2nd form.
>
> I'm trying to use self.changed_data in my form to determine whether which 
> value has changed.
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




cleaned_data returning empty in formsets

2013-04-08 Thread Nora Olsen

The following snippet is returning an empty dictionary for the 2nd form:

 

> dct = {'form-0-attachment': u'',
>  'form-0-id': u'1',
>  'form-0-name': u'1',
>  'form-1-attachment': u'',
>  'form-1-id': u'2',
>  'form-1-name': u'2',
>  'form-INITIAL_FORMS': u'1',
>  'form-MAX_NUM_FORMS': u'1000',
>  'form-TOTAL_FORMS': 2}
> PictureFormSet = formset_factory(PictureForm)
> picture_formset = PictureFormSet(dct, None,
>  initial = [ model_to_dict(a) for a in 
> Picture.objects.filter(pk__in = [1,2])])
> for form in picture_formset.forms:
> if form.is_valid():
> print form.cleaned_data
> print '---'
> Output:
> {'id': 1, 'name': u'1', 'attachment': None}
> ---
> {}
> ---


How does initial work with data= in a formset?  Without the initial, there 
will be cleaned data for the 2nd form.

I'm trying to use self.changed_data in my form to determine whether which 
value has changed.




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Understanding UpdateView with forms and formsets

2013-04-08 Thread Rainy
Sorry, I answered before reading your full message. It looks like you 
understand post loads the object in get_object(). I just want to add
that combined create/update can be done in different ways; I have
an implementation in mcbv.edit module but I'm not sure if it's the
best approach in all cases.

I don't think having two forms is a problem,
you can have one form for update and then inherit and modify as
needed for create.  -ak

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Understanding UpdateView with forms and formsets

2013-04-08 Thread Rainy




On Monday, April 8, 2013 12:22:34 PM UTC-4, Nora Olsen wrote:
>
> Hi,
>
> I'm a new user to Django. 
>
> I'm trying to understand how does an UpdateView works when during a POST. 
> Is there some state carried between the GET and POST, because I don't see 
> the pk in the form. How does the form save() knows that it should be 
> updating instead of inserting?
>
> The reason I'm asking is because I am having trouble trying to save a 
> formset that is used in a view together with the main form. I posted the 
> question on stackoverflow: 
> http://stackoverflow.com/questions/15877199/using-formset-with-contenttype
>
> I am trying to save Item with multiple Pictures in a single form.
>
> I can easily save the item form in the Post method of the view but I can't 
> save the formsets without the pk. In my template, I have the following:
>
> 
> {% for field in form %}
> # do something
> {% endfor %}
>
> {{ picture_formset.management_form }}
> {% for form in picture_formset.forms %}
> # do something
> {% endfor %}
> 
> 
>
>
> And my view:
>
>
> class ItemUpdateView(UpdateView):
>
> form_class = ItemCreateForm
> template_name = 'item/new.html'
> model = Item
> success_url = '/items/'
> def get_context_data(self, **kwargs):
> context = super(ItemUpdateView, self).get_context_data(**kwargs)
> item = context['object']
> # Dont' create any extra forms when showing an update view
> PictureFormSet = formset_factory(PictureForm, extra=0)
> return {'form': kwargs['form'],
> 'picture_formset': UploadFormSet(initial = [ 
> model_to_dict(a) for pic in item.pictures.all()])}
> def post(self, request, *args, **kwargs):
>self.object = self.get_object()
>item_form = ItemCreateForm(request.POST, instance=self.object)
>if item_form.is_valid():
>item = item_form.save(commit=False)
>item.save()
># How do I update the pictures? 
>
>
> I did manage to solve this by adding the pk as a HiddenWidget and 
> obtaining the Picture model before updating the keys/values and saving it.
>
> But I had to create 2 type of forms: with and without the pk for the 
> CreateView and UpdateView.
>
> Is this the correct approach? 
>


Hi Nora, the way it works is that it uses get_object() method to load the 
object; at the top of post() method,
it has the line: self.object = self.get_object().

If you need to use modelformset together with a form or modelform in one 
view, you might
want to look at my mcbv library; it has both a modelformset CBV and also 
allows to easily
combine different types of views together.

The portfolio tutorial has a good examples of doing just that: 
http://lightbird.net/dbe2/portfolio.html

mcbv library itself currently lives here: https://github.com/akulakov/django

 -ak

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Understanding UpdateView with forms and formsets

2013-04-08 Thread Nora Olsen
Hi,

I'm a new user to Django. 

I'm trying to understand how does an UpdateView works when during a POST. 
Is there some state carried between the GET and POST, because I don't see 
the pk in the form. How does the form save() knows that it should be 
updating instead of inserting?

The reason I'm asking is because I am having trouble trying to save a 
formset that is used in a view together with the main form. I posted the 
question on stackoverflow: 
http://stackoverflow.com/questions/15877199/using-formset-with-contenttype

I am trying to save Item with multiple Pictures in a single form.

I can easily save the item form in the Post method of the view but I can't 
save the formsets without the pk. In my template, I have the following:


{% for field in form %}
# do something
{% endfor %}

{{ picture_formset.management_form }}
{% for form in picture_formset.forms %}
# do something
{% endfor %}




And my view:


class ItemUpdateView(UpdateView):

form_class = ItemCreateForm
template_name = 'item/new.html'
model = Item
success_url = '/items/'
def get_context_data(self, **kwargs):
context = super(ItemUpdateView, self).get_context_data(**kwargs)
item = context['object']
# Dont' create any extra forms when showing an update view
PictureFormSet = formset_factory(PictureForm, extra=0)
return {'form': kwargs['form'],
'picture_formset': UploadFormSet(initial = [ 
model_to_dict(a) for pic in item.pictures.all()])}
def post(self, request, *args, **kwargs):
   self.object = self.get_object()
   item_form = ItemCreateForm(request.POST, instance=self.object)
   if item_form.is_valid():
   item = item_form.save(commit=False)
   item.save()
   # How do I update the pictures? 


I did manage to solve this by adding the pk as a HiddenWidget and obtaining 
the Picture model before updating the keys/values and saving it.

But I had to create 2 type of forms: with and without the pk for the 
CreateView and UpdateView.

Is this the correct approach? 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django inline formsets, force initial data to be saved.

2013-03-05 Thread Marc Aymerich
On Tue, Mar 5, 2013 at 4:43 PM, Marc Aymerich <glicer...@gmail.com> wrote:

>
>
> On Tue, Mar 5, 2013 at 3:11 AM, Russell Keith-Magee <
> russ...@keith-magee.com> wrote:
>
>>
>>
>> On Mon, Mar 4, 2013 at 10:31 PM, Marc Aymerich <glicer...@gmail.com>wrote:
>>
>>> Hi,
>>> I've spend several hours trying to figure out how to save inlines with
>>> initial data in them.
>>>
>>> basically I have a very simple model with 2 fields:
>>>
>>> class DirectIface(models.Model):
>>> parent = models.ForeignKey('nodes.Node')
>>> name = models.CharField(max_lenght=64)
>>>
>>> And what I'm doing is defining a formset with initial data in it:
>>>
>>>  class DirectIfaceInlineFormSet(BaseInlineFormSet):
>>> def __init__(self, *args, **kwargs):
>>> kwargs['initial'] = [{ 'name': 'eth1', }, {'name': 'eth2'},]
>>> super(DirectIfaceInlineFormSet, self).__init__(*args, **kwargs)
>>>
>>>
>>> In this case 2 Direct ifaces with names eth1 and eth2.
>>>
>>> The problem is that those ifaces doesn't get stored when I hit the save
>>> button, that's because has_changed == False.
>>> So is there a way to tell Django to save formsets with only initial data
>>> ?
>>>
>>
>> Sure - just provide the initial data as actual data. If, instead of using
>> 'initial', you pass the same content as 'data', the form will be saveable.
>>
>
> Jops, just tried
>
>
> class DirectIfaceInlineFormSet(BaseInlineFormSet):
> def __init__(self, *args, **kwargs):
> kwargs['data'] = [{ 'name': 'eth1', }, {'name': 'eth2'},]
> super(DirectIfaceInlineFormSet, self).__init__(*args, **kwargs)
>
> but I'm getting an AttributeError "'list' object has no attribute 'get'"
> when i'm rendering the form.
>


yeah, finally I did something like

class DirectIfaceInlineFormSet(BaseInlineFormSet):
def __init__(self, *args, **kwargs):
if not kwargs['instance'].pk:
kwargs['data'] = {
'direct_ifaces-TOTAL_FORMS': u'3',
'direct_ifaces-INITIAL_FORMS': u'0',
'direct_ifaces-MAX_NUM_FORMS': u'',
'direct_ifaces-0-name': u'eth0',
'direct_ifaces-1-name': u'eth1',
'direct_ifaces-2-name': u'eth2',}
else:
self.extra = 1
super(DirectIfaceInlineFormSet, self).__init__(*args, **kwargs)

that it works :)




-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django inline formsets, force initial data to be saved.

2013-03-05 Thread Marc Aymerich
On Tue, Mar 5, 2013 at 3:11 AM, Russell Keith-Magee <russ...@keith-magee.com
> wrote:

>
>
> On Mon, Mar 4, 2013 at 10:31 PM, Marc Aymerich <glicer...@gmail.com>wrote:
>
>> Hi,
>> I've spend several hours trying to figure out how to save inlines with
>> initial data in them.
>>
>> basically I have a very simple model with 2 fields:
>>
>> class DirectIface(models.Model):
>> parent = models.ForeignKey('nodes.Node')
>> name = models.CharField(max_lenght=64)
>>
>> And what I'm doing is defining a formset with initial data in it:
>>
>>  class DirectIfaceInlineFormSet(BaseInlineFormSet):
>> def __init__(self, *args, **kwargs):
>> kwargs['initial'] = [{ 'name': 'eth1', }, {'name': 'eth2'},]
>> super(DirectIfaceInlineFormSet, self).__init__(*args, **kwargs)
>>
>>
>> In this case 2 Direct ifaces with names eth1 and eth2.
>>
>> The problem is that those ifaces doesn't get stored when I hit the save
>> button, that's because has_changed == False.
>> So is there a way to tell Django to save formsets with only initial data ?
>>
>
> Sure - just provide the initial data as actual data. If, instead of using
> 'initial', you pass the same content as 'data', the form will be saveable.
>

Jops, just tried

class DirectIfaceInlineFormSet(BaseInlineFormSet):
def __init__(self, *args, **kwargs):
kwargs['data'] = [{ 'name': 'eth1', }, {'name': 'eth2'},]
super(DirectIfaceInlineFormSet, self).__init__(*args, **kwargs)

but I'm getting an AttributeError "'list' object has no attribute 'get'"
when i'm rendering the form.

http://dpaste.com/1013099/

What i've missed ?
Thanks again !




-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django inline formsets, force initial data to be saved.

2013-03-05 Thread Marc Aymerich
On Tue, Mar 5, 2013 at 3:11 AM, Russell Keith-Magee <russ...@keith-magee.com
> wrote:

>
>
> On Mon, Mar 4, 2013 at 10:31 PM, Marc Aymerich <glicer...@gmail.com>wrote:
>
>> Hi,
>> I've spend several hours trying to figure out how to save inlines with
>> initial data in them.
>>
>> basically I have a very simple model with 2 fields:
>>
>> class DirectIface(models.Model):
>> parent = models.ForeignKey('nodes.Node')
>> name = models.CharField(max_lenght=64)
>>
>> And what I'm doing is defining a formset with initial data in it:
>>
>>  class DirectIfaceInlineFormSet(BaseInlineFormSet):
>> def __init__(self, *args, **kwargs):
>> kwargs['initial'] = [{ 'name': 'eth1', }, {'name': 'eth2'},]
>> super(DirectIfaceInlineFormSet, self).__init__(*args, **kwargs)
>>
>>
>> In this case 2 Direct ifaces with names eth1 and eth2.
>>
>> The problem is that those ifaces doesn't get stored when I hit the save
>> button, that's because has_changed == False.
>> So is there a way to tell Django to save formsets with only initial data ?
>>
>
> Sure - just provide the initial data as actual data. If, instead of using
> 'initial', you pass the same content as 'data', the form will be saveable.
>

Thank you Russ, you've saved my day ! :)




-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Django inline formsets, force initial data to be saved.

2013-03-04 Thread Marc Aymerich
Hi,
I've spend several hours trying to figure out how to save inlines with
initial data in them.

basically I have a very simple model with 2 fields:

class DirectIface(models.Model):
parent = models.ForeignKey('nodes.Node')
name = models.CharField(max_lenght=64)

And what I'm doing is defining a formset with initial data in it:

class DirectIfaceInlineFormSet(BaseInlineFormSet):
def __init__(self, *args, **kwargs):
kwargs['initial'] = [{ 'name': 'eth1', }, {'name': 'eth2'},]
super(DirectIfaceInlineFormSet, self).__init__(*args, **kwargs)


In this case 2 Direct ifaces with names eth1 and eth2.

The problem is that those ifaces doesn't get stored when I hit the save
button, that's because has_changed == False.
So is there a way to tell Django to save formsets with only initial data ?

Thanks !

-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Tutorials for formsets using PKs as checkboxes

2013-02-08 Thread Rafael E. Ferrero
You can choose what widget use, one of them convert selectMultiple on
checkboxes 
(checkboxSelectMultiple<https://docs.djangoproject.com/en/dev/ref/forms/widgets/#checkboxselectmultiple>)
Hope to help you

See ya!

2013/2/8 David <davidwi...@adviserbreakthrough.co.uk>

> Hi
>
> Does anyone know of any good tutorials or guides for using formsets, with
> PKs as checkboxes? Something not to dissimilar to the functionality found
> in the django admin when listing records belonging to a model.
>
> I have tried looking through Django's code but can't find what I need.
>
> Thanks for any help
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Rafael E. Ferrero
Claro: (03562) 15514856

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Tutorials for formsets using PKs as checkboxes

2013-02-08 Thread David
Hi

Does anyone know of any good tutorials or guides for using formsets, with 
PKs as checkboxes? Something not to dissimilar to the functionality found 
in the django admin when listing records belonging to a model.

I have tried looking through Django's code but can't find what I need.

Thanks for any help

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Formsets and auto_id's

2013-02-07 Thread David
I've kinda managed to achieve what I want but I can't help but think it's a 
bit of a fudge:



Especially this part: form.id.html_name

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Formsets and auto_id's

2013-02-07 Thread David
Hi

I have a formset. Each form will only contain a checkbox. This checkbox 
needs to indicate which PK the form applies to.

The idea is that a user can scroll through this formset. Check which 
records they wish to delete and then remove them through a delete view.

auto_id's always seem to show as hidden fields and nothing I have tried 
changes this. Also how I can make sure that the checkbox value is the 
auto_id?

Thanks for any assistance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Django Formsets - How to build a formset correctly and validade it?

2013-01-11 Thread Andre Lopes
Hi all,

I'm struggling with Formsets. I've read the documentation and lots of
information on the web, but I'm experiencing some difficulties on get
them working.

I've wrote a StackOverflow question that explains my difficulties.

http://stackoverflow.com/questions/14280875/django-formsets-how-to-build-a-formset-correctly-and-validade-it

Can you give me some help on this one?

Best regards,
André

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



Re: Management form in Model Formsets

2012-07-01 Thread Knight Samar

Thanks Thomas! I checked the script and tried to follow it.

It seems that for Django 1.2, *not* modifying the form-TOTAL_FORMS, 
form-INITIAL_FORMS and form-MAX_NUM_FORMS works properly!! 

Regards,
Samar

On Sunday, 1 July 2012 22:12:37 UTC+5:30, Thomas Orozco wrote:
>
> You might want to check this snippet out: djangosnippets.org/snippets/1389
> */*
> Le 1 juil. 2012 06:27, "Knight Samar" <knightsa...@gmail.com> a écrit :
>
>> Hi,
>>
>> I am using Django 1.2 and developing using Model formsets. Using 
>> JavaScript, I am allowing the user to dynamically "Add another" formset on 
>> the template, but I can't figure out what exactly I have to modify in the 
>> management forms, for all the formsets to be successfully saved.
>>
>> The documentation points out to three properties in the management form - 
>> form-TOTAL_FORMS, form-INITIAL_FORMS and form-MAX_NUM_FORMS. But I don't 
>> understand, which properties I have to exactly modify and how, when a new 
>> formset is being added dynamically using JavaScript ?
>>
>> Thanks :)
>>
>> Regards,
>> Samar
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/Ecs6EVDku_YJ.
>> 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 view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/0MFh_Lo5aDEJ.
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.



Re: Management form in Model Formsets

2012-07-01 Thread Thomas Orozco
You might want to check this snippet out: djangosnippets.org/snippets/1389*/
*
Le 1 juil. 2012 06:27, "Knight Samar" <knightsa...@gmail.com> a écrit :

> Hi,
>
> I am using Django 1.2 and developing using Model formsets. Using
> JavaScript, I am allowing the user to dynamically "Add another" formset on
> the template, but I can't figure out what exactly I have to modify in the
> management forms, for all the formsets to be successfully saved.
>
> The documentation points out to three properties in the management form -
> form-TOTAL_FORMS, form-INITIAL_FORMS and form-MAX_NUM_FORMS. But I don't
> understand, which properties I have to exactly modify and how, when a new
> formset is being added dynamically using JavaScript ?
>
> Thanks :)
>
> Regards,
> Samar
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/Ecs6EVDku_YJ.
> 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.



Management form in Model Formsets

2012-06-30 Thread Knight Samar
Hi,

I am using Django 1.2 and developing using Model formsets. Using 
JavaScript, I am allowing the user to dynamically "Add another" formset on 
the template, but I can't figure out what exactly I have to modify in the 
management forms, for all the formsets to be successfully saved.

The documentation points out to three properties in the management form - 
form-TOTAL_FORMS, form-INITIAL_FORMS and form-MAX_NUM_FORMS. But I don't 
understand, which properties I have to exactly modify and how, when a new 
formset is being added dynamically using JavaScript ?

Thanks :)

Regards,
Samar

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Ecs6EVDku_YJ.
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.



labels for check-boxes in formsets?

2012-06-06 Thread matru...@googlemail.com
Hey,

currently, I puzzling on a solution to do the following:

I've got a list of objects defined by a model, e.g persons. I'd like
to put a form together to select some of those objects to do something
with them (e.g. send an email).

The view, which should be created is something like in the admin site.
Reading the code from admin site didn't help me to accomplish that
task.

Do you have suggestions for me?
Thanks

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



Re: Struggling with formsets

2012-05-29 Thread akaariai
On May 29, 12:45 pm, David <davidwi...@adviserbreakthrough.co.uk>
wrote:
> Anyone else have any suggestions please?
>
> Thank you

I don't think there is a way to create formsets, and then formsets
related to the first formsets. So, something like this is what you
likely need:

for p in persons:
do_what_you_did_for_single_object() # remember to prefix the
forms.

I would likely do a list persons + their attendances view with edit
link/button for each person. That is one approach worth considering,
as it is pretty easy to do.

 - Anssi

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



Re: Struggling with formsets

2012-05-29 Thread David
Anyone else have any suggestions please?

Thank you

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/-8zgkyBbFBoJ.
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.



Re: Struggling with formsets

2012-05-18 Thread David
Thanks Pedesen for your reply.

I have tried inline-formsets and as you say unfortunately I could only get 
it to work with a single object.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/LVLBaUUdY8MJ.
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.



Re: Struggling with formsets

2012-05-18 Thread pedesen
For this case inline-formsets should be the way to go: 
https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#inline-formsets
But I think this will work for a particular person, but not for multiple 
persons...

Am Freitag, 18. Mai 2012 15:27:05 UTC+2 schrieb David:
>
> Given 2 models:
>
> class Person(models.Model):
> first_name = models.CharField(max_length=255)
> last_name = models.CharField(max_length=255)
>
> class PersonAttendance(models.Model):
> person = models.ForeignKey(Person)
> attend_date = models.DateField()
>
> I need to produce a formset that lists all Person(s) and their 
> PersonAttendance if it has been entered, and blank fields for Persons that 
> have no PersonAttendance related record so their attendance can be filled 
> in.
>
> In SQL I guess this would be achieved using a LEFT JOIN on Person, but I 
> can't work out how to get this working with the ORM and Django Formsets.
>
> Any help would be greatly appreciated, I've been stumped on this for ages.
>
> Thank you
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/aZuOiHNhGcEJ.
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.



Struggling with formsets

2012-05-18 Thread David
Given 2 models:

class Person(models.Model):
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)

class PersonAttendance(models.Model):
person = models.ForeignKey(Person)
attend_date = models.DateField()

I need to produce a formset that lists all Person(s) and their 
PersonAttendance if it has been entered, and blank fields for Persons that 
have no PersonAttendance related record so their attendance can be filled 
in.

In SQL I guess this would be achieved using a LEFT JOIN on Person, but I 
can't work out how to get this working with the ORM and Django Formsets.

Any help would be greatly appreciated, I've been stumped on this for ages.

Thank you

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/2dRj9IjQwO4J.
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.



Re: Altering object order in formsets with can_order

2012-05-06 Thread Boris Shemigon
The best I've found is this <http://stackoverflow.com/a/8417283/187171>.


On Wednesday, May 5, 2010 11:56:02 PM UTC+7, palmeida wrote:
>
> Hi,
>
> I'm having a hard time grasping the concept of the can_order argument, 
> when creating formsets. Once objects are created and saved through the 
> formset, is it possible to reorder them? Where does the order information 
> get stored? I tried just adding can_order=True when creating the formset 
> (it's an inline_formset) and the order fields do show up on the form, but 
> they don't seem to have any effect. I'm just saving the formset. Should I 
> use "formset.ordered_forms" to sort them and then save each one 
> individually?
>
> I really need to be able to reorder after saving, because some of these 
> objects are being created outside forms and I want the users to reorder 
> them if they want to. If that is not possible with can_order, I think an 
> easy way to do it would be to have an extra variable in that model, storing 
> the order (in the form it would work just like the fields created by 
> can_order). Does that sound reasonable?
>
> Thanks for any help,
> Paulo Almeida
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/FZ-bC1LBZmsJ.
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.



ListView, Formsets and Model formsets

2012-05-02 Thread Steve Kilbane
I'm sure I'm missing something obvious here...

I want to produce a form which is a list of objects in my model, with
a checkbox to select some of the objects, so that the posted data is
the list of selected objects. Just like you get on the listviews in
the admin interface, in fact.

It seems like formsets are the solution here, but neither Formset nor
ModelFormset seems to be quite right: I want a reference to my
original model, so that each form in the set is related to an object,
but I don't want *any* of the model's fields in the form - just the
checkbox. Nor do I want a database table with ForeignKeyField/
BooleanField columns - this is just transitory.

I'm sure this should be trivial, if I just squint at it right.

Thanks,

steve

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



How to do form validation for inline formsets?

2012-04-18 Thread Derek
Working with Django 1.3

I can create and run an inline formset without problems using Approach 1.
 However, when I try Approach 2, then I get the error below, triggered by
the line shown.

TypeError at /uploads/details/1
__init__() got an unexpected keyword argument 'instance'

Clearly, my syntax is wrong somewhere, but how do I go about fixing this?

Thanks
Derek


Approach No.1 - NO validation

# view file

UploadFieldFormSet = inlineformset_factory(Upload, UploadField,
max_num=None,
extra=9, can_delete=False)
if request.method == 'POST':
...
else:
formset = UploadFieldFormSet(instance=upload)


Approach No. 2 - Form validation

# form file

class UploadFieldFormSet(BaseFormSet):

def clean(self):
if any(self.errors):
return
# need to add special checks here...

# view file

UploadFieldFormSetFactory = inlineformset_factory(Upload, UploadField,

formset=UploadFieldFormSet,
  max_num=None,
  extra=9,
can_delete=False)
if request.method == 'POST':
...
else:
formset = UploadFieldFormSetFactory(instance=upload)  # returns
error

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



Need help with Django formsets

2012-04-11 Thread BeriK
I'm making a survey site with django. I am pretty newbie with django
so I apologize in advance if I can not explain well. My question
focuses on the following models:

class SurveyType(models.Model):

name = models.CharField(max_length=200)

def __unicode__(self):
return self.name

class Question(models.Model):

ANSWERTYPE_CHOICES = (
(u'T', u'Text'),
(u'R', u'Range'),
(u'M', u'Media'),
)

question = models.CharField(max_length=200)

surveytype = models.ForeignKey(SurveyType)

answertype = models.CharField(max_length=1,
choices=ANSWERTYPE_CHOICES)

order = models.IntegerField(default=0)

def __unicode__(self):
return self.question


class Survey(models.Model):

course = models.ForeignKey(Course)

surveytype = models.ForeignKey(SurveyType)

def __unicode__(self):
return u"%s %s" % (self.course, self.surveytype)

class Answer(models.Model):

answer = models.CharField(max_length=400)

survey = models.ForeignKey(Survey)

question = models.ForeignKey(Question)

def __unicode__(self):
return self.answer


Django receives survey id. With the survey id it gets the surveytype
and shows questions that must be displayed.

def survey(request, survey_id):
survey_data = get_object_or_404(Survey, pk=survey_id)
survey_type = survey_data.surveytype
questions = Question.objects.all().filter(surveytype =
survey_type).order_by('order')


I have read the django documentation about formsets but I don't
understand what I have to write in forms.py, so I can't call the form
in views.py to render de form in the template that shows the questions
and write the answers in the answer model.

Thanks in advance and sorry for my english.

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



Re: Nested formsets at Django 1.3

2011-11-08 Thread Ilya
The validation error happens when the formset is passed an empty 
dictionary. The docs (release notes for 1.3) suggest passing None instead. 
So doing this should fix the problem:
>
> TenantFormset(data=self.data or None, instance=instance, 
prefix='TENANTS_%s' % pk_value)

In my case, which is similar to Nathan's, this made the validation error to 
go away.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ZHnO7qM0OJoJ.
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.



Re: Nested formsets at Django 1.3

2011-07-31 Thread Kev Dwyer
Kev Dwyer wrote:

> Hello List,
> 
> I've been upgrading an old Django 1.1.x app to use Django 1.3, and am
> having a problem with nested formsets.
> 
...
> 
> 
> 
I omitted one important fact in this write-up.  In Nathan's original code, 
the lowest level formset is created like this:

TenantFormset(data=self.data,
  instance=instance,
  prefix='TENANTS_%s' % pk_value)

where instance is an instance of Building, the "parent" or container 
for tenants and self is an instance of 

class BaseBuildingFormset(BaseInlineFormSet)

which is instantiated like this:

BuildingFormset = inlineformset_factory(models.Block,
models.Building,
formset=BaseBuildingFormset,
extra=1)

I omitted to mention that to get around this I stopped passing in self.data, 
which led to the behaviour that I described in my original post.  Apologies 
if this misled anyone.

Up to Django 1.2.5, Nathan's code works fine.  However at 1.3, if self.data 
is passed to TenantFormset, it turns out to be empty and a ValidationError 
is raised because the ManagementForm information has not been supplied.  
This is the intended consequewnce of #11418, AFAICT.

Working on the assumption that self.data should contain the 
ManagementForm data I've tried populating it with said data, but 
ValidationError is still raised.

My use case is slightly simpler than Nathan's example as I just need to edit 
existing objects, so I'm going to try populating the formsets using 
querysets rather than instances.

Does anyone have any other ideas on how this might be made to work?  

Cheers,

Kev

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



Nested formsets at Django 1.3

2011-07-30 Thread Kev Dwyer
Hello List,

I've been upgrading an old Django 1.1.x app to use Django 1.3, and am 
having a problem with nested formsets.

The structure of my formsets is based on the structure outline in 
Nathan Yerger's blog post http://yergler.net/blog/2009/09/27/nested-
formsets-with-django/, i.e. I have a grandparent object with a one to 
many relation to its child objects, and each of these child objects has 
a one to many relation to its children.

This worked fine in Django 1.1.x, but at 1.3 the forms in the lowest 
layer always have is_bound = False, even after being rendered and 
POSTed back to the view.  Consequently validation always fails and the 
objects that the forms represent cannot be updated.  I've reproduced 
the behaviour using the code from Nathan's blog post, so it seems that 
this approach to nesting formsets is no longer valid, or the code needs 
a tweak to work at 1.3.

Has anyone successfully used Nathan's code at 1.3, or is anyone able to 
point me towards a nested formset implementation that works at this 
release?

(Sorry about the absence of code examples - Nathan's post is much 
clearer than my code, so I'd recommend you look at that.)

Cheers,

Kev 



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



Re: [formsets] Initial Values to an inline_formset() instance

2011-06-17 Thread Nikhil Somaru
Hi,

This is the hack-a-round that I figured out:

formset = OrderFormset(request.POST) #created earlier with inline_formset()
# now we recreate it to have the submitted number of forms+3
OrderFormset = inlineformset_factory(Order, OrderItem,
extra=len(formset.forms)+3)
formset = OrderFormset()
# populate the forms
# initial_data is a list of dictionaries created from POST data
# dict keys are field names
for subform, data in zip(formset.forms, initial_data):
subform.initial = data

I know this is inelegant and probably uses more memory than it should, but
it works. Are there any other, more elegant solutions?

On Fri, Jun 17, 2011 at 3:38 PM, Nikhil Somaru <nsom...@gmail.com> wrote:

> Hi,
>
> PURPOSE: Mimic the admin "inline" functionality (with 
> ForeignKeyrelationships) in one of my own forms without using Javascript 
> (because I
> don't know it)
>
> My Solution: Inline Formset via inline_formset()
>
> However,
>
>- inline_formset() does not accept initial as an argument
>- This is after the form has been submitted once and I want to create
>new forms in the formsets while still keeping the data already entered,
>waiting to be edited
>
> I am using the following workaround in the mean time: (the entire view may
> be found here: http://dpaste.com/hold/555463/)
>
> elif 'more_items' in request.POST:
> order = form.save(commit=False) # models.Order
> instances = formset.save(commit=False) # models.OrderItem(s)
> for instance in instances:
> initial_data.append({'item': instance.item,
>  'quantity_requested':
> instance.quantity_requested,
>  }
> )
> formset = OrderFormset() #created via inline_formset()
> for subform, data in zip(formset.forms, initial_data):
> subform.initial = data
> # render_to_response
>
> The problem is, this limits me to a total number of forms as defined in the
> extra field passed to inline_formset().
>
> Any improvements or totally new solutions are welcome! My Python/Django
> knowledge is beginner-intermediate (leaning towards beginner)
>
> --
> Yours,
> Nikhil Somaru
>
>


-- 
Yours,
Nikhil Somaru

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



[formsets] Initial Values to an inline_formset() instance

2011-06-17 Thread Nikhil Somaru
Hi,

PURPOSE: Mimic the admin "inline" functionality (with
ForeignKeyrelationships) in one of my own forms without using
Javascript (because I
don't know it)

My Solution: Inline Formset via inline_formset()

However,

   - inline_formset() does not accept initial as an argument
   - This is after the form has been submitted once and I want to create new
   forms in the formsets while still keeping the data already entered, waiting
   to be edited

I am using the following workaround in the mean time: (the entire view may
be found here: http://dpaste.com/hold/555463/)

elif 'more_items' in request.POST:
order = form.save(commit=False) # models.Order
instances = formset.save(commit=False) # models.OrderItem(s)
for instance in instances:
initial_data.append({'item': instance.item,
 'quantity_requested':
instance.quantity_requested,
 }
)
formset = OrderFormset() #created via inline_formset()
for subform, data in zip(formset.forms, initial_data):
subform.initial = data
# render_to_response

The problem is, this limits me to a total number of forms as defined in the
extra field passed to inline_formset().

Any improvements or totally new solutions are welcome! My Python/Django
knowledge is beginner-intermediate (leaning towards beginner)

-- 
Yours,
Nikhil Somaru

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



Dynamic Nested Formsets?

2011-06-10 Thread Sontek
I have 3 Models:

class Workflow(models.Model):
name = models.CharField(max_length=255)
company = models.ForeignKey(Company)
class Meta:
unique_together = ('name', 'company')

class Milestone(models.Model):
workflow = models.ForeignKey(Workflow)
tasks = models.ManyToManyField(Task)

class Task(models.Model):
task = models.CharField(max_length=255)

How could I create a form that allows me to add many milestones to a
workflow and many tasks to a milestone?

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



Embedded Inline Formsets

2011-05-28 Thread John Anderson
I have 3 Models:

class Workflow(models.Model):
name = models.CharField(max_length=255)
company = models.ForeignKey(Company)

class Meta:
unique_together = ('name', 'company')

class Milestone(models.Model):
workflow = models.ForeignKey(Workflow)
tasks = models.ManyToManyField(Task)

class Task(models.Model):
task = models.CharField(max_length=255)


How could I create a form that allows me to add multiple milestones with 
multiple tasks?


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



Multiple formsets in a view

2011-05-22 Thread ekms
Hello,

in my view, I create dinamically multiple formsets, and I put a
dinamic prefix to all of them (ex, formset1, formset2, ...), then I
pack all the formsets in a list and pass it to the template.

Later, how I can retrieve all the formsets from request.POST? I know
that I've to do something like this:

formset = formset_factory(myFormset, prefix='myprefix')

there's a way to iterate over all the formsets of request.POST, and
get the prefix of them?

Or the only way to do this is to pass a hidden field to the form
containing the number of formsets, and then in the POST, check it and
use that number as the variable part of the prefix?

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



Re: Formsets and new 1.3 class based views

2011-05-11 Thread Iván Raskovsky
BTW you can find some example views and how to use them in the tests!
Iván

On Wed, May 11, 2011 at 3:50 PM, DK <cypre...@gmail.com> wrote:
> Fantastic piece of work. I will try to dive into.
> DK
>
> On May 11, 8:02 pm, Iván Raskovsky <raskov...@gmail.com> wrote:
>> On Wed, May 11, 2011 at 1:29 PM, DK <cypre...@gmail.com> wrote:
>> > What is a proper way to handle formsets with new class based views?
>> > Should I use standard forms views like CreateView, I did not saw any
>> > views dedicated to handle formsets.
>>
>> Hi DK. I've faced the same issue some weeks ago, and I decided to make
>> my own CBV to handle formsets, modelformsets and inlines :)
>>
>> I haven't released them yet, cause I haven't had the proper time to
>> document them, but the code is full of docstrings and commentaries and
>> I'm using them in production. You can find them in my github repo[0].
>>
>> I think you'll find them easy enough to understand, but if you have
>> any doubts you can query me on #django or email me. Of course any
>> issue report or pull request is more than welcome!
>>     Iván
>>
>> [0]https://github.com/rasca/django-enhanced-cbv
>
> --
> 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.



  1   2   3   >