Вопрос

I'm building a database application using django. Much of the data recorded requires supporting documentation (this documentation is scanned in and uploaded). Many of my django views include links to my scanning view, and arguments are passed into that view. In fact the view that handles the scanning takes 9 optional kwargs. I can't work out how to set up my urls.py so as to handle the following:

HttpResponseRedirect(reverse('general_doc_upload', kwargs = doc_parameters))

I'm sure there must be a nicer way of handling this than trying to write Regex for every possible combination of kwargs.

Unfortunately the I don't have a lot of leeway with the underlying database structure, this has been specified by the client, the django models (and corresponding views) have been written to fit this structure.

Это было полезно?

Решение

This sort of thing is where putting the parameters in the URL breaks down. Instead, you should pass them as GET parameters - /my/url/upload/?param1=foo&param2=bar etc.

In your urlconf, just match the basic pattern with r'upload/$', and get the parameters in your view with request.GET['param1'] etc.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top