from django.db import models
from django.contrib.auth.models import User, PermissionsMixin
from django.urls import reverse
# Create your models here.
class Owner(User, PermissionsMixin):
def __str__(self):
return self.username
class Cat(models.Model):
name = models.CharField(max_length=40)
bday = models.DateField()
owner = models.ForeignKey(Owner, related_name='cats', null=True, on_delete=models.SET_NULL)
def get_absolute_url(self):
return reverse('test')
def __str__(self):
return self.name
class Dog(models.Model):
name = models.CharField(max_length=40)
bday = models.DateField()
owner = models.ForeignKey(Owner, related_name='dogs', null=True, on_delete=models.SET_NULL)
def get_absolute_url(self):
return reverse('test')
def __str__(self):
return self.name
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA6wQL%2BphX%3Dy8RnuHzfG1u7Z68%3Difpy6-3HFgVrQGitSCqBniA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment