Code

Opened 8 years ago

Closed 7 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:

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 (0)

Change History (2)

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

  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 7 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.