Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#450 closed (wontfix)

[patch] Give generic views support for dynamic lookup keywords

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: UI/UX:

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'
     }
  ...
}

Attachments (1)

dynamic_generics.diff (6.5 KB) - added by slashzero 10 years ago.
patch to do dynamic keyword lookups

Download all attachments as: .zip

Change History (7)

Changed 10 years ago by slashzero

patch to do dynamic keyword lookups

comment:1 Changed 10 years ago by adrian

  • Summary changed from Dynamic lookup keywords for generics to Give generic views support for dynamic lookup keywords

comment:2 Changed 10 years ago by jacob

  • Component changed from Admin interface to Generic views
  • Owner changed from adrian to jacob

comment:3 Changed 10 years ago by jacob

  • Summary changed from Give generic views support for dynamic lookup keywords to [patch] Give generic views support for dynamic lookup keywords

comment:4 Changed 10 years ago by jacob

  • Description modified (diff)
  • Status changed from new to assigned

(edited formatting of description)

comment:5 Changed 10 years ago by adrian

  • Resolution set to wontfix
  • Status changed from assigned to closed

I think the solution here is: Write your own view. This is a bit beyond the scope of generic views at this point.

comment:6 Changed 9 years ago by Main

  • Type enhancement deleted
Note: See TracTickets for help on using tickets.
Back to Top