Django admin change_list.html错误

时间:2015-07-17 21:25:47

标签: django python-2.7 django-models django-templates

我最近也更改了我的模型和sqlite3数据库。

当我运行服务器并转到我的admin/project/model页面时。我收到一个错误:

  

对于带有基数为10的int()的无效文字:'已更新'。

已更新是我模型中的字段。

models.py:

@reversion.register
class Block(models.Model):      
    class Meta:
        verbose_name_plural = "Request Blocks"
    inventory = models.ForeignKey(Inventory, null=True) #limit_choices_to={'inventory_name': True})
    added = models.DateTimeField(auto_now_add=True, null=True)
    updated = models.DateTimeField(auto_now=True, null=True)
    name = models.CharField(max_length=50, null=True) #unique=True)
    status = models.CharField(max_length=32, default='pending')
    derivatives = models.CharField(max_length=256, null=True)  
    subsystems = models.CharField(max_length=128, null=True)
    ip = models.CharField(max_length=128, null=True)
    owners = models.CharField(max_length=100, null=True)

admin.py:

class BlockAdmin(reversion.VersionAdmin, admin.ModelAdmin):
    action_form = UpdateActionForm
    list_display = ['name', 'status', 'inventory', 'derivatives', 'added', 'updated'] #'block_date']
    list_filter = ['inventory', 'status', 'derivatives', ]
    search_fields = ['name']
    #list_per_page = 200
    ordering = ['name']
    actions = ['make_finalized', 'make_pending', 'move_to_inventory', 'block_current_date', 'export_csv', 'export_xls', 'export_xlsx']

错误:

Environment:


Request Method: GET
Request URL: http://localhost:8000/admin/inventory/block/

Django Version: 1.8.2
Python Version: 2.7.9


Template error:
In template /usr/lib/python2.7/site-packages/Django-1.8.2-    py2.7.egg/django/contrib/admin/templates/admin/change_list.html, error at line 91
invalid literal for int() with base 10: 'updated'

{% endif %}
 {% endblock %}

      <form id="changelist-form" action="" method="post"{% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %} novalidate>{% csrf_token %}
      {% if cl.formset %}
        <div>{{ cl.formset.management_form }}</div>
      {% endif %}

      {% block result_list %}
          {% if action_form and actions_on_top and cl.show_admin_actions %}{% admin_actions %}{% endif %}


      LINE 91{% result_list cl %}



          {% if action_form and actions_on_bottom and cl.show_admin_actions %}{% admin_actions %}{% endif %}
      {% endblock %}
      {% block pagination %}{% pagination cl %}{% endblock %}
      </form>
    </div>
  </div>
{% endblock %}


Exception Type: ValueError at /admin/inventory/block/
Exception Value: invalid literal for int() with base 10: 'updated'

回溯:

  

文件   &#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/core/handlers/base.py"在get_response中     164. response = response.render()File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/response.py"   在渲染中     158. self.content = self.rendered_content File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/response.py"   在rendered_content中     135. content = template.render(context,self._request)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/backends/ django.py&#34;   在渲染中     74. return self.template.render(context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/base.py" ;   在渲染中     209. return self._render(context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/base.py"   在_render     201. return self.nodelist.render(context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/base.py" ;   在渲染中     903. bit = self.render_node(node,context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/debug.py&# 34;   在render_node中     79. return node.render(context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/loader_tags.py"   在渲染中     135. return compiled_pa​​rent._render(context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/base.py"   在_render     201. return self.nodelist.render(context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/base.py" ;   在渲染中     903. bit = self.render_node(node,context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/debug.py&# 34;   在render_node中     79. return node.render(context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/loader_tags.py"   在渲染中     135. return compiled_pa​​rent._render(context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/base.py"   在_render     201. return self.nodelist.render(context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/base.py" ;   在渲染中     903. bit = self.render_node(node,context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/debug.py&# 34;   在render_node中     79. return node.render(context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/loader_tags.py"   在渲染中     135. return compiled_pa​​rent._render(context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/base.py"   在_render     201. return self.nodelist.render(context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/base.py" ;   在渲染中     903. bit = self.render_node(node,context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/debug.py&# 34;   在render_node中     79. return node.render(context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/loader_tags.py"   在渲染中     65. result = block.nodelist.render(context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/base.py&# 34;   在渲染中     903. bit = self.render_node(node,context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/debug.py&# 34;   在render_node中     79. return node.render(context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/loader_tags.py"   在渲染中     65. result = block.nodelist.render(context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/base.py&# 34;   在渲染中     903. bit = self.render_node(node,context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/debug.py&# 34;   在render_node中     79. return node.render(context)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/template/base.py"   在渲染中     1271. _dict = func(* resolved_args,** resolved_kwargs)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/contrib/admin/templatetags /admin_list.py"   在result_list中     320.&#39;结果&#39;:列表(结果(cl))}文件&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django /contrib/admin/templatetags/admin_list.py"   在结果中     296. yield ResultList(None,items_for_result(cl,res,None))文件   &#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/contrib/admin/templatetags/admin_list.py"   在 init     287. super(ResultList,self)。 init (* items)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg /django/contrib/admin/templatetags/admin_list.py"   在items_for_result中     199. f,attr,value = lookup_field(field_name,result,cl.model_admin)文件   &#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/contrib/admin/utils.py"   在lookup_field中     288. value = getattr(obj,name)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/db/models/fields/related。 PY&#34;   在获取     598. qs = qs.filter(** params)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/db/models/query。 PY&#34;   在过滤器中     679. return self._filter_or_exclude(False,* args,** kwargs)文件   &#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/db/models/query.py"   在_filter_or_exclude中     697. clone.query.add_q(Q(* args,** kwargs))File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/分贝/模型/ SQL / query.py&#34;   在add_q中     1304.子句,require_inner = self._add_q(where_part,self.used_aliases)文件   &#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/db/models/sql/query.py"   在_add_q中     1332. allow_joins = allow_joins,split_subq = split_subq,File   &#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/db/models/sql/query.py"   在build_filter中     1203. condition = self.build_lookup(lookups,col,value)文件   &#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/db/models/sql/query.py"   在build_lookup中     1096. return final_lookup(lhs,rhs)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/db/models/lookups.py" ;   在 init     96. self.rhs = self.get_prep_lookup()File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/db/models/lookups.py& #34;   在get_prep_lookup中     134. return self.lhs.output_field.get_prep_lookup(self.lookup_name,self.rhs)文件   &#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/db/models/fields/的初始化的.py&#34;   在get_prep_lookup中     727. return self.get_prep_value(value)File&#34; /usr/lib/python2.7/site-packages/Django-1.8.2-py2.7.egg/django/db/models/fields/ 初始化的.py&#34;   在get_prep_value中     985. return int(value)Exception Type:ValueError at / admin / inventory / block / Exception Value:int()的文字无效   基数为10:&#39;已更新&#39;

任何人都可以帮助解决此错误吗?

0 个答案:

没有答案