Django __init __()占用1个位置参数,但给出了2个

时间:2017-07-29 20:10:04

标签: django python-3.x django-models django-views

我有Django的问题。我试图在Django中创建第二页但得到default_app_config = 'page.apps.PageConfig' 。我需要帮助找到我犯错的地方。我试着阅读文档,但现在对我来说很难。

__初始化__。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'),
]

urls.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

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

model.py

from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _


class PageConfig(AppConfig):
    name = 'page'
    verbose_name = _('Another page')

apps.py

#/bin/bash

i=0
while read a1 b1
    do
    i=$(($i+1))
    cd RUN_EXP$i
    varval=$(python ../postproc.py --susc $a1 --exp_trans $b1 2>&1)
    echo $varval
    cd ..
    echo M1,M2,M3
        for j in "${varval[@]}"
        do
                echo $j
        done
    done < postprocessing.txt

1 个答案:

答案 0 :(得分:10)

尝试添加as_view并更好地显示完整的错误跟踪

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