User Tools

Site Tools


devel:django_introduction

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
devel:django_introduction [2008/08/25 08:27]
jodal Upgrade to Django 1.0 done.
devel:django_introduction [2008/08/25 10:44]
jodal Document the improved inner workings of nav.django.urls.
Line 18: Line 18:
 ==== URL configuration ==== ==== URL configuration ====
  
-In ''​nav.django.urls''​ the root URL configuration for all things Django in NAV is located. ​The URLconf ​is roughly divided in two. The first part delegates various ​URL namespaceslike ''/​ipdevinfo/'', ​to the corresponding Django apps and their own URLconfsThe second part is URL patterns ​for non-Django NAV subsystemslike the report subsystemThe second part is used by Django apps to link to non-Django apps, through the use of the ''​url''​ template tag or the ''​reverse()''​ function, instead of using the archaic ''​nav.web.urlbuilder''​.+In ''​nav.django.urls''​ the root URL configuration for all things Django in NAV is located. ​''​nav.django.urls'' ​is not only a module, but also a package. The ''​%%__init__.py%%''​ file in the package imports all submodules it can find in the file system, calls ''​get_urlpatterns()''​ on all the submodules, and combines the results into one ''​urlpatterns''​ list, as all Django ​URL configurations does. 
 + 
 +In other wordswhen creating a new Django app in a branch of its own, you simply drop a new submodule for your app into the ''​subsystem/lib-python/​src/​nav/​django/​urls/'' ​folderrun ''​make install''​ in ''​subsystem/​lib-python/'' ​and then the NAV installation will find your appIf somebody else runs ''​make install''​ in their version of ''​subsystem/​lib-python/''​ they will not overwrite the URL configuration ​for your new appunless they use exactly ​the same name for the submodule as you did. 
 + 
 +=== nav.django.urls.urlbuilder === 
 + 
 +There is one special submodule named ''​nav.django.urls.urlbuilder''​. This is simply a Django replacement for the archaic ''​nav.web.urlbuilder''​. It is used by Django apps to link to non-Django apps, like the report subsystem, through the use of the ''​url''​ template tag or the ''​reverse()''​ function, instead of using the archaic ''​nav.web.urlbuilder''​. From your code's point of view, the URL configurations in ''​nav.django.urls.urlbuilder''​ is used as any other URL configuration in NAV.
  
 ==== Shortcuts ==== ==== Shortcuts ====
devel/django_introduction.txt · Last modified: 2010/01/13 11:30 by eide