Re: How to make a dynamic list in Django
Hello
With this sort of problem it depends on the dimensions of your data. What kind of data is associated with a user? Is this just editing a user profile like the built in django 'user' or is there a lot more?My approach to this sort of stuff is a straightfoward initial HTTP response with your template code, the javascript variables are placed into the page with your template engine. Hence your comment about having a list (presumably some sort of javascript array that you can work with).
Subsequent changes to the data are gone with AJAX methods in your javascript to create, delete, update your data structure accordingly.
This is done by using django forms to clean() your fields. You may want to look at passing ajax to the server and handling it with formsets if the user is repeating input a variable number of times:
https://docs.djangoproject.com/en/1.6/topics/forms/formsets/
https://docs.djangoproject.com/en/1.6/topics/forms/formsets/
Eg: if you're just beginning using jquery perhaps look at some of the examples on stackoverflow make a few test examples using ajax GET and POST.
The premise behind this is you want the user to make changes that are saved as he/she progresses. Hence instantiating a method in javascript that serializes a form and sends it to your server which does all the usual form validation sends back any errors which are handled by your method to produce success/failure.
http://stackoverflow.com/questions/14099038/an-easy-way-to-submit-django-forms-using-ajax-jquery
The premise behind this is you want the user to make changes that are saved as he/she progresses. Hence instantiating a method in javascript that serializes a form and sends it to your server which does all the usual form validation sends back any errors which are handled by your method to produce success/failure.
http://stackoverflow.com/questions/14099038/an-easy-way-to-submit-django-forms-using-ajax-jquery
Hope this helps
cheers
sam
On Fri, Jan 10, 2014 at 2:44 PM, Frank Jaworski <fdjphoenix1984@gmail.com> wrote:
Hello,--Essentially I am trying to take some pre-existing data for a user, populate a "list" with it, and then add/delete any item I wish from that list and display cost and other information for the updated list. I don't want page reloading or anything like that. I know the concept of ajax/jQuery but am not sure how to incorporate it into this type of design. 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+unsubscribe@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/63adb88c-5e11-46b9-b3ee-68e42a5b27e3%40googlegroups.com.
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+unsubscribe@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/CAMbLS2_q3Sb2cqcT%2BN0NhfhrmzeQTbjdo6S-5UGFLqUifTicYA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home