包含的URLconf'Project.urls'似乎没有任何模式。创建视图

时间:2019-07-10 23:00:36

标签: django-2.2

在我尝试添加基于类的视图以创建对象之前,一切都很好:

urls.py

 java.lang.AbstractMethodError
        at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:119)
        at org.hibernate.type.AbstractType.hydrate(AbstractType.java:91)
        at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:3014)
        at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1750)
        at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1676)
        at org.hibernate.loader.Loader.getRow(Loader.java:1565)
        at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:730)
        at org.hibernate.loader.Loader.processResultSet(Loader.java:989)
        at org.hibernate.loader.Loader.doQuery(Loader.java:947)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:339)
        at org.hibernate.loader.Loader.doList(Loader.java:2693)
        at org.hibernate.loader.Loader.doList(Loader.java:2676)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2510)
        at org.hibernate.loader.Loader.list(Loader.java:2505)
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:504)
        at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:396)
        at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219)
        at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1537)
        at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1561)
        at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1529)
        at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.list(CriteriaQueryTypeQueryAdapter.java:96)

apps / combustible / urls.py


from django.conf.urls import url, include
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^', include('apps.combustible.urls', namespace='combustible')),
]

apps / combustible / forms.py

from django.conf.urls import url, include
from apps.combustible import views

app_name='comustible'
urlpatterns = [
    #url(r'^consulta_pagos/$', views.consulta_pagos, name='consulta_pagos'),
    url(r'^$', views.index, name='index'),
    url(r'^crear_transaccion/$', views.TransaccionCreate.as_view(), name='crear_transaccion'),
]

apps / combustible / views.py

from django import forms
from apps.combustible.models import Transaccion

class TransaccionForm(forms.ModelForm):
    class Meta:
        model = Transaccion
        fields = '__all__'

        widgets = {
            'empresa': forms.Select(attrs={'class': 'form-control'}),
            'gas': forms.Select(attrs={'class': 'form-control'}),
            'fechaT': forms.DateInput(attrs={'class': 'form-control'}),
            'monto': forms.NumberInput(attrs={'class': 'form-control'}),
            'galones': forms.NumberInput(min_value=0.01,attrs={'class': 'form-control'}),
            'efectuado': forms.CheckboxInput(attrs={'class': 'form-control'}),
        }

我想基于类创建视图,因为在执行manage.py runserver时出现此错误:django.core.exceptions.ImproperlyConfigured:包含的URLconf'HDP_Combustible.urls'似乎没有任何模式。如果您在文件中看到有效的模式,则说明问题可能是由循环导入引起的。

0 个答案:

没有答案