django - what's wrong with my urls.py in this example? -
i installed userena, , had example working tutorial, added in single line in urls.py, i'm getting error. in example below, added line mapping home function views.py
now issue i'm having when go 127.0.0.1/8000, typeerror: string not callable, oddly, if go accounts/signup or accounts/signin, getting template should appearing if go 127.0.0.1/8000.
from django.conf import settings django.conf.urls import patterns, include, url django.conf.urls.static import static django.views.generic import templateview accounts import views django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r"^$", 'home'), url(r'^admin/', include(admin.site.urls)), (r'^accounts/', include('userena.urls')), )
here accounts/views.py
from django.shortcuts import render django.http import httpresponseredirect def home(request): return render('homepage.html')
you need remove quotes in url , import view
from accounts.views import home urlpatterns = patterns('', url(r"^$", home), url(r'^admin/', include(admin.site.urls)), (r'^accounts/', include('userena.urls')), )
you can steel use strings in url() must use format 'app.views.viewname'
urlpatterns = patterns('', url(r"^$", 'accounts.views.home'), url(r'^admin/', include(admin.site.urls)), (r'^accounts/', include('userena.urls')), )
or name module in first argument string patterns()
urlpatterns = patterns('accounts.views', url(r"^$", 'home'), url(r'^admin/', include(admin.site.urls)), (r'^accounts/', include('userena.urls')), )
Comments
Post a Comment