Begun GridFS documentation
This commit is contained in:
parent
67a9b358a0
commit
dc7181a3fd
26
docs/guide/gridfs.rst
Normal file
26
docs/guide/gridfs.rst
Normal file
@ -0,0 +1,26 @@
|
||||
======
|
||||
GridFS
|
||||
======
|
||||
GridFS support comes in the form of the :class:`~mongoengine.FileField` field
|
||||
object. This field acts as a file-like object and provides a couple of
|
||||
different ways of inserting and retrieving data. Metadata such as content-type
|
||||
can also be stored alongside the stored files. In the following example, an
|
||||
document is created to store details about animals, including a photo:
|
||||
|
||||
class Animal(Document):
|
||||
genus = StringField()
|
||||
family = StringField()
|
||||
photo = FileField()
|
||||
|
||||
marmot = Animal('Marmota', 'Sciuridae')
|
||||
|
||||
marmot_photo = open('marmot.jpg') # Retrieve a photo from disk
|
||||
marmot.photo = marmot_photo # Store the photo in the document
|
||||
|
||||
marmot.save()
|
||||
|
||||
So adding file data to a document is as easy as adding data to any other
|
||||
|
||||
.. versionadded:: 0.4
|
||||
|
||||
|
@ -10,3 +10,4 @@ User Guide
|
||||
defining-documents
|
||||
document-instances
|
||||
querying
|
||||
gridfs
|
||||
|
@ -78,7 +78,6 @@ class User(Document):
|
||||
|
||||
# Normalize the address by lowercasing the domain part of the email
|
||||
# address.
|
||||
# Not sure why we'r allowing null email when its not allowed in django
|
||||
if email is not None:
|
||||
try:
|
||||
email_name, domain_part = email.strip().split('@', 1)
|
||||
|
@ -20,6 +20,7 @@ __all__ = ['StringField', 'IntField', 'FloatField', 'BooleanField',
|
||||
|
||||
RECURSIVE_REFERENCE_CONSTANT = 'self'
|
||||
|
||||
|
||||
class StringField(BaseField):
|
||||
"""A unicode string field.
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user