I'm new to Dojo and Django. That said, I'm trying to write a single-page app and I do not understand how to leverage Django's built-in authentication tools since they are designed around the traditional Django page-per view model.
I'd like to have all forms, both specific to my app and for auth and django-registration displayed in the <div dojoType="dijit.layout.contentPane" id="mainPane"></div>
. I have mastered getting views rendered as Dojango's @json_response
to display; however, I do not know how to "wrap" existing views so that they do not expect page loads.
Is there any conventional strategy for single-page Django apps? I like Django's ORM and Dojo's UI, but they seem to be difficult to fully integrate. Thanks.
##############################################################
# # # #
# LOGOUT # # DISP #
# ########################################## #
# REGSTR # # DISP #
# # MAINPANE # #
# DO_IT # # DISP #
# # Forms, views, etc. # #
# CNTRL # using dojo.xhrGET, xhrPUT # DISP #
# # # #
# QUIT # # DISP #
# # # #
# ########################################## DISP #
# # # #
# # STATUS: MESSAGE # #
# # # #
##############################################################
Edit: Just to be more explicit, I want a flow like this:
- User clicks "DO_IT" button.
- Dojo xhrGETs the DO_IT form and replaces MAINPANE's content with it.
- User does something with DO_IT form and dojo xhrPOSTs the user's action.
- Dojo replaces the content of MAINPANE with the response.
- Profit
What is the best/conventional/common/most-documented way of accomplishing this. I know that there are likely many possible approaches. I'm looking for something that is less easy to f@#$-up as a novice.
You've pretty much spelt it out. The django view can just return the chunk of HTML that you want in the #MAINPANE div, and you insert it by setting the MAINPANE node's .innerHTML property.
Once the user has logged in all the authentication should happen automagically even to Ajax calls, so you don't have to worry about that. But you do have to consider what happens if the authentication fails - you could end up just dumping a 403 Permission Denied message into your #MAINPANE div.
There's a few other subtleties to this kind of web page design - mostly it becomes impossible to bookmark pages unless you provide a 'permalink' link somewhere that gets you to the page with the required content loaded into the MAINPANE div. And hitting reload in the browser causes surprise when it doesn't reload the current view of the page but jumps back to the 'home' view.
Or you could just do it the old skool way with FRAME tags :)