I'm have a problem with Django. I'm trying to create a second page in Django but get TypeError
. I need help finding where I made the mistake. I tried to read the documentation, but it's hard to me now.
__init__.py
default_app_config = 'page.apps.PageConfig'
urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
# url(r'^$', views.IndexView.as_view(), name='index' ),
url(r'^$', views.IndexView, name='index'),
]
view.py
from django.views.generic import TemplateView
from libs.views import CachedViewMixin
from .models import Page
class IndexView(CachedViewMixin, TemplateView):
template_name = 'main/index.html'
config = None
model.py
from django.db import models
from django.utils.translation import ugettext_lazy as _, ugettext
from solo.models import SingletonModel
class Page(SingletonModel):
updated = models.DateTimeField(_('change date'), auto_now=True)
class Meta:
default_permissions = ('change',)
verbose_name = _('settings')
def __str__(self):
return ugettext('Home page')
apps.py
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
class PageConfig(AppConfig):
name = 'page'
verbose_name = _('Another page')
Try add as_view and better to show full error trace
urlpatterns = [
# url(r'^$', views.IndexView.as_view(), name='index' ),
url(r'^$', views.IndexView.as_view(), name='index'),
# ^^^^^^^^
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With