Skip to content

Instantly share code, notes, and snippets.

@edgabaldi
Last active December 10, 2015 21:18
Show Gist options
  • Save edgabaldi/4494208 to your computer and use it in GitHub Desktop.
Save edgabaldi/4494208 to your computer and use it in GitHub Desktop.
extended model for common fields
from django.db import models
from django.contrib.auth.models import User
class IdentModel(models.Model):
user = models.ForeignKey(User)
created = models.DateTimeField(auto_now_add=True, editable=False)
modified = models.DateTimeField(auto_now=True, editable=False)
class Meta:
abstract = True
class Account(IdentModel):
TYPE_CHOICES = (
('D', 'Debit'),
('C', 'Credit'),
)
name = models.CharField(max_length=100)
parent = models.ForeignKey('self')
type = models.CharField(max_length=1, choices=TYPE_CHOICES)
status = models.BooleanField()
def __unicode__(self):
return self.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment