Django - is it possible to access all the attributes of one model class into another model class

I am working on a project in django-rest-framework and creating an api. I created some classes under the model section.
Now how can I access all the attributes of one class into the another class.
I tried to do so but I failed ,I declared first class as foreignkey into the other class but by that I only got the str which is returning by str function in first class .
Please help me !
Tell me if there is any way by changing models and it doesn’t matter if any other file would change !!
Thanks a lot in advance !!

It sounds like you need to learn how Django models provide an interface to the database, and how to do the equivalent of a SQL JOIN. This is covered very well by several tutorials. You should create a sample project using a “getting started” tutorial, so that you are familiar with working with Django models, forms, and views:

I encourage you to work through one or more tutorials rather than read them for reference while you start on your own project. I spent about 6 months with Django before I did the tutorial all the way through, and I was mad at myself for wasting six months after finishing it.

Any time you spend getting comfortable and mastering the Django basics will help with creating an API with django-rest-framework, and I suspect will answer your question.

It is also possible that you are asking “How do I make a database table that has all the fields of another database table?”. You should take a look at Abstract Base Classes. The Django docs are excellent, which is one of the reasons this framework remains popular with web developers.

Actually I am trying django-rest-framework and some topics are not clear to me. Thanks for your help and I will try these tutorials.
:smiley::smiley: