Skip to content

Instantly share code, notes, and snippets.

@elcolie
Created October 2, 2017 10:45
Show Gist options
  • Save elcolie/98e641d57c5de3394f816a5d9b80ef13 to your computer and use it in GitHub Desktop.
Save elcolie/98e641d57c5de3394f816a5d9b80ef13 to your computer and use it in GitHub Desktop.
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