参考了:http://www.mamicode.com/info-detail-1104211.html
urls.py
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^ueditor/', include(DjangoUeditor_urls)),
url(r'^$',news_views.index,name='index'),
url(r'^column/(?P<column_slug>[^/]+)/$',news_views.column_detail,name='column'),
url(r'^news/(?P<article_slug>[^/]+)/$',news_views.article_detail,name='article1'),
]
models.py
def get_absolute_url(self):
return reverse('article1', args=(self.slug,)) #reverse的第一个参数是urls.py的url中的name
比如这里的name='article1'