Opened 10 years ago

Closed 8 years ago

#792 closed defect (invalid)

FileField and edit_inline=meta.STACKED

Reported by: hugo Owned by: nobody
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


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/", line 71, in get_response
    response = callback(request, **param_dict)

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

  File "/home/gb/projects/django/contrib/admin/views/", line 795, in add_stage
    new_object =

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

  File "/home/gb/projects/django/core/meta/", 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

Change History (2)

comment:1 Changed 9 years ago by Gary Wilson <gary.wilson@…>

  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 8 years ago by ubernostrum

  • Resolution set to invalid
  • Status changed from new to closed

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.

Note: See TracTickets for help on using tickets.
Back to Top