Last active
December 10, 2015 21:18
-
-
Save edgabaldi/4494208 to your computer and use it in GitHub Desktop.
extended model for common fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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