Code

Opened 7 years ago

Closed 7 years ago

#3486 closed (worksforme)

Cryptic error message

Reported by: Dave Abrahams <dave@…> Owned by: adrian
Component: Database layer (models, ORM) 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 Conference(models.Model):
    name = models.CharField(maxlength=100, unique_for_year=start)
    # slug = models.SlugField(prepopulate_from=('name',))
    start = models.DateField('Date on which to start the schedule')
    finish = models.DateField('Date on which to end the schedule')

    def __str__(self):
        return '%s %s' % (self.name,self.start.year)
    
    class Admin: pass

yields:

ProgrammingError: ERROR:  relation "auth_user" does not exist

Attachments (0)

Change History (11)

comment:1 Changed 7 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

What do you have to do in order to make the error message appear?

comment:2 Changed 7 years ago by Dave Abrahams <dave@…>

I think it was just a syncdb

comment:3 Changed 7 years ago by ramiro <rm0 _at_ gmx.net>

I cant't reproduce this. I'd say it is obviously related to another
part of the models.py file the reporter didn't include in the excerpt
he posted.

There is a suer error (with the use of the unique_for_year option) that
syncdb detects and reports but I don't think this ticket is the place to talk
about that.

comment:4 Changed 7 years ago by Michael Radziej <mir@…>

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

It's not possible to find out whether this is a bug or a usage error with the information you provide. As it smells a bit for a usage error, can you please try your luck on django-users and reopen the ticket if this was found to be an error in django?

comment:5 Changed 7 years ago by Dave Abrahams <dave@…>

  • Resolution worksforme deleted
  • Status changed from closed to reopened

It's certainly a usage error! start should have been quoted. The complaint is about the quality of the error message, which ought to tell me if a string field name is required to be passed rather than the field itself.

comment:6 follow-up: Changed 7 years ago by ubernostrum

I'm not entirely certain how we're getting from an unquoted string to auth_user...

I'm also not certain why you're not immediately getting a NameError that start isn't bound to anything at the time you're trying to use it.

This one's gonna need some digging.

comment:7 Changed 7 years ago by Michael Radziej <mir@…>

I still don't see how to produce this message. I get this:

$ python manage.py syncdb
Error: Couldn't install apps, because there were errors in one or more models:
testproj.testapp: name 'start' is not defined

and that's because in the first line, the variable 'start' has not been defined.

Please explain how you get this message.

comment:8 Changed 7 years ago by Dave Abrahams <dave@…>

There were other things in the global namespace, obviously. I don't know if I
can reconstruct the scenario exactly, but what happens if you precede the declaration with

 start = 1

?

comment:9 in reply to: ↑ 6 Changed 7 years ago by Michael Radziej <mir@…>

Replying to ubernostrum:

I'm not entirely certain how we're getting from an unquoted string to auth_user...

I'm also not certain why you're not immediately getting a NameError that start isn't bound to anything at the time you're trying to use it.

This one's gonna need some digging.

I don't understand your decision to reopen this bug. In my opinion, this is a clear 'worksforme'.

comment:10 Changed 7 years ago by Dave Abrahams <dave@…>

I reopened it because it seemed to have been closed based only on a misunderstanding of the report (the comment asked me to determine whether it was usage error or a django bug). If I were a django devel who wanted to close it, it would be on the grounds that the reporter didn't provide enough info to fully reproduce the problem, not "worksforme," since the example, as written, clearly can't work. Personally I'd be eager to find out why the error message isn't more useful, but it's your project.

comment:11 Changed 7 years ago by Michael Radziej <mir@…>

  • Resolution set to worksforme
  • Status changed from reopened to closed

Well. As much as I try, I cannot reproduce it. Please reopen when you have found a way to reproduce it.

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.