Django 模板 url 未更新

发布于 2024-11-04 06:50:48 字数 344 浏览 2 评论 0原文

我最近一直在更改一些视图模板网址, 从: 切换

(r'^(?P<slug>[^\.]+)/view_post/$', 'view_post'),

到 :

(r'^(?P<slug>[^\.]+)/post/$', 'post'),

并在我的博客应用程序 urls.py 中 。而且,尽管我做了 syncdb 并迁移了 我的博客应用程序与南方,新的网址似乎没有被考虑 通过我的站点地图或管理界面将我重定向到 当我点击查看这篇文章时的旧网址。

I have been changing some of my views templates urls lately,
and switched from:

(r'^(?P<slug>[^\.]+)/view_post/

to :

(r'^(?P<slug>[^\.]+)/post/

in my blog application urls.py. And, though I did a syncdb and migrated
my blog application with south, the new url doesn't seem to be considered
by my sitemaps or the admin interface which redirects me on the
old url when I'm clicking on view this article.

, 'view_post'),

to :


in my blog application urls.py. And, though I did a syncdb and migrated
my blog application with south, the new url doesn't seem to be considered
by my sitemaps or the admin interface which redirects me on the
old url when I'm clicking on view this article.

, 'post'),

in my blog application urls.py. And, though I did a syncdb and migrated
my blog application with south, the new url doesn't seem to be considered
by my sitemaps or the admin interface which redirects me on the
old url when I'm clicking on view this article.

, 'view_post'),

to :

in my blog application urls.py. And, though I did a syncdb and migrated
my blog application with south, the new url doesn't seem to be considered
by my sitemaps or the admin interface which redirects me on the
old url when I'm clicking on view this article.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

打小就很酷 2024-11-11 06:50:48

如果它在 Apache 下运行,则必须强制重新加载或重新启动 apache 才能应用更改。

此外,在更改 urls.py 地图时,您不必同步数据库或迁移应用程序(除非您正在运行我不知道的自定义插件)。

If this is running under Apache, you would have to force-reload or restart apache for your changes to be applied.

Also, you don't have to syncdb or migrate your app when changing your urls.py map (unless you are running a custom add-on I don't know about).

动听の歌 2024-11-11 06:50:48

你如何重新启动 Gunicorn?与-HUP?听起来很奇怪,但尝试完全杀死它然后重新启动它。另外-你不需要重新启动Nginx,只需gunicorn

#start command, stores pid in a file in /tmp
sudo python manage.py run_gunicorn -p /tmp/gunicorn.pid -b 127.0.0.1:8000 --daemon

#stop command
sudo kill `cat /tmp/gunicorn.pid` #note those aren't apostrophes, but the ~ key

#restart commad
sudo kill -HUP `cat /tmp/gunicorn.pid`

我将这些编写为小脚本,这样我就可以从我的主文件夹中调用./start ./stop ./restart,这使得它更容易

How are you restarting Gunicorn? with -HUP? Sounds weird, but try killing it completely then restarting it. Also- you shouldn't need to restart Nginx, just gunicorn

#start command, stores pid in a file in /tmp
sudo python manage.py run_gunicorn -p /tmp/gunicorn.pid -b 127.0.0.1:8000 --daemon

#stop command
sudo kill `cat /tmp/gunicorn.pid` #note those aren't apostrophes, but the ~ key

#restart commad
sudo kill -HUP `cat /tmp/gunicorn.pid`

I write these as little scripts so that I can just call ./start ./stop ./restart from my main folder, makes it easier

野鹿林 2024-11-11 06:50:48

您是否修复了模板中的网址?在您的模板中,我看到两个实例:

<input type="hidden" name="next" value="{% url blog.views.view_post slug=post.slug %}" />

上面应该是:

<input type="hidden" name="next" value="{% url blog.views.post slug=post.slug %}" />

Did you fix your urls from your template? In your template, I see two instances of:

<input type="hidden" name="next" value="{% url blog.views.view_post slug=post.slug %}" />

The above should be:

<input type="hidden" name="next" value="{% url blog.views.post slug=post.slug %}" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文