Django url.py重写到不同的主机

时间:2022-04-21 18:07:18

this was my url.py

这是我的url.py

urlpatterns = patterns('',
url(r'/newm/$', views.CreateManView.as_view(), name='create_man'),

I've changed it to:

我已将其更改为:

url(r'http://y.y.y.y/newm/$', views.CreateManView.as_view(), name='create_man'),

but result in a call to:

但导致致电:

http://x.x.x.x/http://y.y.y.y/newm/

HTTP://x.x.x.x/http://y.y.y.y/newm/

how can I change all url that refer to create_man so they will get to

如何更改引用create_man的所有url,以便他们可以访问

http://y.y.y.y/newm/

HTTP://y.y.y.y/newm/

?

1 个解决方案

#1


1  

Check out django-hosts, it does exactly that.

看看django-hosts,就是这样。

As for having it as a feature in Django, a core dev commented on this question:

至于将它作为Django中的一个功能,核心开发者就这个问题发表了评论:

This has been solved by external apps and I'm happy with that solution

这已经被外部应用程序解决了,我很满意这个解决方案

#1


1  

Check out django-hosts, it does exactly that.

看看django-hosts,就是这样。

As for having it as a feature in Django, a core dev commented on this question:

至于将它作为Django中的一个功能,核心开发者就这个问题发表了评论:

This has been solved by external apps and I'm happy with that solution

这已经被外部应用程序解决了,我很满意这个解决方案