Django Webapp Framework Comparison

WebappFrameworkComparison / Scratchbook / Django

Back to Snip <-- Previous Change | Next Change -->

Diff Summary
Title
Date 2008-02-10 19:52:25 2008-02-10 19:53:03
Editor Herbert Poul Herbert Poul
Tags

2008-02-10 19:52:25 by Herbert Poul
2008-02-10 19:53:03 by Herbert Poul
4646
47through regular expressions which map against view47through regular expressions which map against view
> functions> functions
4848
49this were my url definitions:49this were my url definitions:
5050
n51[code] n51
52urlpatterns = patterns('barcrud.views',52    urlpatterns = patterns('barcrud.views',
53                       (r'^$', 'list'),53                       (r'^$', 'list'),
54                       (r'^create.*$', 'edit'),54                       (r'^create.*$', 'edit'),
55                       (r'^edit/(?P<bar_id>\d+)/$'55                       (r'^edit/(?P<bar_id>\d+)/$'
>, 'edit'),>, 'edit'),
56                       (r'^details/(?P<bar_id>\d+)56                       (r'^details/(?P<bar_id>\d+)
>/$', 'details'),>/$', 'details'),
57                       (r'^postcomment/(?P<bar_id>57                       (r'^postcomment/(?P<bar_id>
>\d+)/$', 'postcomment'),>\d+)/$', 'postcomment'),
58                       )58                       )
n59[/code] n59
6060
61** How can you link within templates to other acti61** How can you link within templates to other acti
>ons/views/... ? **>ons/views/... ? **
6262
63unfortunately .. i was too lazy to implement it ev63unfortunately .. i was too lazy to implement it ev
>erywhere the "clean" way .. in a real application >erywhere the "clean" way .. in a real application 
>it should definitifely be used:>it should definitifely be used:
6464
65it is possible to make reverse lookups which tries65it is possible to make reverse lookups which tries
> to apply a given set of parameters to the URL pat> to apply a given set of parameters to the URL pat
>terns .. a typical get_absolute_url method in the >terns .. a typical get_absolute_url method in the 
>_model_ looks like this:>_model_ looks like this:
6666
n67[code] n67
68    @permalink68    @permalink
69    def get_absolute_url(self):69    def get_absolute_url(self):
70        return ('barcrud.views.details', (), { 'ba70        return ('barcrud.views.details', (), { 'ba
>r_id': self.id })>r_id': self.id })
t71[/code] t71
7272
73this could also be used for editing urls & co .. a73this could also be used for editing urls & co .. a
>nd .. you could use named URLs to link to URLs not>nd .. you could use named URLs to link to URLs not
> associated with models.. > associated with models.. 
7474
75# Various Comments75# Various Comments
7676

Personal website and blog of Herbert Poul. Also check out my Photo Gallery.




Herby's Photo Gallery

Subscriptions

User

You are not logged in.
Login
Register