Opened 16 years ago

Closed 16 years ago

#7294 closed (invalid)

Same Classname and Fieldnames clash in edit inline

Reported by: Patrick Lauber <patrick.lauber@…> Owned by: nobody
Component: contrib.admin Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

class Apple(models.Model):
     name = models.CharField()

class Orange(models.Model):
     one = models.ForeignKey(One,edit_inline=models.STACKED)
     description = models.TextField()

This will break the admin when you try to save an Apple. The error message is very obscure and not understandable and doesn't guide you to the real conflict.

Change History (1)

comment:1 by Karen Tracey <kmtracey@…>, 16 years ago

Resolution: invalid
Status: newclosed

This fails long before trying to save an Apple. What you have included fails syncdb:

Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "/homedir/django/trunk/django/core/management/__init__.py", line 272, in execute_manager
    utility.execute()
  File "/homedir/django/trunk/django/core/management/__init__.py", line 219, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/homedir/django/trunk/django/core/management/base.py", line 72, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/homedir/django/trunk/django/core/management/base.py", line 85, in execute
    self.validate()
  File "/homedir/django/trunk/django/core/management/base.py", line 112, in validate
    num_errors = get_validation_errors(s, app)
  File "/homedir/django/trunk/django/core/management/validation.py", line 28, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "/homedir/django/trunk/django/db/models/loading.py", line 128, in get_app_errors
    self._populate()
  File "/homedir/django/trunk/django/db/models/loading.py", line 57, in _populate
    self.load_app(app_name, True)
  File "/homedir/django/trunk/django/db/models/loading.py", line 72, in load_app
    mod = __import__(app_name, {}, {}, ['models'])
  File "/homedir/software/web/playground/../playground/apple/models.py", line 6, in <module>
    class Orange(models.Model):
  File "/homedir/software/web/playground/../playground/apple/models.py", line 7, in Orange
    one = models.ForeignKey(One,edit_inline=models.STACKED)
NameError: name 'One' is not defined

If I try to guess what you meant and change One to Apple then it still fails because you haven't included a max_length on the CharField plus there are no core=True fields in the inline-edited model. So since guessing isn't working out so well, please reopen with a copy of exactly what you have specified to cause the problem, preferably whittled down to as small an example as possible but not whittled so far that it doesn't work at all.

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