Last active
January 28, 2021 10:41
-
-
Save rririanto/144e785defc5c2a86b47385f9f536128 to your computer and use it in GitHub Desktop.
AbstractBaseCustomer
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
import uuid | |
from django.db import models | |
from django.contrib.auth.models import AbstractUser | |
from djstripe.models import Customer, Subscription, PaymentMethod | |
class BaseCustomer(models.Model): | |
customer = models.ForeignKey(Customer, null=True, blank=True, on_delete=models.SET_NULL) | |
subscription = models.ForeignKey(Subscription, null=True, blank=True, on_delete=models.SET_NULL) | |
payment_id = models.CharField(max_length=255, blank=True) | |
class Meta: | |
abstract = True | |
class User(AbstractUser, BaseCustomer): | |
id = models.UUIDField( | |
primary_key=True, | |
default=uuid.uuid4, | |
editable=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment