Hi Matthew,

Am 11.07.19 um 04:13 schrieb Matthew Pava:
I had a use for such a feature, though I used an implementation more specific to my application.

Basically, I have a model and then I have several other models that are directly related to that model. So in the base model I would have a field to determine if the instance was marked as deleted. I don’t have this field in the sub-models, so I would pass in the related name of the base model to create a queryset of all instances of the submodels that should be marked as deleted. Actually, that’s not exactly what I was doing, but the concept is there. Saying that, I am only doing that on one field on one model in my project.

Yes, that would be a use-case indeed.

I'm using it for filtering a model's QuerySet for those objects a user is authorized to see, which has to be implemented for all models in the project so that a custom view mixin can then filter the queryset regardless of the model. However, these queries heavily depend on related fields.

For convenience, I created this module [0], which makes declaring the query logic as part of a model's manager really straightforward and also provides the well-known API for getting filtered querysets (aka Fruit.objects.green()).

Actually, this helped me a lot declaring the needed queries DRY-free.

[0] https://github.com/efficiosoft/QProvider/blob/master/QProvider.py

--
You received this message because you are subscribed to the Google Groups "Django 
developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/35029311-3b9e-0f99-2752-2147415a305e%40efficiosoft.com.
For more options, visit https://groups.google.com/d/optout.
  • ... 'Robert Schindler' via Django developers (Contributions to Django itself)
    • ... Matthew Pava
      • ... 'Robert Schindler' via Django developers (Contributions to Django itself)
        • ... 'Robert Schindler' via Django developers (Contributions to Django itself)
    • ... Shai Berger
      • ... 'Robert Schindler' via Django developers (Contributions to Django itself)
        • ... 'Robert Schindler' via Django developers (Contributions to Django itself)

Reply via email to