url scheme sample:
http://domain/tests/?_=1111111&data=3333333&status=22222222
In view, I ne开发者_如何学Goed data and status, any approach is welcome! All the params are integers.
Your data passed as GET parameters does not need to be matched in urls file.
urlpatterns += patterns(
('^tests/$', 'app.views.test'),
)
You will have that data in your view as: request.GET.get('_', None)
, ...
Your can write a form which will help you to validate and clean up the data and use it like this in your view:
form = some_form(data=request.GET)
if not form.is_valid():
raise InvalidRequest()
data = form.cleaned_data
If that's the url the params are accessible through the request.GET dictionary in the view method.
def my_view(request):
print request.GET['data']
Of course if you need to validate whether the elements are in the dictionary('data' in request.GET
) and convert them to int prior using them like that. int(request.GET['data'])
精彩评论