-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #587 from bharath637462/developer_bharath
model field redundancy removed
- Loading branch information
Showing
7 changed files
with
92 additions
and
90 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import uuid | ||
|
||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
|
||
class BaseModelMixin(models.Model): | ||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) | ||
active = models.BooleanField(default=True) | ||
|
||
class Meta: | ||
abstract = True | ||
|
||
|
||
class ModelMixin(BaseModelMixin): | ||
created_by = models.ForeignKey( | ||
"authentication.User", | ||
verbose_name=_("Created by"), | ||
on_delete=models.SET_NULL, | ||
editable=False, | ||
null=True, | ||
related_name="created_%(class)s_set", | ||
) | ||
modified_by = models.ForeignKey( | ||
"authentication.User", | ||
verbose_name=_("Modified by"), | ||
on_delete=models.SET_NULL, | ||
editable=False, | ||
null=True, | ||
related_name="modified_%(class)s_set", | ||
) | ||
created_at = models.DateTimeField(_("Created at"), auto_now_add=True) | ||
modified_at = models.DateTimeField(_("Modified at"), auto_now=True) | ||
deleted_at = models.DateField(_("Deleted at"), null=True, blank=True) | ||
|
||
class Meta: | ||
abstract = True |
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
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
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
Oops, something went wrong.