Answer the question
In order to leave comments, you need to log in
How to pass parameter to Django model?
Good day.
Available model
class Image(models.Model)
name = models.ImageField(upload_to='относительный каталог для файлов/', blank=True, verbose_name='подпись')
Answer the question
In order to leave comments, you need to log in
https://docs.djangoproject.com/en/2.0/ref/models/f...
def content_file_name(instance, filename):
return '/'.join(['content', instance.user.username, filename])
class Content(models.Model):
name = models.CharField(max_length=200)
user = models.ForeignKey(User)
file = models.FileField(upload_to=content_file_name)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question