Opened 15 years ago

Closed 15 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: no UI/UX: no

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

Change History (2)

comment:1 by pedromagnus, 15 years ago

Keywords: foreignkey added
Summary: missed error description and line (and file) which contains itmissed 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 by Dennis Kaarsemaker, 15 years ago

Resolution: invalid
Status: newclosed

Closing as invalid. USer error, not bug.

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