1

I was reading Django Documentation and I got across this line.

     Managers are only accessible via model classes, not the model 
     instances.

What is the meaning of this line? I am not able to comprehend this. I know what are Model classes ( Represents the Table in Database if I am not wrong). Are the model instances same as what we call "objects" sometimes?

What does this line mean actually? IS this some OOP concept or just Django?

1 Answer 1

3

Lets say you have a model X:

class X(models.Model):
    pass

Now if you want to access the Manager method, you need to access like this:

X.objects.all()

But the following line will not work:

> x = X()  # model instance
> x.save()
> x.objects  << will throw error

FYI: its django specific, not OOP.

Sign up to request clarification or add additional context in comments.

1 Comment

'MODEL' is the representation of an entire 'TABLE' of your database that has a 'MANAGER' and you can do operations (i.e query, crud) through this manager. On the contrary, 'MODEL INSTANCE' is a single 'ROW' of an entire 'TABLE' of your database which undeniably does not contain any manager. Hope this summarizes the concept.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.