Django FilePathField filter used entries
I have the following Model where the FilePathField should be unique: class Gallery(models.Model): template = models.FilePathField(path=".../templates/galleries/", unique=True) In the admin, I would like the dropdown list to only show me those entries that have not been used, yet, in order to make the selection among available answers more easy. After all, any already used option in the resulting dropdown list will give me an error anyway and does not need to be shown to me in the admin. Unfortunately I am having problems wrapping my head around this. Can anyone tell me where I could insert something similar to the following: used = [gallery.template for gallery in Gallery.objects.all()] return [file for file in files if file not in used] ...or might I have overseen an option somewhere in Django that could already give me the desired result?
How to listen for an AUDIO file using Python and Selenium Webdriver
Storing Encrypted Data On A MySQL Database with Python, Pandas and SQLAlchemy [Connection Lost]
How to make python decorators work like a tag to make function calls “by tag”
Pandas - Remove index column
Setting SublimeRepl to work inside venv (sublime 3)
python-docx get info from dropdownlist (in table)
Creating audio file with gTTS for Google Speech API [duplicate]
Python: Make raw input remember commands [duplicate]
Can Omnicomplete in Vim for python/3 complete function names or just methods?
Slowness on iterating over namedtuple and dicts for defined pairs
I'm trying to put these inputs into a text file, [duplicate]
Printing Dictionaries? [closed]
OpenCV's frame count always printing 0
Including first and last elements in list comprehension
how to see output history on pycharm?
plotting just a single rgb color in matplotlib