|
Bonus posted:On our Django project, we're using jQuery and stuff works out just fine. You make views that serve the data that's requested asynchronously and then just write the jQuery to call them. Like king_kilr said, you can also use Django's serialization features in the views that are served up asynchronously. I like either serializing stuff into JSON and then reading it with the javascript or just directly sending html. Funnily enough I'm working on that now in our app, but I've hit an issue. The problem is when making a Ajax request, when I load a view because it extends the template above it and it loads in the whole page and not just the fragment. I tried to pass a view variable from request.is_ajax() and put a {% if %} tag around the extend, it doesn't work - so what I'm having to do is create two versions of the same template, one without the extend. It seems very anti-DRY, but I can find any other solution to it.
|
# ¿ Mar 23, 2008 12:52 |
|
|
# ¿ Apr 28, 2024 12:58 |
|
Yea, I think I've kinda got it now - it's still a bit messy, but I had to fix some inheritance and I have my AJAX fragments which contain my login, and my non-ajax stuff too. It's starting to work out. It's a pity, as some PHP frameworks I've used are able to handle this no problem :/
|
# ¿ Mar 23, 2008 20:54 |
|
The last Django application I worked on was in 0.96 and I'm trying to get used to the new stuff in there. I've been following the docs here: http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#id2 trying to use the formset_factory on some forms. I have a Contact model, and associated through a FK it has several ContactNumber and ContactEmail instances. I've used ModelForm to create the forms and it works successfully if I just have one instance of the number and email, but when I try to create a formset for it, I get this problem: 'ContactNumberFormFormSet' object has no attribute 'save' But as far as I can see, I've followed the docs correctly?? I've pasted the code for my model, form and view below: Contact,ContactNumber,ContactEmail models: http://paste.ifies.org/158 Forms: http://paste.ifies.org/161 View: http://paste.ifies.org/160 Any help on this would be appreciated
|
# ¿ Nov 16, 2008 23:32 |