简体   繁体   English

Django 模板 url 未更新

[英]Django Templates urls not updating

I have been changing some of my views templates urls lately, and switched from:我最近一直在更改我的一些视图模板 url,并从以下位置切换:

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

to:至:

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

in my blog application urls.py .在我的博客应用程序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 .而且,虽然我做了一个同步数据库并用南迁移了我的博客应用程序,但我的站点地图或管理界面似乎没有考虑新的syncdb ,当我点击查看这篇文章时,它会将我重定向到旧的 url 上。

If this is running under Apache, you would have to force-reload or restart apache for your changes to be applied.如果它在 Apache 下运行,则必须强制重新加载或重新启动 apache 才能应用更改。

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).此外,在更改 urls.py map 时,您不必同步数据库或迁移您的应用程序(除非您正在运行我不知道的自定义插件)。

How are you restarting Gunicorn?你如何重新启动 Gunicorn? with -HUP?与-HUP? Sounds weird, but try killing it completely then restarting it.听起来很奇怪,但是尝试完全杀死它然后重新启动它。 Also- you shouldn't need to restart Nginx, just gunicorn另外-您不需要重新启动 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`

I write these as little scripts so that I can just call./start./stop./restart from my main folder, makes it easier我把这些写成小脚本,这样我就可以从我的主文件夹中调用./start./stop./restart,这样更容易

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 %}" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM