Question

essentially the idea is that every method in a specific QuerySet will have to use a variable. So define that variable in the __init__ seems to be a good approach:

class SomeQuerySet(models.QuerySet):
    def __init__(self,something):
        self.something = something
        #what goes here???
    #...

now I know that the way Django works, the QuerySet must have an __init__ with some very important code, and this would overwrite it. What would I need to add to this __init__ so that it would not disrupt the QuerySet?

Was it helpful?

Solution

Try super(SomeQuerySet, self).__init__(self, *args, **kwargs) whilst changing your __init__ method to def __init__(self, something, *args, **kwargs). The QuerySet itself is using parameters in the __init__ method so you need to pass them to it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top