can class in django model have limited number of fields code example
Example 1: create models in django
from django.db import models
class Contact(models.Model):
name = models.CharField(max_length=50)
email = models.CharField(max_length=50)
contact = models.CharField(max_length=50)
content = models.TextField()
def __str__(self):
return self.name + ' ' + self.email
Example 2: get data from model with field name in django
field_name = "is_staff"
user = User.objects.get(pk=0)
field_name_val = getattr(user, field_name)