Django

Code

Ticket #792 (closed: invalid)

Opened 3 years ago

Last modified 1 year ago

FileField and edit_inline=meta.STACKED

Reported by: hugo Assigned to: nobody
Milestone: Component: django.contrib.admin
Version: Keywords:
Cc: Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

When using a FileField? in a model that is edited inline in another model, I get the following error:

There's been an error:

Traceback (most recent call last):

  File "/home/gb/projects/django/core/handlers/base.py", line 71, in get_response
    response = callback(request, **param_dict)

  File "/home/gb/projects/django/contrib/admin/views/decorators.py", line 49, in _checklogin
    return view_func(request, *args, **kwargs)

  File "/home/gb/projects/django/contrib/admin/views/main.py", line 795, in add_stage
    new_object = manipulator.save(new_data)

  File "/home/gb/projects/django/utils/functional.py", line 3, in _curried
    return args[0](*(args[1:]+moreargs), **dict(kwargs.items() + morekwargs.items()))

  File "/home/gb/projects/django/core/meta/__init__.py", line 1573, in manipulator_save
    f.save_file(rel_new_data, new_rel_obj, change and old_rel_obj or None, old_rel_obj is not None, rel=True)

UnboundLocalError: local variable 'old_rel_obj' referenced before assignment

The model:

class Dokument(meta.Model):

    slug = meta.SlugField('Kurzname', prepopulate_from=('titel',))
    titel = meta.CharField('Titel', maxlength=100)
    beschreibung = meta.TextField('Beschreibung')
    parent = meta.ForeignKey('self', null=True, blank=True)

    class META:

        admin = meta.Admin(
            search_fields = ('titel', 'beschreibung'),
        )

        module_name = 'dokumente'
        verbose_name_plural = 'Dokumente'

    def __repr__(self):
        return self.titel

class Anhang(meta.Model):

    titel = meta.CharField('Titel', maxlength=100)
    beschreibung = meta.TextField('Beschreibung')
    dokument = meta.ForeignKey(Dokument, edit_inline=meta.STACKED, num_in_admin=1)
    datei = meta.FileField('Datei', upload_to='uploads/%Y-%m-%d')

    class META:

        module_name = 'Anhaenge'
        verbose_name_plural = 'Anhaenge'

    def __repr__(self):
        return self.titel

Attachments

Change History

02/26/07 10:52:30 changed by Gary Wilson <gary.wilson@gmail.com>

  • stage changed from Unreviewed to Accepted.

09/16/07 06:41:56 changed by ubernostrum

  • status changed from new to closed.
  • resolution set to invalid.

The age of this ticket and the fact that various components in that traceback don't exist anymore lead me to believe this is probably invalid now, and in any case edit_inline is getting completely overhauled.


Add/Change #792 (FileField and edit_inline=meta.STACKED)




Change Properties
Action