Python中文
首页
教程
问答
标签
搜索
登录
注册
Django URL和namesp
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我正在Book应用程序中构建一个Django模板,并使用URL标记重定向到Account应用程序的URL。但上面写着<code>account' is not a registered namespace</code>。你知道吗</p> <p><strong>书本.url:</strong></p> <pre><code>app_name = 'book' urlpatterns = [ path('', views.HomePageView.as_view(), name='home'), path('account/', include('account.urls', namespace='account')) ] </code></pre> <p><strong>书本视图:</strong></p> <pre><code>class HomePageView(generic.TemplateView): template_name = 'book/home.html' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['all_books'] = Book.objects.all() return context </code></pre> <p><strong>模板/书籍/主页.html:</strong></p> <pre><code><div id="register"> <p> <a href="{% url 'account:register' %}"> Sign Up </a> </p> </div> </code></pre> <p><strong>帐户/url:</strong></p> <pre><code>app_name='account' urlpatterns=( path('register/', views.RegisterView.as_view(), name='register'), path('successful/', views.successful_created, name='successful'), ) </code></pre>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>我相信如果您删除namespace=account并只使用path('account/',include('帐户.url)会很好的。你知道吗</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何合并多个PDF文件?
5 回答
如何合并多个xarray数据变量及其坐标?
7 回答
如何合并多个列中具有重复值的行
5 回答
如何合并多个唯一id
3 回答
如何合并多个图纸并使用图纸名称的名称重命名列名?
8 回答
如何合并多个字典并添加同一个键的值?(Python)
7 回答
如何合并多个搜索结果文件(pkl)以将它们全部打印在一起?
2 回答
如何合并多个数据帧
8 回答
如何合并多个数据帧并使用Pandas为假人添加列?
2 回答
如何合并多个数据帧并按时间戳排序
6 回答
如何合并多个数据帧的列表并用另一个lis标记每列
5 回答
如何合并多个数据框中的列
7 回答
如何合并多个文件?
7 回答
如何合并多个查询集?
5 回答
如何合并多个绘图?
8 回答
如何合并多个词典
2 回答
如何合并多个输入数据集(数据帧)?
5 回答
如何合并多条记录中拆分的文本行
2 回答
如何合并多索引列datafram
4 回答
如何合并多级(即多索引)数据帧?
6 回答