1

DojoとDjangoは初めてです。とはいえ、私はシングルページアプリを作成しようとしていますが、Djangoの組み込み認証ツールは従来のDjangoページごとのモデルを中心に設計されているため、それらを活用する方法がわかりません。

アプリに固有のフォームと、認証とdjango-registrationの両方のフォームをに表示したいと思います<div dojoType="dijit.layout.contentPane" id="mainPane"></div>。Dojangoとしてレンダリングされたビュー@json_responseを表示する方法をマスターしました。ただし、ページの読み込みを予期しないように既存のビューを「ラップ」する方法がわかりません。

シングルページDjangoアプリの従来の戦略はありますか?DjangoのORMとDojoのUIは好きですが、完全に統合するのは難しいようです。ありがとう。

##############################################################
#         #                                        #         #
#  LOGOUT #                                        #  DISP   #
#         ##########################################         #
#  REGSTR #                                        #  DISP   #
#         #  MAINPANE                              #         #
#  DO_IT  #                                        #  DISP   #
#         #  Forms, views, etc.                    #         #
#  CNTRL  #  using dojo.xhrGET, xhrPUT             #  DISP   #
#         #                                        #         #
#  QUIT   #                                        #  DISP   #
#         #                                        #         #
#         ##########################################  DISP   #
#         #                                        #         #
#         # STATUS: MESSAGE                        #         #
#         #                                        #         #
##############################################################

編集:より明確にするために、私は次のようなフローが必要です:

  1. ユーザーが「DO_IT」ボタンをクリックします。
  2. DojoはDO_ITフォームをxhrGETし、MAINPANEのコンテンツをそれに置き換えます。
  3. ユーザーはDO_ITフォームを使用して何かを実行し、dojoxhrPOSTはユーザーのアクションを実行します。
  4. Dojoは、MAINPANEのコンテンツを応答に置き換えます。
  5. 利益

これを達成するための最良の/従来の/一般的な/最も文書化された方法は何ですか。考えられるアプローチはたくさんあると思います。初心者としてf@#$-upするのが簡単ではないものを探しています。

4

1 に答える 1

1

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

于 2011-10-30T17:10:31.197 に答える