Created
October 2, 2017 10:45
-
-
Save elcolie/98e641d57c5de3394f816a5d9b80ef13 to your computer and use it in GitHub Desktop.
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.utils.translation import ugettext_lazy as _ | |
from model_controller.models import AbstractModelController | |
from django.contrib.auth.models import User | |
class AbstractTimeStampMarker(models.Model): | |
created_at = models.DateTimeField(auto_now_add=True, verbose_name=_("Created at")) | |
updated_at = models.DateTimeField(auto_now=True, verbose_name=_("Updated at")) | |
class Meta: | |
abstract = True | |
class AbstractModelController(AbstractTimeStampMarker): | |
created_user = models.ForeignKey(User, related_name="%(class)s_created_user", verbose_name=_("Created User")) | |
updated_user = models.ForeignKey(User, related_name="%(class)s_updated_user", verbose_name=_("Updated User")) | |
class Meta: | |
abstract = True | |
class ZIPCodeAddress(AbstractModelController): | |
""" | |
Do not forget to change ZIPCodeAddressExcelSerializer too! | |
Because it is beta version. Meta class does not inherited | |
""" | |
zipcode = models.CharField(max_length=100, db_index=True, verbose_name=_('Zipcode')) | |
region = models.CharField(max_length=100, verbose_name=_('Region')) | |
prefecture = models.CharField(max_length=100, verbose_name=_('Prefecture')) | |
city = models.CharField(max_length=100, verbose_name=_('City'), blank=True, null=True) | |
town = models.CharField(max_length=100, verbose_name=_('Town'), blank=True, null=True) | |
building = models.CharField(max_length=100, verbose_name=_('Building'), blank=True, null=True) | |
class Meta: | |
verbose_name = 'ZIPCode Address' | |
verbose_name_plural = 'ZIPCode Addresses' | |
def __str__(self): | |
return self.zipcode | |
class ZIPCodeAddressManager(models.Manager): | |
pass | |
class ZIPCodeAddressImportExport(ZIPCodeAddress): | |
objects = models.Manager() | |
class Meta: | |
proxy = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment