django model object code example
Example 1: super in django manager
class DahlBookManager(models.Manager):
def get_queryset(self):
return super().get_queryset().filter(author='Roald Dahl')
class Book(models.Model):
title = models.CharField(max_length=100)
author = models.CharField(max_length=50)
objects = models.Manager()
dahl_objects = DahlBookManager()
Example 2: model object means in django
from django.db import models
class Person(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
Example 3: create django object
Author.objects.create(name="Joe")
Example 4: .save() in django
>>> one_entry = Entry.objects.get(pk=1)