<reponame>seajhawk/DjangoCRUD<filename>my_shelter/dog_shelters/models.py
from django.db import models
from django.urls import reverse

class Shelter(models.Model):
    name = models.CharField(max_length=200)
    location = models.CharField(max_length=200)
    def __str__(self):
        return self.name

class Dog(models.Model):
    shelter = models.ForeignKey(Shelter, on_delete=models.PROTECT)
    name = models.CharField(max_length=200)
    description = models.TextField()
    intake_date = models.DateTimeField(auto_now_add=True)
    def __str__(self):
        return f"{self.shelter}_{self.name}"
    def get_absolute_url(self):
        return reverse('dog_detail', kwargs={"pk": self.pk})
        
from django.db import models
from django.urls import reverse

class Shelter(models.Model):
    name = models.CharField(max_length=200)
    location = models.CharField(max_length=200)
    def __str__(self):
        return self.name

class Dog(models.Model):
    shelter = models.ForeignKey(Shelter, on_delete=models.PROTECT)
    name = models.CharField(max_length=200)
    description = models.TextField()
    intake_date = models.DateTimeField(auto_now_add=True)
    def __str__(self):
        return f"{self.shelter}_{self.name}"
    def get_absolute_url(self):
        return reverse('dog_detail', kwargs={"pk": self.pk})