Associate each bookmark with a user

This commit is contained in:
2021-03-11 08:56:47 -06:00
parent c9d0d81972
commit d80d70b1fe
2 changed files with 24 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
# Generated by Django 3.1.7 on 2021-03-11 14:54
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('bookmarks', '0002_bookmark_title'),
]
operations = [
migrations.AddField(
model_name='bookmark',
name='user',
field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to='auth.user'),
preserve_default=False,
),
]

View File

@@ -1,8 +1,10 @@
from django.db import models
from django.contrib.auth.models import User
class Bookmark(models.Model):
title = models.CharField(max_length=255,null=True)
url = models.URLField(max_length=2048)
user = models.ForeignKey(User, on_delete=models.CASCADE)
def __str__(self):
return self.title