Can't not load static or media file, only load static when i put files in staticfiles then colllectstatic Django
I tried to put files to static, but even when i have file in static, i still can't open them in localhost.I can't use them until i put them in staticfiles and then python manage.py collectstatic. Here is my setting:
STATIC_URL = '/static/'
STATICFILES_DIRS = [ os.path.join (BASE_DIR, "staticfiles"), ]
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
My models
class UserProfile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
# owner = models.ForeignKey(
# User,
# on_delete=models.CASCADE,
# related_name='topic_content_type'
# )
name = models.CharField(max_length=200)
avatar = models.ImageField(default='default.jpg', upload_to='static/images')
def __str__(self):
return self.user.username
i try to put file in media either, but even when i have media in my folder and have the right path, it still doesn't work. i run local host with postgres db.
How can i use static file in my folder, don't need to use collectstatic everytime i put more file in static.