Code

Opened 6 years ago

Closed 6 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: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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.

Attachments (0)

Change History (1)

comment:1 Changed 6 years ago by Karen Tracey <kmtracey@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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.

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.