使用url config找不到Django Page(404)错误

时间:2015-10-09 02:33:46

标签: django django-urls

我的Django项目中的urls配置有问题,在我的root url配置中我有这个:

from django.conf import settings
from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
                   url(r'^$', include('main.urls')),
                   url(r'^admin/', include(admin.site.urls)),
                   url(r'^profile/', include('accounts.urls')),
                   ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += staticfiles_urlpatterns()

在我的app url config中我有这个:

from django.conf.urls import patterns, url
urlpatterns = patterns('',
                   url(r'^$', 'main.view.home', name='main_home'),
                   url(r'^integrations/$', 'main.view.integrations', name='main_integrations'),
)

但是当我去渲染 url http://127.0.0.1:8000/integrations/ 时,我收到错误404 Not Found。

感谢您的回答。

1 个答案:

答案 0 :(得分:-1)

是的,我的应用名为'main',这是我的观看代码:

def home(request):
user = request.user
if not user.is_authenticated():
    data = {
        'messages': get_messages(request),
    }

    return render_to_response('home.html', data, context_instance=RequestContext(request))

data = {
    'messages': get_messages(request),
}
return render_to_response('home_user.html', data, context_instance=RequestContext(request))


def integrations(request):
    return render_to_response('/main/integrations.html', context_instance=RequestContext(request))