Code

Opened 5 years ago

Closed 5 years ago

#10311 closed (invalid)

Overriding the default manager at "import-time"

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

Description

I tried to override the default manager
when I am importing my views.

I noticed that I needed to do override both;

  • objects attribute
  • _default_manager attribute

In my views module I do something like

from app.models import MyModel
from app.models.managers import MyManager

MyModel.add_to_class('objects', MyManager())
MyModel.add_to_class('_default_manager', MyManager())

Overriding the '_default_manager' attribute is needed in order to make
the AnyModel.foreingKey_set working with the new custom manager.

Is it correct and/or safe ?

Attachments (0)

Change History (1)

comment:1 Changed 5 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

The tracker is for bugs and enhancement requests. This seems to be a question, and would be better posed on django-users.

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.