Skip to content

Instantly share code, notes, and snippets.

@vikas-git
Created December 17, 2019 06:33
Show Gist options
  • Save vikas-git/aac3267f2d064aa392615825ccef00a0 to your computer and use it in GitHub Desktop.
Save vikas-git/aac3267f2d064aa392615825ccef00a0 to your computer and use it in GitHub Desktop.
Use some common fields in every django modal
from django.db import models
class AbstractDateTime(models.Model):
'''
Abstract model for created_on and updated_on field in models
'''
created_on = models.DateTimeField(auto_now_add=True)
updated_on = models.DateTimeField(auto_now=True)
class Meta:
abstract = True
class ModalName(AbstractDateTime):
a = models.CharField(max_length=50, null=True, blank=True)
class Meta:
db_table = 'ocean_fcl_rate'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment