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)
{{ some_list|slice:":2" }}
Если some_list равно ['a', 'b', 'c'], вернет ['a', 'b'].