def get_page_url(page_num, current_app, url_view_name, url_extra_args, url_extra_kwargs, url_param_name, url_get_params, url_anchor):
if url_view_name is not None:<EOL><INDENT>url_extra_kwargs[url_param_name] = page_num<EOL>try:<EOL><INDENT>url = reverse(url_view_name, args=url_extra_args, kwargs=url_extra_kwargs, current_app=current_app)<EOL><DEDENT>except NoReverseMatch as e:  <EOL><INDENT>if settings.SETTINGS_MODULE:<EOL><INDENT>if django.VERSION < (<NUM_LIT:1>, <NUM_LIT:9>, <NUM_LIT:0>):<EOL><INDENT>separator  = '<STR_LIT:.>'<EOL><DEDENT>else:<EOL><INDENT>separator  = '<STR_LIT::>' <EOL><DEDENT>project_name = settings.SETTINGS_MODULE.split('<STR_LIT:.>')[<NUM_LIT:0>]<EOL>try:<EOL><INDENT>url = reverse(project_name + separator + url_view_name, args=url_extra_args, kwargs=url_extra_kwargs, current_app=current_app)<EOL><DEDENT>except NoReverseMatch:<EOL><INDENT>raise e <EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise e <EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>url = '<STR_LIT>'<EOL>url_get_params = url_get_params or QueryDict(url)<EOL>url_get_params = url_get_params.copy()<EOL>url_get_params[url_param_name] = str(page_num)<EOL><DEDENT>if len(url_get_params) > <NUM_LIT:0>:<EOL><INDENT>if not isinstance(url_get_params, QueryDict):<EOL><INDENT>tmp = QueryDict(mutable=True)<EOL>tmp.update(url_get_params)<EOL>url_get_params = tmp<EOL><DEDENT>url += '<STR_LIT:?>' + url_get_params.urlencode()<EOL><DEDENT>if (url_anchor is not None):<EOL><INDENT>url += '<STR_LIT:#>' + url_anchor<EOL><DEDENT>return url<EOL>
Helper function to return a valid URL string given the template tag parameters