My favorites | Sign in
Project Logo
                
Search
for
Updated Sep 19, 2008 by tobias.klipstein
GettingStarted  
Help - How to install, setup and get the dojango test page running - in only two steps!

Introduction

Dojango is a reusable django application that helps you to use the client-side framework dojo within your django project. It provides capabilites to easily switch between several dojo versions and sources (e.g. aol, google, local) and delivers helping utilities, that makes the development of rich internet applications in combination with dojo more comfortable. Also it makes the building of your own packed dojo release easier. Another goal of this project is, that you can learn how you have to structure your html to use dojo within your projects.

Start your first dojango driven django project

This section describes, how you integrate dojango on the basis of a newly created django project. Django with at least version >= 1.0 must be installed before to run dojango successfully. Details how you install django can be found here:

http://www.djangoproject.com/download/

http://www.djangoproject.com/documentation/install/

Start an empty project

Type the following on your console to create an empty django project:

django-admin.py startproject mysite

1. Add dojango as app to your project

Download the dojango-xxx.tar.gz from the google code page and place it in your previously created django project directory and extract it there:

cd mysite
tar xzvf dojango-xxx.tar.gz

You could also use an actual subversion checkout from googlecode and place it in your mysite directory:

cd mysite
svn checkout http://dojango.googlecode.com/svn/trunk/dojango

After that you can enable the dojango app by defining the following in your project's settings file (mysite/settings.py):

INSTALLED_APPS = (
    ...
    'dojango',
)

2. Enable the dojango URLs

To deliver the media files you also have to add the URL definitions of dojango to your main URL defintion file (mysite/urls.py):

urlpatterns = patterns('',
...
(r'^dojango/', include('dojango.urls')),
)

Consider, that if you want to set a different base pattern than ''dojango'', you should also modify the DOJANGO_BASE_MEDIA_URL setting.

Now you are ready to start your django server:

./manage.py runserver

Open the dojango test page:

http://localhost:8000/dojango/test/

And enjoy dojo :-)


Comment by alatar.azul, Sep 05, 2008

Hi. Im only a newbie in web development, im just starting. I tried to follow your instructions and i have this error:

  • /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/handlers/base.py in get_response
  • 61. return response 62. 63. # Get urlconf from request object, if available. Otherwise use default. 64. urlconf = getattr(request, "urlconf", settings.ROOT_URLCONF) 65. 66. resolver = urlresolvers.RegexURLResolver(r'^/', urlconf) 67. try: 68. callback, callback_args, callback_kwargs = resolver.resolve(request.path) ... 69. 70. # Apply view middleware 71. for middleware_method in self.view_middleware: 72. response = middleware_method(request, callback, callback_args, callback_kwargs) 73. if response: 74. return response
    ▶ Local vars Variable Value debug <module 'django.views.debug' from '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/views/debug.pyc'> exceptions <module 'django.core.exceptions' from '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/exceptions.pyc'> mail_admins <function mail_admins at 0xdfeb30> middleware_method <bound method AuthenticationMiddleware?.process_request of <django.contrib.auth.middleware.AuthenticationMiddleware? object at 0xe01610>> request <WSGIRequest GET:<MultiValueDict?: {}>, POST:<MultiValueDict?: {}>, COOKIES:{}, META:{'Apple_PubSub_Socket_Render?': '/tmp/launch-zsSUxd/Render', 'COMMAND_MODE': 'unix2003', 'CONTENT_LENGTH': '', 'CONTENT_TYPE': 'text/plain', 'DISPLAY': '/tmp/launch-TOY5Fu/:0', 'DJANGO_SETTINGS_MODULE': 'mysite.settings', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HOME': '/Users/Alatar', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,;q=0.7', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'es-es,es;q=0.8,en-us;q=0.5,en;q=0.3', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_HOST': 'localhost:8000', 'HTTP_KEEP_ALIVE': '300', 'HTTP_REFERER': 'http://code.google.com/p/dojango/wiki/GettingStarted', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; es-ES; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1', 'LANG': 'es_ES.UTF-8', 'LOGNAME': 'Alatar', 'MANPATH': '/usr/share/man:/usr/local/share/man:/usr/X11/man', 'OLDPWD': '/Users/Alatar/Desktop', 'PATH': '/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Library/PostgreSQL8/bin:/opt/local/bin', 'PATH_INFO': '/dojango/test/', 'PWD': '/Users/Alatar/Desktop/mysite', 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_HOST': '', 'REQUEST_METHOD': 'GET', 'RUN_MAIN': 'true', 'SCRIPT_NAME': '', 'SECURITYSESSIONID': 'b2e130', 'SERVER_NAME': 'localhost', 'SERVER_PORT': '8000', 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.5.2', 'SHELL': '/bin/bash', 'SHLVL': '1', 'SSH_AUTH_SOCK': '/tmp/launch-8GQWw3/Listeners', 'TERM': 'xterm-color', 'TERM_PROGRAM': 'Apple_Terminal?', 'TERM_PROGRAM_VERSION': '240', 'TMPDIR': '/var/folders/ve/ve788NuoFAi8+eUQvt-lI++++TI/-Tmp-/', 'TZ': 'America/Chicago', 'USER': 'Alatar', '': '/Library/Frameworks/Python.framework/Versions/Current/bin/python', 'CF_USER_TEXT_ENCODING': '0x1F5:0:86\n', 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x160b0>, 'wsgi.file_wrapper': <class 'django.core.servers.basehttp.FileWrapper?'>, 'wsgi.input': <socket.fileobject object at 0xdc2470>, 'wsgi.multiprocess': False, 'wsgi.multithread': True, 'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 0)}> resolver <django.core.urlresolvers.RegexURLResolver object at 0xe01af0> response None self <django.core.handlers.wsgi.WSGIHandler object at 0xbdc7f0> settings <django.conf.LazySettings? object at 0x95cb90> urlconf 'mysite.urls' urlresolvers <module 'django.core.urlresolvers' from '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.pyc'>
  • /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py in resolve
    1. 5. def resolve(self, path):
    2. 6. tried =
    3. 7. match = self.regex.search(path)
    4. 8. if match:
    5. 9. new_path = pathmatch.end():?
    6. 0. for pattern in self.urlconf_module.urlpatterns:
    7. 1. try:
    8. 2. sub_match = pattern.resolve(new_path) ...
    9. 3. except Resolver404, e:
    10. 4. tried.extend(+ ' ' + t) for t in e.args[0?'tried'?])
    11. 5. else:
    12. 6. if sub_match:
    13. 7. sub_match_dict = dict(self.default_kwargs, sub_match2?)
    14. 8. return sub_match0?, sub_match1?, dict(match.groupdict(), sub_match_dict)
    ▶ Local vars Variable Value match <sre.SRE_Match object at 0xe06170> new_path 'dojango/test/' path '/dojango/test/' pattern <django.core.urlresolvers.RegexURLResolver object at 0xe01d90> self <django.core.urlresolvers.RegexURLResolver object at 0xe01af0> tried
  • /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py in resolve
    1. 5. def resolve(self, path):
    2. 6. tried =
    3. 7. match = self.regex.search(path)
    4. 8. if match:
    5. 9. new_path = pathmatch.end():?
    6. 0. for pattern in self.urlconf_module.urlpatterns:
    7. 1. try:
    8. 2. sub_match = pattern.resolve(new_path) ...
    9. 3. except Resolver404, e:
    10. 4. tried.extend(+ ' ' + t) for t in e.args[0?'tried'?])
    11. 5. else:
    12. 6. if sub_match:
    13. 7. sub_match_dict = dict(self.default_kwargs, sub_match2?)
    14. 8. return sub_match0?, sub_match1?, dict(match.groupdict(), sub_match_dict)
    ▶ Local vars Variable Value match <sre.SRE_Match object at 0xe06678> new_path 'test/' path 'dojango/test/' pattern <django.core.urlresolvers.RegexURLPattern object at 0xe10990> self <django.core.urlresolvers.RegexURLResolver object at 0xe01d90> tried
  • /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py in resolve
    1. 1. if kwargs:
    2. 2. args = ()
    3. 3. else:
    4. 4. args = match.groups()
    5. 5. # In both cases, pass any extra_kwargs as kwargs.
    6. 6. kwargs.update(self.default_args)
  1. 7.
    1. 8. return self.callback, args, kwargs ...
    2. 9.
    3. 0. def get_callback(self):
    4. 1. if self.callback is not None:
    5. 2. return self.callback
    6. 3. mod_name, func_name = get_mod_func(self.callback_str)
    7. 4. try:
    ▶ Local vars Variable Value args () kwargs {} match <sre.SRE_Match object at 0xe068e0> path 'test/' self <django.core.urlresolvers.RegexURLPattern object at 0xe10990>
    • /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py in get_callback
      1. 0. def get_callback(self):
      2. 1. if self.callback is not None:
      3. 2. return self.callback
      4. 3. mod_name, func_name = get_mod_func(self.callback_str)
      5. 4. try:
      6. 5. self.callback = getattr(import(mod_name, {}, {}, ''?), func_name)
      7. 6. except ImportError?, e:
      8. 7. raise ViewDoesNotExist?, "Could not import %s. Error was: %s" % (mod_name, str(e)) ...
      9. 8. except AttributeError?, e:
      10. 9. raise ViewDoesNotExist?, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e))
      11. 0. return self.callback
      12. 1. callback = property(get_callback)
      13. 2.
      14. 3. def reverse(self, viewname, args, kwargs):
      ▶ Local vars Variable Value e ImportError?('No module named encoding',) func_name 'test' mod_name 'dojango.views' self <django.core.urlresolvers.RegexURLPattern object at 0xe10990>

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response

68. callback, callback_args, callback_kwargs = resolver.resolve(request.path)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in resolve
  1. 2. sub_match = pattern.resolve(new_path)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in resolve
  1. 2. sub_match = pattern.resolve(new_path)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in resolve
  1. 8. return self.callback, args, kwargs
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in get_callback
  1. 7. raise ViewDoesNotExist?, "Could not import %s. Error was: %s" % (mod_name, str(e))

ViewDoesNotExist? at /dojango/test/ Could not import dojango.views. Error was: No module named encoding

I want to do the test. Can you help me?

Thx

Comment by tobias.klipstein, Sep 09, 2008

please use django version >= 1.0

Comment by iguane39, Nov 29, 2008

You should add some screenshots for the results, this would be better for your visitor.

Nice app.

Comment by gilles.paul.dubois, Feb 12, 2009

Congratulations for your work. I wrote a small French tutorial to install and use Dojango. Adress: http://gilles-dubois.developpez.com/info/django/ Fill free to give this reference for French speaking readers if you think it can help.

Comment by fchevitarese, Mar 13, 2009

Thanks for your work... Very very nice... There´s some place that we can get more help ?

Thanks

Comment by michal.dtz, Jul 12, 2009

This is great, CONGRATULATIONS AND THANKYOU!

Comment by quzhengping, Sep 23, 2009

Great work.

Comment by lord.carcas, Sep 24, 2009

Hi, i have recibe one error http://dpaste.com/97948/

Comment by robinson.ceng, Nov 02, 2009

Hi bro,

I got some error. Please your help .. Request Method: GET Request URL: http://localhost:8000/my-first-page/ Exception Type: TemplateSyntaxError? Exception Value:

Caught an exception while rendering: 'module' object has no attribute 'appengine'

Exception Location: /usr/lib/pymodules/python2.6/django/template/debug.py in render_node, line 81 Python Executable: /usr/bin/python Python Version: 2.6.4 Python Path: '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-packages'? Server time: Mon, 2 Nov 2009 20:53:07 -0600 Template error

In template /home/robin/Desktop/dojango/mysite/dojango/templates/dojango/base.html, error at line 35 Caught an exception while rendering: 'module' object has no attribute 'appengine' 25 {% block dojango_dojo_styles %} 26 <style type="text/css"> 27 @import "{{ DOJANGO.DOJO_URL }}/resources/dojo.css"; 28 @import "{{ DOJANGO.THEME_CSS_URL }}"; 29 </style> 30 {% endblock %} 31 <script type="text/javascript"> 32 {# baseUrl setting is needed, if you want to combine a local with a remote build! #} 33 {% block dojango_dj_config %} 34 var djConfig = { 35 'isDebug':{{ DOJANGO.DEBUG|json }}, 36 'parseOnLoad':true, 37 'baseUrl':"{{ DOJANGO.DOJO_BASE_PATH }}" 38 {% if not DOJANGO.IS_LOCAL %} 39 ,'dojoBlankHtmlUrl':"{{ DOJANGO.BASE_MEDIA_URL }}/resources/blank.html" 40 ,'dojoIframeHistoryUrl':"{{ DOJANGO.BASE_MEDIA_URL }}/resources/blank.html" 41 {% endif %} 42 {% if DOJANGO.CDN_USE_SSL and not DOJANGO.IS_LOCAL %} 43 ,'modulePaths':{'dojo': '{{ DOJANGO.DOJO_URL }}', 'dijit': '{{ DOJANGO.DIJIT_URL }}', 'dojox': '{{ DOJANGO.DOJOX_URL }}'} 44 {% endif %} 45 };

Comment by heidar.rafn, Nov 23, 2009

Hi all I have encountered the same problem as described by robinson.ceng here above. I have analysed it and here are my findings: This started when I upgraded from ubuntu 8.10 to 9.10 this line in dojango/templates/dojango/include.html causes this: 'isDebug':{{ DOJANGO.DEBUG|json } the file dojango/util/init.py contains the code for the json filter and in that file this can be found:

try:
  1. we need it, if we want to serialize query- and model-objects
  2. of google appengine within json_encode
import google
except:
google = None
This import statement succeeds now because a part of ubuntu 9.10 is the package "python-protobuf" drawn in by the ubuntu-one client. And this package contains a "google" module which obviously is not compatible with the one expected by the dojango code. A dirty fix is to change the above try: import block to simple "google=None" statement. If the python-protobuf is removed from the system, dojango works fine.

Comment by tobias.klipstein, Nov 23, 2009

The problem with the google import should be fixed within dojango 0.4.5.

Comment by heidar.rafn, Nov 24, 2009

I confirm the google import is fixed by dojanga 0.4.5, reinstalled ubuntuone client and my django application works fine with dojango now.


Sign in to add a comment
Hosted by Google Code