SCM
SCM

Reputation: 121

Unable to create Model without fields in Django rest framework

I am trying to create a model in Django rest framework, without any field information as I'm using MongoDB which doesn't have any fixed fields

twitterdashmodel.py-----

class TwitterMaster(models.Model):

I need a way out so that I can use model to make query functionality from function based views. I am novice to Django rest framework. Need a guidance/solution to it

Upvotes: 1

Views: 1103

Answers (2)

Narendra Kumawat
Narendra Kumawat

Reputation: 59

You can also use Python Doc String

class TwitterMaster(models.Model):
    """TwitterMaster do ...."""

Upvotes: 2

willeM_ Van Onsem
willeM_ Van Onsem

Reputation: 477607

You usually write pass [python-doc] to end a scope without any statements:

class TwitterMaster(models.Model):
    pass

# … something else …

Note that Django will however add a field itself: an AutoField with the name id that is the primary key of the model. For more information, see the automatic primary key fields section of the documentation.

Upvotes: 3

Related Questions