-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
Question about workflow model design #32
Comments
Sometimes, user may have their own custom manager on I don't actually remember the reason exactly. A situation poped up and I decided to change variable name. Now I remember the reason like it is as I mention earlier. I see your case and I will think about it. |
@javrasya how do you make it work with django admin out of the box then? They definitely have Anyways nowadays that sites are API driven its important to keep things compatible with Django Rest Framework out of the box as well (at least). If you have entire control of the codebase then .workflow should be fine but with third party apps and all a simple |
I don't actually see the reason you use |
There are two thing can be done via I mean, if you want to use those APIs of the |
@javrasya this is my model:
Unless it's something related to this issue #30 |
Adding different manager into the model, makes django not to add default one which is Django admin works well because it detects default manager and works with it actually. Probably django gives it to admin. In django source code; if not opts.managers or cls._requires_legacy_default_manager():
if any(f.name == 'objects' for f in opts.fields):
raise ValueError(
"Model %s must specify a custom Manager, because it has a "
"field named 'objects'." % cls.__name__
)
manager = Manager()
manager.auto_created = True
cls.add_to_class('objects', manager) Django decides that, there is already a manager in this model and no need to add default one which is This may be a problem for django-river as well. Becuase, I didn't actually want to loose Thank you for the report. |
@javrasya aha... pure magic ;) Yeah there should be an "easy" way for you to let .objects being accessible, maybe inherit from the same model manager as .objects and then add you django-river/workflow methods on top of it?? |
@javrasya I trying out django-river, and i noticed that if i do
MyModel.objects.all()
i get aAttributeError: type object 'MyModel' has no attribute 'objects'
, but if i doMyModel.workflow.get_queryset().all()
it works.Is this a bug or a design decision?? How does it work in the admin out of the box then, but when i try it manually i run into that error? Would i always have to use the
.workflow
to access my models manager?I needed to make this work with Rest Framework and because of this issue i had to override the create method for example and explicitly say
instance = ModelClass.workflow.create(**validated_data)
instead of the normalinstance = ModelClass.objects.create(**validated_data)
Thanks
The text was updated successfully, but these errors were encountered: