Hi
I am working with Django 1.11 and Python 3.4.
I am attempting to pass multiple keyword arguments from a reverse() call
(from my app called `uploads`).
*urls.py*
urlpatterns = [
url(
regex=r'^add/$',
view=views.add_new,
name='add_new'),
url(
regex=r'^details/(?P<view>[a-z.]+)/(?P<mid>\d+)?$',
view=views.upload_details,
name='upload_details'),
]
*views.py*
def add_new(request)
# ... process data via a form; create a result object
return HttpResponseRedirect(
reverse('uploads:upload_details',
kwargs={'view': view, 'mid':result.pk})
)
def upload_details(request, view='site', mid=None):
# ... run process based on view and mid args
When the `upload_details` view gets called, the 'mid' does not set (even
though it has a valid integer value); examining the
contrib/auth/decorators.py file in debug mode:
def decorator(view_func):
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
if test_func(request.user):
return view_func(request, *args, **kwargs)
shows that the kwargs now only holds:
{'view': 'site'}
(for reference, the browser address shows:
http://127.0.0.1:8000/uploads/details/site/3 )
I am not sure how to pass through both keyword arguments in a way that
Django retains and uses them?
Thanks
Derek
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAF1Wu3NTM-6qhFo4DQwdJ62AgJ3Vyw91SAdaSgZeOYyk82xD7A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.