python - Django URL - default value if the value doesn't exist -
i trying set default value in case of no entry.
url file:
url(r'^testapp/(?:(?p<view_id>test1|test2\w+)/)?$', testapp_views.main),
view file:
def main( request, view_id = 'test1'): print view_id
and in console see " none "
do know why ? in advance,
make url this
url(r'^testapp/$', testapp_views.main),
blank value gives error in url can pass value parameters "testapp/?view_id=test1"
and write view as
def main(request): print request.get.get("view_id", "test1")
Comments
Post a Comment