Reputation: 2406
I need to use a get()
to select an object by comparing it with a FILE request:
My models:
class Work (models.Model):
file = models.FileField(storage=OverwriteStorage(), upload_to=path)
class Group(models.Model):
members = models.ManyToManyField(User, related_name='group_list', null=True, blank=True)
I have tried: var = mygroup.work_list.get(file=request.FILES['file'])
With the same file: Work matching query does not exist
I prefer in reality to compare the name of file but that doesn't works too:
var = mygroup.work_list.get(file__name=request.FILES['file'].name)
It seems I can't make a request whith informations about file, I have tried with size Join on field 'file' not permitted. Did you misspell 'size' for the lookup type?
I have the same message with name...
Upvotes: 3
Views: 427
Reputation: 9917
You can try generating and storing a md5-hash of the file and compare with this key.
Upvotes: 1
Reputation: 2406
I have found : var = mygroup.work_list.get(file=path+'/'+request.FILES['file'].name)
Upvotes: 0