0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

There's no real benefit for me having descriptive urls, so that will work perfectly. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.