We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
After all, tomorrow is another day.
url
URLconf
from django.conf.urls import url from django.contrib import admin urlpatterns = [ url(r'^admin/', admin.site.urls), ]
逆向解析 url
HTML
templates
{% url 'name' %}
{% url 'name' 参数 %}
name
<!-- add 就是 name 属性 --> <a href="{% url 'add' 1 2 %}">link</a>
url(r'^new_add/(\d+)/(\d+)/$', views.add, name='add') # 只要url中的正则发生变化,那么网址也会改变,而不需要重新写一个new_add的name属性
django.core.urlresolvers.reverse()
from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect def old_add(request, a, b): return HttpResponseRedirect(reverse('add', args=(a, b)))
get_absolute_url()
^$
Linux
The text was updated successfully, but these errors were encountered:
No branches or pull requests
0x01 Django
url
URLconf
来进行解析逆向解析
url
HTML
模板templates
,使用url
标记进行解析{% url 'name' %}
{% url 'name' 参数 %}
name
不变,正则发生变化,网址也会动态的发生变化django.core.urlresolvers.reverse()
方法解析get_absolute_url()
方法解析0x02 正则表达式
^$
表示空行,是字符串的开始同时也是字符串的结尾,中间没有任何字符Linux
中也代表了空行The text was updated successfully, but these errors were encountered: