Wtower / django-ninecms

Nine CMS is a simple Django app to manage content. Users can create content and publish it to various paths.
BSD 3-Clause "New" or "Revised" License
42 stars 6 forks source link

Error when cloning a node with images #36

Closed Wtower closed 2 years ago

Wtower commented 8 years ago
Internal Server Error: /admin/ninecms/node/add/
Traceback (most recent call last):
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/db/models/fields/__init__.py", line 964, in to_python
    return int(value)
ValueError: invalid literal for int() with base 10: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/contrib/admin/options.py", line 618, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/utils/decorators.py", line 110, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/contrib/admin/sites.py", line 233, in inner
    return view(request, *args, **kwargs)
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/contrib/admin/options.py", line 1518, in add_view
    return self.changeform_view(request, None, form_url, extra_context)
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/utils/decorators.py", line 34, in _wrapper
    return bound_func(*args, **kwargs)
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/utils/decorators.py", line 110, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/utils/decorators.py", line 30, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File "/usr/lib/python3.4/contextlib.py", line 30, in inner
    return func(*args, **kwds)
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/contrib/admin/options.py", line 1468, in changeform_view
    if all_valid(formsets) and form_validated:
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/forms/formsets.py", line 439, in all_valid
    if not formset.is_valid():
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/forms/formsets.py", line 304, in is_valid
    self.errors
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/forms/formsets.py", line 278, in errors
    self.full_clean()
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/forms/formsets.py", line 326, in full_clean
    form = self.forms[i]
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/utils/functional.py", line 59, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/forms/formsets.py", line 142, in forms
    forms = [self._construct_form(i) for i in range(self.total_form_count())]
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/forms/formsets.py", line 142, in <listcomp>
    forms = [self._construct_form(i) for i in range(self.total_form_count())]
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/forms/models.py", line 868, in _construct_form
    form = super(BaseInlineFormSet, self)._construct_form(i, **kwargs)
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/forms/models.py", line 586, in _construct_form
    pk = to_python(pk)
  File "/var/virtualenvs/ttours/lib/python3.4/site-packages/django/db/models/fields/__init__.py", line 969, in to_python
    params={'value': value},
django.core.exceptions.ValidationError: ["Η τιμή '' πρέπει να είναι ακέραιος."]

Request repr(): 
<WSGIRequest
path:/admin/ninecms/node/add/,
GET:<QueryDict: {}>,
POST:{'_save': 'Αποθήκευση',
 'alias': 'tour/argolida',
 'body': '<p>Visiting a place "studded" with archaeological monuments.</p>',
 'created_0': '13/12/2015',
 'created_1': '21:59:49',
 'csrfmiddlewaretoken': 'xIGW1Nx4SndMGWBP5H7Hi8FV96a4gEEg',
 'file_set-INITIAL_FORMS': '0',
 'file_set-MAX_NUM_FORMS': '1000',
 'file_set-MIN_NUM_FORMS': '0',
 'file_set-TOTAL_FORMS': '0',
 'file_set-__prefix__-file': '',
 'file_set-__prefix__-group': '',
 'file_set-__prefix__-id': '',
 'file_set-__prefix__-node': '',
 'file_set-__prefix__-title': '',
 'highlight': 'We are all Argeans, as Homer used to say.',
 'image_set-0-group': '',
 'image_set-0-id': '',
 'image_set-0-node': '',
 'image_set-0-title': 'Nafplio',
 'image_set-1-group': '',
 'image_set-1-id': '',
 'image_set-1-node': '',
 'image_set-1-title': 'Nafplio',
 'image_set-2-group': '',
 'image_set-2-id': '',
 'image_set-2-node': '',
 'image_set-2-title': 'Nafplio',
 'image_set-3-group': '',
 'image_set-3-id': '',
 'image_set-3-node': '',
 'image_set-3-title': 'Epidavros',
 'image_set-4-group': '',
 'image_set-4-id': '',
 'image_set-4-node': '',
 'image_set-4-title': 'Mycinae',
 'image_set-INITIAL_FORMS': '5',
 'image_set-MAX_NUM_FORMS': '1000',
 'image_set-MIN_NUM_FORMS': '0',
 'image_set-TOTAL_FORMS': '5',
 'image_set-__prefix__-group': '',
 'image_set-__prefix__-id': '',
 'image_set-__prefix__-image': '',
 'image_set-__prefix__-node': '',
 'image_set-__prefix__-title': '',
 'language': 'el',
 'link': 'https://www.youtube.com/embed/Mo8dbYkahC0',
 'noderevision_set-INITIAL_FORMS': '0',
 'noderevision_set-MAX_NUM_FORMS': '1000',
 'noderevision_set-MIN_NUM_FORMS': '0',
 'noderevision_set-TOTAL_FORMS': '0',
 'noderevision_set-__prefix__-body': '',
 'noderevision_set-__prefix__-highlight': '',
 'noderevision_set-__prefix__-id': '',
 'noderevision_set-__prefix__-link': '',
 'noderevision_set-__prefix__-log_entry': '',
 'noderevision_set-__prefix__-node': '',
 'noderevision_set-__prefix__-promote': '0',
 'noderevision_set-__prefix__-status': '1',
 'noderevision_set-__prefix__-sticky': '0',
 'noderevision_set-__prefix__-summary': '',
 'noderevision_set-__prefix__-title': '',
 'noderevision_set-__prefix__-user': '',
 'original_translation': '',
 'page_type': '2',
 'status': 'on',
 'summary': '',
 'title': 'Argolis',
 'user': '2',
 'video_set-INITIAL_FORMS': '0',
 'video_set-MAX_NUM_FORMS': '1000',
 'video_set-MIN_NUM_FORMS': '0',
 'video_set-TOTAL_FORMS': '0',
 'video_set-__prefix__-group': '',
 'video_set-__prefix__-id': '',
 'video_set-__prefix__-media': '',
 'video_set-__prefix__-node': '',
 'video_set-__prefix__-title': '',
 'video_set-__prefix__-type': '',
 'video_set-__prefix__-video': '',
 'weight': '0'},
COOKIES:{'csrftoken': 'xIGW1Nx4SndMGWBP5H7Hi8FV96a4gEEg',
 'ttours_sessionid': 'ndjas9aa87ej02o8ltx8703lnqkq0i24'},
META:{'CONTENT_LENGTH': '2477514',
 'CONTENT_TYPE': 'multipart/form-data; '
                 'boundary=---------------------------2022823047268517132314423194',
 'CSRF_COOKIE': 'xIGW1Nx4SndMGWBP5H7Hi8FV96a4gEEg',
 'DOCUMENT_ROOT': '/var/www/vhosts/pbit.9-dev.com/ttours.eu',
 'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
 'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
 'HTTP_ACCEPT_LANGUAGE': 'el-GR,el;q=0.8,en-US;q=0.5,en;q=0.3',
 'HTTP_CONNECTION': 'keep-alive',
 'HTTP_COOKIE': 'csrftoken=xIGW1Nx4SndMGWBP5H7Hi8FV96a4gEEg; '
                'ttours_sessionid=ndjas9aa87ej02o8ltx8703lnqkq0i24',
 'HTTP_HOST': 'www.ttours.eu',
 'HTTP_REFERER': 'http://www.ttours.eu/admin/ninecms/node/15/',
 'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) '
                    'Gecko/20100101 Firefox/42.0',
 'PATH_INFO': '/admin/ninecms/node/add/',
 'PATH_TRANSLATED': '/var/www/vhosts/pbit.9-dev.com/ttours.eu/index.wsgi/admin/ninecms/node/add/',
 'QUERY_STRING': '',
 'REMOTE_ADDR': '37.6.47.2',
 'REMOTE_PORT': '21122',
 'REQUEST_METHOD': 'POST',
 'REQUEST_URI': '/admin/ninecms/node/add/',
 'SCRIPT_FILENAME': '/var/www/vhosts/pbit.9-dev.com/ttours.eu/index.wsgi',
 'SCRIPT_NAME': '',
 'SERVER_ADDR': '87.230.14.186',
 'SERVER_ADMIN': 'web@9-dev.com',
 'SERVER_NAME': 'www.ttours.eu',
 'SERVER_PORT': '80',
 'SERVER_PROTOCOL': 'HTTP/1.1',
 'SERVER_SIGNATURE': '<address>Apache Server at www.ttours.eu Port '
                     '80</address>\n',
 'SERVER_SOFTWARE': 'Apache',
 'UNIQUE_ID': 'Vm-E6FfmDroAAFV@EtMAAAAL',
 'apache.version': (2, 2, 22),
 'mod_wsgi.application_group': 'ttours.eu|',
 'mod_wsgi.callable_object': 'application',
 'mod_wsgi.enable_sendfile': '0',
 'mod_wsgi.handler_script': '',
 'mod_wsgi.listener_host': '',
 'mod_wsgi.listener_port': '80',
 'mod_wsgi.path_info': '/admin/ninecms/node/add/',
 'mod_wsgi.process_group': '',
 'mod_wsgi.request_handler': 'wsgi-script',
 'mod_wsgi.request_start': '1450165480276843',
 'mod_wsgi.script_name': '',
 'mod_wsgi.script_reloading': '1',
 'mod_wsgi.script_start': '1450165481367659',
 'mod_wsgi.version': (4, 4, 11),
 'wsgi.errors': <_io.TextIOWrapper encoding='utf-8'>,
 'wsgi.file_wrapper': <class 'mod_wsgi.FileWrapper'>,
 'wsgi.input': <newrelic.api.web_transaction._WSGIInputWrapper object at 0x7f6fc93e1e48>,
 'wsgi.multiprocess': True,
 'wsgi.multithread': False,
 'wsgi.run_once': False,
 'wsgi.url_scheme': 'http',
 'wsgi.version': (1, 0)}>
Wtower commented 8 years ago
Progress

During the investigation of the above, multiple issues in administration when saving as (cloning) a node.

If the node contains images, it loses them and shows form validation errors. Relevant Django issue 14760 is open 5 years already. Current status: patch exists, awaiting release.

If after the above, the images are uploaded anew, we get IntegerError (with the above stack trace). Relevant Django issue 13223. Current status: Should have been fixed in 1.9.

Relevant question in SO: Django admin save as with inlines.

Current bug status

Node save as is disabled temporarily.

Future actions

Either wait for release of the above fixes, or implement custom clone form action (use button like with clear cache).