In this lesson, you’re going to learn about static files so you can add images, CSS, or JavaScript in the right folder structure inside Django.
When you created models.py, you said that there would be images associated with each project and you put them in the database with the filepath '/img':
# Create your models here.
class Project(models.Model):
title = models.CharField(max_length=100)
description = models.TextField()
technology = models.CharField(max_length=20)
image = models.FilePathField(path='/img/')
Just like you saw with the templates folder, Django is aware of all the static folders inside each project and collects all of them and puts them all in one folder, so don’t forget to use double folder structure.
Martin Breuss RP Team on Jan. 7, 2020
Hello @Amit kumra. It is difficult to diagnose your issue and provide helpful tips without more information.
Can you describe what problem you are running into? Is there any feedback from your command line when attempting to create the object?
As some general tips:
python manage.py shellHope that helps, otherwise please describe in detail what you are doing and what is currently not working, as well as any error messages and exceptions you are receiving.