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.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.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.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.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.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.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.create()

create(**kwargs) Creates a new object, saves it and puts it in the related object set. Returns the newly created object: >>> b = Blog.objects.get(id=1) >>> e = b.entry_set.create( ... headline='Hello', ... body_text='Hi', ... pub_date=datetime.date(2005, 1, 1) ... ) # No need to call e.save() at this point -- it's already been saved. This is equivalent to (but much simpler than): >>> b = Blog.objects.get(id=1) >>> e = Entry( ... blog=b, .

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

clear() Removes all objects from the related object set: >>> b = Blog.objects.get(id=1) >>> b.entry_set.clear() Note this doesn’t delete the related objects – it just disassociates them. Just like remove(), clear() is only available on ForeignKeys where null=True and it also accepts the bulk keyword argument.