Opened 19 years ago

Last modified 18 years ago

#450 closed enhancement

[patch] Give generic views support for dynamic lookup keywords — at Version 4

Reported by: slashzero Owned by: Jacob
Component: Generic views Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Jacob)

I have a database with weather data with daily updates for each weather station in the area. My first thought was to use the date base generic views. I wanted to be able to specify the station_id in the url so that the url is something like /weather/KAPF/2005 , but the generic view will only allow you to specify extra lookup keywords in the url pattern module, not dynamically in the url.

What I created was an extra argument called: 'dynamic_lookup_kwargs'

Simply use that the same way as the extra_lookup_kwargs except that you use the url keyword name instead of a hard coded value.

So for the pattern:

(r'^(?P<station_id>\w{4})/(?P<year>\d{4})/$','archive_year',  info_dict),

We would define the dynamic_lookup_kwargs as:

info_dict = {
  ...  
  'dynamic_lookup_kwargs' : {
      'station_id__exact' : 'station_id'
     }
  ...
}

Change History (5)

by slashzero, 19 years ago

Attachment: dynamic_generics.diff added

patch to do dynamic keyword lookups

comment:1 by Adrian Holovaty, 19 years ago

Summary: Dynamic lookup keywords for genericsGive generic views support for dynamic lookup keywords

comment:2 by Jacob, 19 years ago

Component: Admin interfaceGeneric views
Owner: changed from Adrian Holovaty to Jacob

comment:3 by Jacob, 19 years ago

Summary: Give generic views support for dynamic lookup keywords[patch] Give generic views support for dynamic lookup keywords

comment:4 by Jacob, 19 years ago

Description: modified (diff)
Status: newassigned

(edited formatting of description)

Note: See TracTickets for help on using tickets.
Back to Top