Try to search your question here, if you can't find : Ask Any Question Now ?

How can I access a URL's named group in a Django Generic View?

HomeCategory: stackoverflowHow can I access a URL's named group in a Django Generic View?
Avatarpushpa asked 4 months ago

Given a url like: url(r'^foos/(?P<foo_id>[0-9]+)/bars/new/$'

How can I access foo_id from within a CreateView instance in order to populate a foreign key form field? I’ve tried a number of approaches (most recently overriding get_context_data and trying to pull the value out of the request object or from kwargs) without success.

There may be a better way to do this (e.g. formsets), but I’d like to make as few changes to my existing flow.

1 Answers
Best Answer
AvatarMatthias answered 4 months ago
Your Answer

6 + 9 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com