Skip to content

Instantly share code, notes, and snippets.

@rririanto
Last active January 28, 2021 10:41
Show Gist options
  • Save rririanto/144e785defc5c2a86b47385f9f536128 to your computer and use it in GitHub Desktop.
Save rririanto/144e785defc5c2a86b47385f9f536128 to your computer and use it in GitHub Desktop.
AbstractBaseCustomer
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