Answer the question
In order to leave comments, you need to log in
Why are imports not visible?
There are a bunch of applications.
In one of the applications in models.py:
# -*- coding: utf-8 -*-
import os
from django.conf import settings
.....
#Имеется вот такой класс для загрузки изображения
#BaseModel - абстракт (описывает только привязку к юзеру)
class Image(BaseModel):
def file_uploads_to(instance, filename):
#from django.conf import settings
#import os
file_name = '/'.join(['dir', instance.user.id, 'image', filename])
file_folder = os.path.join(settings.MEDIA_ROOT, 'dir/%s/image/' % instance.user.id,)
if not os.path.exists(file_folder):
os.makedirs(file_folder)
return file_name
text = models.TextField('_(Info)', max_length=1000, blank=False, null=True, default='')
image = models.ImageField('_(Image)', upload_to=file_uploads_to, blank=True)
class Meta:
.....
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question