Code

Opened 5 years ago

Closed 5 years ago

#11380 closed (invalid)

missed error description and line (and file) which contains it [TIP]

Reported by: pedromagnus Owned by: nobody
Component: Uncategorized Version: 1.0
Severity: Keywords: error, _meta, foreignkey
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I had the following output for validating my aplication:

/var/lib/python-support/python2.6/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated
  from sets import ImmutableSet
Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "/var/lib/python-support/python2.6/django/core/management/__init__.py", line 340, in execute_manager
    utility.execute()
  File "/var/lib/python-support/python2.6/django/core/management/__init__.py", line 295, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/var/lib/python-support/python2.6/django/core/management/base.py", line 192, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/var/lib/python-support/python2.6/django/core/management/base.py", line 219, in execute
    output = self.handle(*args, **options)
  File "/var/lib/python-support/python2.6/django/core/management/base.py", line 348, in handle
    return self.handle_noargs(**options)
  File "/var/lib/python-support/python2.6/django/core/management/commands/validate.py", line 9, in handle_noargs
    self.validate(display_num_errors=True)
  File "/var/lib/python-support/python2.6/django/core/management/base.py", line 246, in validate
    num_errors = get_validation_errors(s, app)
  File "/var/lib/python-support/python2.6/django/core/management/validation.py", line 95, in get_validation_errors
    for r in rel_opts.get_all_related_objects():
  File "/var/lib/python-support/python2.6/django/db/models/options.py", line 338, in get_all_related_objects
    self._fill_related_objects_cache()
  File "/var/lib/python-support/python2.6/django/db/models/options.py", line 367, in _fill_related_objects_cache
    if f.rel and not isinstance(f.rel.to, str) and self == f.rel.to._meta:
AttributeError: 'unicode' object has no attribute '_meta'

My app has several subapps and models, so there's no way I could locate the error with this output. By the way, someone knows why the validation is failing by? :P
Sorry for my bad english)
Greetings
Pedro

Attachments (0)

Change History (2)

comment:1 Changed 5 years ago by pedromagnus

  • Keywords error, _meta, foreignkey added; error _meta removed
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Summary changed from missed error description and line (and file) which contains it to missed error description and line (and file) which contains it [TIP]

I finally found the origin of the error (with some help of a camarade).
The error was a ForeignKey declaration:

'''from myapp.practicas import Practica'''
...

# line with the error
practica = models.ForeignKey(u'Práctica', Practica)

# corrected line 
practica = models.ForeignKey(Practica, u'Práctica')

The docs say (and really clear) that a ForeignKey declaration MUST start with the class name (not with its alias). My mistake is had read the docs days after I wrote my app, so I forgot what I had written :P

The thing here is: the error is missed for the validation, and appears when it's too late to reach the error cause (I think). It has to point out this kind of errors, it's very tedious to dive in your code looking for 'something bad'.

I hope this could be helpfull to someone who's about to dive in the same way I did.

Greetings.
Pedro

comment:2 Changed 5 years ago by seveas

  • Resolution set to invalid
  • Status changed from new to closed

Closing as invalid. USer error, not bug.

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.