Created
April 12, 2019 13:22
-
-
Save bencleary/4fcf3eb06fabda51bd04eb4596765646 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Migration(migrations.Migration): | |
initial = True | |
dependencies = [ | |
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | |
] | |
operations = [ | |
migrations.CreateModel( | |
name='Post', | |
fields=[ | |
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |
('created_at', models.DateTimeField(auto_now_add=True)), | |
('updated_at', models.DateTimeField(auto_now=True)), | |
('title', models.CharField(max_length=255)), | |
('post', models.TextField()), | |
('created_by', models.ForeignKey(blank=True, null=True, on_delete=None, related_name='blog_post_created_by_related', to=settings.AUTH_USER_MODEL)), | |
('updated_by', models.ForeignKey(blank=True, null=True, on_delete=None, related_name='blog_post_updated_by_related', to=settings.AUTH_USER_MODEL)), | |
], | |
options={ | |
'abstract': False, | |
}, | |
), | |
] |
This file contains hidden or 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
class Migration(migrations.Migration): | |
initial = True | |
dependencies = [ | |
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | |
] | |
operations = [ | |
migrations.CreateModel( | |
name='Post', | |
fields=[ | |
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |
('title', models.CharField(max_length=255)), | |
('post', models.TextField()), | |
('created_at', models.DateTimeField(auto_now_add=True)), | |
('updated_at', models.DateTimeField(auto_now=True)), | |
('created_by', models.ForeignKey(blank=True, null=True, on_delete=None, related_name='blog_post_created_by_related', to=settings.AUTH_USER_MODEL)), | |
('updated_by', models.ForeignKey(blank=True, null=True, on_delete=None, related_name='blog_post_updated_by_related', to=settings.AUTH_USER_MODEL)), | |
], | |
options={ | |
'abstract': False, | |
}, | |
), | |
] |
This file contains hidden or 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 BaseModelMixin(models.Model): | |
created_at = models.DateTimeField(auto_now_add=True) | |
updated_at = models.DateTimeField(auto_now=True) | |
created_by = models.ForeignKey(User, on_delete=None, related_name="%(app_label)_%(class)_related") | |
updated_by = models.ForeignKey(User, on_delete=None, related_name="%(app_label)_%(class)_related") | |
class Meta: | |
abstract = True |
This file contains hidden or 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 blog_shared.models import BaseModelMixin | |
from django.db import models | |
class Post(BaseModelMixin): | |
title = models.CharField(max_length=255) | |
post = models.TextField() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment