我的默认项目文件夹是启动,其中包含登录应用程序。在
登录应用程序网址.py:-
url(r'^$', views.LoginFormView.as_view(), name='index'),
登录页面的url。在
内部登录应用程序视图.py:
^{pr2}$已提交登录表单并重定向到用户配置文件页面。在
启动网址.py:-
url(r'^client/', views.IndexClientView.as_view(), name='indexClient'),
启动视图.py:-
class IndexClientView(TemplateView):
template_name = 'startup/index-client.html'
我需要url来用登录表单中输入的用户名替换客户端。在
您可以导入HttpResponseRedirect并使用reverse函数。在
那你呢视图.py看起来像这样
改变你的网址.py因此
^{pr2}$您将有一个登录视图和一个单独的用户配置文件视图。这里indexClient显示为用户配置文件视图。登录后,django重定向到indexClient视图,用户名=用户名,即当前用户的用户名,该用户名应在您需要的url上。在
希望这是有用的。在
在网址.py:-
在视图.py:-
^{pr2}$现在您可以通过以下方式访问它:
slug参数被DetailView(或任何其他基于单个objectmixin的视图)使用,通过使用}来查找{}上的对象
model = User
和{相关问题 更多 >
编程相关推荐