For django >= 1.5 You could pass parameters to class view doing somethin like this:
class Foo(TemplateView):
template_name = "yourtemplatesdir/template.html"
# Set any other attributes here
# dispatch is called when the class instance loads
def dispatch(self, request, *args, **kwargs):
self.id = kwargs.get('foo_id', "other_def_id")
self.barid = kwargs.get('bar_id', "other_def_id")
# depending on your definition, this class might be different
class Bar(TemplateView):
template_name = "yourtemplatesdir/template.html"
# Set any other attributes here
# this method might not be necessary
# dispatch is called when the class instance loads
def dispatch(self, request, *args, **kwargs):
self.id = kwargs.get('bar_id', "other_def_id")
In your url conf something like:
from .views import FooBar
urlpatterns = patterns('',
url(
regex=r'^(?P<foo_id>\d+)/(?P<bar_id>\d+)/$'
view=FooBar.as_view(),
name='viewname'
),
)
Then, in your template view for FooBar, you could do:
{{ view.id }}
{{ view.barid }}
I hope it helps, it could be more detailed if you provide further information about the object information needed in your 'action'.
class FooBar(models.Model)has 2 foreign keys to eachFooandBarclasses.FooBar. In that view will be some kind of navigation for navigating toFooandBar.FooandBarand get results ofFooBar