如何在运行服务器时制作我的django应用程序,然后当我放入127.0.0.1时,我的网址将显示我创建的网站..不是 127.0.0.1/posts 这是我的网站的urls.py。
admin urls.py
from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^posts/', include("posts.urls", namespace='posts')),
]
my myls.py on myapp
from django.conf.urls import url
from django.contrib import admin
from .views import (
post_list,
post_create,
post_detail,
post_update,
post_delete,
)
urlpatterns = [
url(r'^$', post_list, name='list'),
url(r'^create/$', post_create),
url(r'^(?P<id>\d+)/$', post_detail, name='detail'),
url(r'^(?P<id>\d+)/edit/$', post_update, name='update'),
url(r'^(?P<id>\d+)/delete/$', post_delete),
]
我当前的项目是,当我访问它时,它应该是 127.0.0.1/posts / 当我点击 127.0.0.1 /
时,我想要 post_list 节目我想在pythonanywhere上部署它... 希望你们能帮帮我......谢谢!!
答案 0 :(得分:0)
url(r'', include('posts.urls'))
你应该在admin urls.py
中使用它答案 1 :(得分:0)
我认为您需要更改管理员str = str.replace(/\b\w/g, "+");
之前:
urls.py
后:
url(r'^posts/', include("posts.urls", namespace='posts')),