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


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 "", line 11, in <module>
  File "/homedir/django/trunk/django/core/management/", line 272, in execute_manager
  File "/homedir/django/trunk/django/core/management/", line 219, in execute
  File "/homedir/django/trunk/django/core/management/", line 72, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/homedir/django/trunk/django/core/management/", line 85, in execute
  File "/homedir/django/trunk/django/core/management/", line 112, in validate
    num_errors = get_validation_errors(s, app)
  File "/homedir/django/trunk/django/core/management/", line 28, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "/homedir/django/trunk/django/db/models/", line 128, in get_app_errors
  File "/homedir/django/trunk/django/db/models/", line 57, in _populate
    self.load_app(app_name, True)
  File "/homedir/django/trunk/django/db/models/", line 72, in load_app
    mod = __import__(app_name, {}, {}, ['models'])
  File "/homedir/software/web/playground/../playground/apple/", line 6, in <module>
    class Orange(models.Model):
  File "/homedir/software/web/playground/../playground/apple/", 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