Opened 18 years ago

Closed 17 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: no UI/UX: no

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

Change History (2)

comment:1 by Gary Wilson <gary.wilson@…>, 17 years ago

Triage Stage: UnreviewedAccepted

comment:2 by James Bennett, 17 years ago

Resolution: invalid
Status: newclosed

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