pwtail / vinyl_v1

2 stars 1 forks source link

assert Model error #1

Closed dejmail closed 2 years ago

dejmail commented 2 years ago
  File "/$HOME/venv/lib/python3.10/site-packages/vinyl/queryset.py", line 67, in __init__
    assert model
AssertionError

Hi there! Many thanks for putting in all the effort writing this library. I am trying to test it on the little Django project that I am busy with, but keep getting this AssertionError. Obvisouly the model is not making its way to the queryset init method. I have registered the custom manager as vinyl = VinylManager() under each model, and have registered the backend. I hope that I have done everything I need to, but as it is not working I'm sure something is missing or my understanding is lacking. Would you be able to shed any light? What is it that I am not understanding? Thanks!

pwtail commented 2 years ago

Hi @dejmail! I am sorry I forgot about this.

To test you currently have to call init_models signal after the models have been initialized. For example:

from django.apps import AppConfig
from vinyl import init_models

class MyAppConfig(AppConfig):

  def ready(self):
    init_models.send(AppConfig)

The final way to do the init is yet to be found

dejmail commented 2 years ago

@pwtail Much appreciated. Created a pull request, as I think it is supposed to be from vinyl.manager import init_models.