Skip to content

Instantly share code, notes, and snippets.

@egitimplus
Last active November 2, 2020 18:10
Show Gist options
  • Save egitimplus/2524ffa96c4c110d654655ee7ba3c999 to your computer and use it in GitHub Desktop.
Save egitimplus/2524ffa96c4c110d654655ee7ba3c999 to your computer and use it in GitHub Desktop.
from django.db import models
class Car(models.Model):
name = models.CharField(max_length=255)
def __str__(self):
return self.name
class CarModel(models.Model):
name = models.CharField(max_length=255)
car = models.ForeignKey(Car, on_delete=models.SET_NULL, blank=True, null=True)
def __str__(self):
return self.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment