Code

Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#7845 closed (fixed)

./manage.py reset fails if app does not define models

Reported by: miracle2k Owned by: nobody
Component: Core (Management commands) Version: master
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

./manage.py reset fails with an obscure IndexError if an app does not define models.

There seems to be no strong reason why it should fail though, and in fact the problem is a line in core/management/sql.py that doesn't seem to have any effect at all anyway (see patch).

Attachments (1)

reset-modelless-app.diff (1.0 KB) - added by miracle2k 6 years ago.

Download all attachments as: .zip

Change History (6)

Changed 6 years ago by miracle2k

comment:1 Changed 6 years ago by ubernostrum

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

Since reset is intended to drop and re-create tables belonging to the models defined in an application, shouldn't resetting a model-less application be an error? Silently passing on this situation seems like a bad idea, since that may well mask deeper errors (e.g., if someone's scripting management commands, this could hide bugs in their script).

comment:2 Changed 6 years ago by miracle2k

Well, lack of models in an application that you expect to be there seems like a pretty big error, that surely should surface easily at some other point. And while I am unable to check check right now, I think I remember that most of the other commands involving models don't complain either, so I'd be in line with that behaviour.

I was in fact scripting management when I stumbled on this, iterating over INSTALLED_APPS and calling call_command'ing "reset". I'm able to workaround that problem of course by checking with get_app(emptyOK=True) and get_models() myself, so it's not that big a deal.

comment:3 Changed 6 years ago by ericholscher

  • milestone set to 1.0
  • Triage Stage changed from Unreviewed to Design decision needed

comment:4 Changed 6 years ago by russellm

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

(In [8401]) Fixes #7845: Removed a piece of stale code that was causing ./manage.py reset to fail with apps that don't have any models. Thanks to miracle2k for the report and patch.

comment:5 Changed 3 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

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.