Edit the models.py file of the images application and add the following code to it:
from django.db import modelsfrom django.conf import settingsclass Image(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='images_created', on_delete=models.CASCADE) title = models.CharField(max_length=200) slug = models.SlugField(max_length=200, blank=True) url = models.URLField() image = models.ImageField(upload_to='images/%Y/%m/%d/') description = models.TextField(blank=True) created = models.DateField(auto_now_add=True, db_index=True) def __str__(self): return self.title
This is the model we will use to store images bookmarked from different sites. Let's take a look at the fields of this model:
- user ...