Skip to content

Instantly share code, notes, and snippets.

@RedGhoul
Created December 9, 2017 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RedGhoul/a00fe0629b480451324fe1276d39e221 to your computer and use it in GitHub Desktop.
Save RedGhoul/a00fe0629b480451324fe1276d39e221 to your computer and use it in GitHub Desktop.
from django.db import models
class Topic(models.Model):
top_name = models.CharField(max_length=264,unique=True)
def __str__(self):
return self.top_name
class Webpage(models.Model):
topic = models.ForeignKey(Topic) # notice how easy it is to take care of foreign keys
name = models.CharField(max_length=264,unique=True)
url = models.URLField(unique=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