Django __init __ () takes 1 positional argument, but 2 are given

I have a problem with Django. I am trying to create a second page in Django but I am getting TypeError

. I need help on where I went wrong. I tried to read the documentation, but now it's hard for me.

__ __ INIT. RU

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')

      

+3


source to share


1 answer


Try to add as_view and better show full error trace



urlpatterns = [
    # url(r'^$', views.IndexView.as_view(), name='index' ),
    url(r'^$', views.IndexView.as_view(), name='index'),
    #                          ^^^^^^^^
]

      

+7


source







All Articles