db.models.FilePathField.path

FilePathField.path Required. The absolute filesystem path to a directory from which this FilePathField should get its choices. Example: "/home/images".

db.models.FilePathField.match

FilePathField.match Optional. A regular expression, as a string, that FilePathField will use to filter filenames. Note that the regex will be applied to the base filename, not the full path. Example: "foo.*\.txt$", which will match a file called foo23.txt but not bar.txt or foo23.png.

db.models.FilePathField.allow_folders

FilePathField.allow_folders Optional. Either True or False. Default is False. Specifies whether folders in the specified location should be included. Either this or allow_files must be True. Of course, these arguments can be used together. The one potential gotcha is that match applies to the base filename, not the full path. So, this example: FilePathField(path="/home/images", match="foo.*", recursive=True) ...will match /home/images/foo.png but not /home/images/foo/bar.png because the mat

db.models.FilePathField.allow_files

FilePathField.allow_files Optional. Either True or False. Default is True. Specifies whether files in the specified location should be included. Either this or allow_folders must be True.

db.models.FilePathField

class FilePathField(path=None, match=None, recursive=False, max_length=100, **options) [source] A CharField whose choices are limited to the filenames in a certain directory on the filesystem. Has three special arguments, of which the first is required:

db.models.FileField.upload_to

FileField.upload_to This attribute provides a way of setting the upload directory and file name, and can be set in two ways. In both cases, the value is passed to the Storage.save() method. If you specify a string value, it may contain strftime() formatting, which will be replaced by the date/time of the file upload (so that uploaded files don’t fill up the given directory). For example: class MyModel(models.Model): # file will be uploaded to MEDIA_ROOT/uploads upload = models.FileFi

db.models.FileField.storage

FileField.storage A storage object, which handles the storage and retrieval of your files. See Managing files for details on how to provide this object. The default form widget for this field is a ClearableFileInput. Using a FileField or an ImageField (see below) in a model takes a few steps: In your settings file, you’ll need to define MEDIA_ROOT as the full path to a directory where you’d like Django to store uploaded files. (For performance, these files are not stored in the database.) De

db.models.FileField

class FileField(upload_to=None, max_length=100, **options) [source] A file-upload field. Note The primary_key and unique arguments are not supported, and will raise a TypeError if used. Has two optional arguments:

db.models.fields.related.RelatedManager.set()

set(objs, bulk=True, clear=False) New in Django 1.9. Replace the set of related objects: >>> new_list = [obj1, obj2, obj3] >>> e.related_set.set(new_list) This method accepts a clear argument to control how to perform the operation. If False (the default), the elements missing from the new set are removed using remove() and only the new ones are added. If clear=True, the clear() method is called instead and the whole set is added at once. The bulk argument is passed on t

db.models.fields.related.RelatedManager.remove()

remove(*objs) Removes the specified model objects from the related object set: >>> b = Blog.objects.get(id=1) >>> e = Entry.objects.get(id=234) >>> b.entry_set.remove(e) # Disassociates Entry e from Blog b. Similar to add(), e.save() is called in the example above to perform the update. Using remove() with a many-to-many relationship, however, will delete the relationships using QuerySet.delete() which means no model save() methods are called; listen to the m2m_ch