Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError thrown when mixing managers #315

Open
dtnmr opened this issue Oct 9, 2016 · 5 comments
Open

AssertionError thrown when mixing managers #315

dtnmr opened this issue Oct 9, 2016 · 5 comments

Comments

@dtnmr
Copy link

dtnmr commented Oct 9, 2016

Hi !

I'm using this segment of the docs in order to implement translatable MPTT models. (By the way the MPTTManager seems to have been renamed to TreeManager)

However an AssertionError is thrown here due to my Django version (1.10.2)

Is there a way to overcome this, or the feature is not ready for 1.10 yet ?

@spectras
Copy link
Collaborator

Hello,

The assertion error is because Django 1.10 no longer supports this way of assigning model managers. It introduced a new API instead, using default_manager_name meta option (and an equivalent for base manager name). Therefore, the _add_to_class way of changing managers doesn't work anymore.

Are you using the new API to assign your manager to your model? If so, can you post a copy of the model and its meta options?

@orf
Copy link

orf commented Oct 22, 2016

Hi, I ran into this error, perhaps the docs should be updated?

I had to add the following code to my models:

objects = TranslationManager()
base_objects = models.Manager()

class Meta:
    base_manager_name = 'base_objects'

@spectras
Copy link
Collaborator

spectras commented Oct 28, 2016

Interesting. TranslationManager is hvad's one or a custom one?

@orf
Copy link

orf commented Oct 28, 2016

It was hvads default one.

@spectras
Copy link
Collaborator

I should add a tag troublesome. It's not a bug per se, though working around this on the hvad side would be an option. I have trouble wrapping my head around the new API for customizing the manager hierarchy. Even though it was changed by Django team at hvad's request (first version was completely incompatible with hvad), another pass on that is due.

While trying to figure out how to handle that, your workaround seems good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants