Code

Changes between Version 3 and Version 4 of GenerateGenericURLs


Ignore:
Timestamp:
06/24/06 15:43:07 (8 years ago)
Author:
anonymous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GenerateGenericURLs

    v3 v4  
     1= Generate Generic URLs = 
     2 
    13Here's a little function I wrote to generate a standard set of URL mappings I use with generic views.  It takes a list of tuples that each contain the name to use for the url and the model class that represents it.  This function generates generic views for listing, viewing details, adding, editing and deleting objects for the given model. For example: 
    24 
    35{{{ 
     6#!python 
    47make_url_list([('widget', Widget)]) 
    58}}} 
     
    811 
    912{{{ 
     13#!python 
    1014^/widget/$  # will list all widgets 
    1115^/widget/(?<object_id>\d+)/$ # will give details for a specific object 
     
    1822 
    1923{{{ 
     24#!python 
    2025def make_url_list(input, prefix=''): 
    2126    l = [] 
     
    4954 
    5055{{{ 
     56#!python 
    5157tup = tuple(make_url_list(input,prefix='/prefix_if_needed')) 
    5258