2011-06-22 57 views
2

'save_as'是否應該與inline一起工作。我對回溯感到困惑,但它似乎並沒有顯示出我自己的代碼有太多的參與。Django admin'save_as'with inline

這個問題似乎是在保存添加表單時設置爲''的內聯ID。這是當你做一個正常的「添加」很樂意處理:

Traceback: 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 
    111.       response = callback(request, *callback_args, **callback_kwargs) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper 
    307.     return self.admin_site.admin_view(view)(*args, **kwargs) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view 
    93.      response = view_func(request, *args, **kwargs) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 
    79.   response = view_func(request, *args, **kwargs) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner 
    197.    return view(request, *args, **kwargs) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper 
    28.    return bound_func(*args, **kwargs) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view 
    93.      response = view_func(request, *args, **kwargs) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func 
    24.     return func(self, *args2, **kwargs2) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/db/transaction.py" in inner 
    217.     res = func(*args, **kwargs) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/contrib/admin/options.py" in add_view 
    879.         prefix=prefix, queryset=inline.queryset(request)) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/forms/models.py" in __init__ 
    682.             queryset=qs) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/forms/models.py" in __init__ 
    415.   super(BaseModelFormSet, self).__init__(**defaults) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/forms/formsets.py" in __init__ 
    47.   self._construct_forms() 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/forms/formsets.py" in _construct_forms 
    108.    self.forms.append(self._construct_form(i)) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/forms/models.py" in _construct_form 
    691.   form = super(BaseInlineFormSet, self)._construct_form(i, **kwargs) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/forms/models.py" in _construct_form 
    437.     connection=connections[self.get_queryset().db]) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/db/models/fields/subclassing.py" in inner 
    53.    return func(*args, **kwargs) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/db/models/fields/subclassing.py" in inner 
    53.    return func(*args, **kwargs) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/db/models/fields/__init__.py" in get_db_prep_lookup 
    306.    value = self.get_prep_lookup(lookup_type, value) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/db/models/fields/__init__.py" in get_prep_lookup 
    292.    return self.get_prep_value(value) 
File "/Users/andybaker/.virtualenvs/nmdc_test/lib/python2.7/site-packages/django/db/models/fields/__init__.py" in get_prep_value 
    479.   return int(value) 

Exception Type: ValueError at /admin/property_manager/property/add/ 
Exception Value: invalid literal for int() with base 10: '' 
+0

它看起來像一個int字段留空。沒有更多的信息很難知道哪個 – Thomas

+0

爲了幫助您解決問題,請克隆您的項目,將您的模型和管理員剝離到絕對最小值,然後拋出錯誤並將其發佈到您的問題中。 – Udi

回答