Opened 3 years ago

Closed 3 years ago

#19069 closed Cleanup/optimization (fixed)

improve error when attempting to use a swapped model

Reported by: ptone Owned by: nobody
Component: Database layer (models, ORM) Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation:
Needs tests: Patch needs improvement:
Easy pickings: no UI/UX: no

Description

Currently two checks for a swapped model exist when creating a manager:

These result in an error:

AttributeError: type object 'User' has no attribute 'objects'

as opposed to DatabaseError: no such table: <...> which is the error when the model is swapped but has the default manager (as syncdb will not create tables for swapped models). Ideally - there should be a manager installed that just raises an error explaining that the model has been swapped and is unavailable and probably offer information about what model it was swapped for - as this is readily available.

Change History (1)

comment:1 Changed 3 years ago by Russell Keith-Magee <russell@…>

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

In cc337a74f1808b216fff96f1695d8b066d2636f6:

Fixed #19069 -- Improved the error message when trying to query a swapped model.

Thanks to Preston Holmes for the suggestion.

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