我认为这是一个需要修复的简单问题。我在运行服务器时遇到的主要错误是
crudbuilder.exceptions.NotModelException: No model defined in <class 'crudbuilder.abstract.BaseCrudBuilder'> class
如果你想跟随,那么github位于https://github.com/asifpy/django-crudbuilder。在pip install
和django-tables2
django-crudbuilder
之后,我将两者都添加到我的settings.py中。
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_tables2',
'my_project',
'crudbuilder', ]
在我的models.py中,
from django.contrib.gis.db import models
from django.contrib.postgres.fields import ArrayField
class my_model(models.Model):
name = models.CharField(max_length=500)
gender = models.IntegerField(null=True)
在我新添加的crud.py中,
from crudbuilder.abstract import BaseCrudBuilder
from my_project.models import my_model
class MyModelCrud(BaseCrudBuilder):
model = my_model
search_fields = ['name']
tables2_fields = ('name', 'gender')
tables2_css_class = "table table-bordered table-condensed"
tables2_pagination = 20 # default is 10
modelform_excludes = ['created_by', 'updated_by']
login_required=False
permission_required=False
# permissions = {
# 'list': 'example.person_list',
# 'create': 'example.person_create'
# }
由于某种原因,我的django应用程序不喜欢crud.py第1行的from crudbuilder.abstract import BaseCrudBuilder
,但它确实认为crudbuilder是合法的INSTALLED_APP
crudbuilder的来源非常少。在我找到的5个文档页面中,它们都共享相同的示例文档。我觉得这可能是我所做的一行django错误。提前感谢您的时间。