#Question❓
imagefielddan keladigan rasmni o'zim xohlagandek nomlab saqlab qo'yishim uchun nima qilishni tavsiya berasizlar?
#solution✅
def get_path(instance,filename):
return "site_media/jobs/%s_%s/%s" % (instance.client, instance.job_number, filename)
class CCEntry(models.Model):
....
pdf = models.FilePathField(path=get_path, match=".*\.pdf$", recursive=True)
imagefielddan keladigan rasmni o'zim xohlagandek nomlab saqlab qo'yishim uchun nima qilishni tavsiya berasizlar?
#solution✅
def get_path(instance,filename):
return "site_media/jobs/%s_%s/%s" % (instance.client, instance.job_number, filename)
class CCEntry(models.Model):
....
pdf = models.FilePathField(path=get_path, match=".*\.pdf$", recursive=True)
ѕнυĸυralι
Assalomu Alaykum #savolboredi list ga objectlar terib chiqilgan tartib buyicha ,hozir shu tartib buzilmagan holda Model da mavjud bulgan objectlarni listdan olishim kere . Qanday qilsam buladi shuni ? hozir men: any_list = [obj1,obj2,obj9,obj4...] Es…
Stack Overflow
Sort queryset by values in list
Is it possible to sort a django queryset by the list of elements provided in the query?
For example, if I do
m.objects.filter(id__in=[3,1,8])
I wan't the order of the queryset to be the element ...
For example, if I do
m.objects.filter(id__in=[3,1,8])
I wan't the order of the queryset to be the element ...