simplepro 模型继承的类 页面不能展示

作者:zhc1208420887 577 浏览 4 评论 发布时间:2019-12-09 17:20:18

例: models.py : 

class demo1(models.Model):
    name = models.CharField(
        max_length=10,
        verbose_name='姓名'

    )
    age = models.SmallIntegerField(
        verbose_name='年龄'
    )
    def __str__(self):
        return '姓名:{}, 年龄:{}'.format(self.name, self.age)

    class Meta:
        verbose_name = 'demo1'
        verbose_name_plural = verbose_name
        ordering = ('name',)
class demo2(demo1):
    class Meta:
        verbose_name = 'demo2'
        verbose_name_plural = verbose_name
        ordering = ('name',)

admin.py:

class Demo1Admin(admin.ModelAdmin):
    list_display = ('name', 'age')
    list_display_links = ['name']

class Demo2Admin(admin.ModelAdmin):
    list_display = ('name', 'age')
    list_display_links = None
    def get_queryset(self, request):
        qs = models.demo1.objects.all()
        return qs
admin.site.register(models.demo1, Demo1Admin)
admin.site.register(models.demo2, Demo2Admin)

simpleui 就可以展示  pro 就一直报错:

Traceback (most recent call last):
  File "<string>", line 237, in process_list
  File "<string>", line 477, in list_data
  File "/home/xftm/.virtualenvs/evn_django/lib/python3.6/site-packages/django/db/models/query.py", line 274, in __iter__
    self._fetch_all()
  File "/home/xftm/.virtualenvs/evn_django/lib/python3.6/site-packages/django/db/models/query.py", line 1242, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/home/xftm/.virtualenvs/evn_django/lib/python3.6/site-packages/django/db/models/query.py", line 55, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/home/xftm/.virtualenvs/evn_django/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1087, in execute_sql
    sql, params = self.as_sql()
  File "/home/xftm/.virtualenvs/evn_django/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 474, in as_sql
    extra_select, order_by, group_by = self.pre_sql_setup()
  File "/home/xftm/.virtualenvs/evn_django/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 55, in pre_sql_setup
    order_by = self.get_order_by()
  File "/home/xftm/.virtualenvs/evn_django/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 330, in get_order_by
    field, self.query.get_meta(), default_order=asc))
  File "/home/xftm/.virtualenvs/evn_django/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 704, in find_ordering_name
    field, targets, alias, joins, path, opts, transform_function = self._setup_joins(pieces, opts, alias)
  File "/home/xftm/.virtualenvs/evn_django/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 734, in _setup_joins
    field, targets, opts, joins, path, transform_function = self.query.setup_joins(pieces, opts, alias)
  File "/home/xftm/.virtualenvs/evn_django/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1504, in setup_joins
    names[:pivot], opts, allow_many, fail_on_missing=True,
  File "/home/xftm/.virtualenvs/evn_django/lib/python3.6/site-packages/django/db/models/sql/query.py", line 1420, in names_to_path
    "Choices are: %s" % (name, ", ".join(available)))
django.core.exceptions.FieldError: Cannot resolve keyword 'demo1_ptr' into field. Choices are: age, demo2, id, name

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xftm/.virtualenvs/evn_django/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/xftm/.virtualenvs/evn_django/lib/python3.6/site-packages/django/core/handlers/base.py", line 106, in _get_response
    response = middleware_method(request, callback, callback_args, callback_kwargs)
  File "<string>", line 19, in process_view
  File "<string>", line 26, in process_view
  File "<string>", line 134, in pre_process
  File "<string>", line 239, in process_list
TypeError: write() got an unexpected keyword argument 'msg'

Loading...
评论列表 4条评论
社区小助手
2020-05-04 18:14:48

已经修复该问题,请更新至1.0.7 升级。

zhc1208420887
2020-05-04 18:14:48

@simplepro 原生的和simpleui都不会

社区小助手
2020-05-04 18:14:48

原生admin会报错么

zhc1208420887
2020-05-04 18:14:48

@simplepro 1