models module¶
-
class
models.User(*args, **kwargs)¶ Bases:
pymodm.base.models.MongoModelThis MongoModel store the data into database. :param email: EmailField to store user emails :param name: CharField to store user names :param images: ListField to store original images with their information including the base64 str of the images, filename, id, filetype, time stamp, image size and unaltered histograms. :param pro_images: ListField to store processed images with their information including base64 str of the images, filename, id, process type, time stamp, time duration and processed histograms.
-
exception
DoesNotExist¶ Bases:
pymodm.errors.DoesNotExist
-
exception
MultipleObjectsReturned¶ Bases:
pymodm.errors.MultipleObjectsReturned
-
email¶ A field that stores email addresses.
-
images¶ A field that stores a list.
-
name¶ A field that stores unicode strings.
-
objects¶ The default manager used for
MongoModelinstances.This implementation of
BaseManagerusesQuerySetas its QuerySet class.This Manager class (accessed via the
objectsattribute on aMongoModel) is used by default for all MongoModel classes, unless another Manager instance is supplied as an attribute within the MongoModel definition.Managers have two primary functions:
- Construct
QuerySetinstances for use when querying or working withMongoModelinstances in bulk. - Define collection-level functionality that can be reused across different MongoModel types.
If you created a custom QuerySet that makes certain queries easier, for example, you will need to create a custom Manager type that returns this queryset using the
from_queryset()method:class UserQuerySet(QuerySet): def active(self): '''Return only active users.''' return self.raw({"active": True}) class User(MongoModel): active = fields.BooleanField() # Add our custom Manager. users = Manager.from_queryset(UserQuerySet)
In the above example, we added a users attribute on User so that we can use the active method on our new QuerySet type:
active_users = User.users.active()
If we wanted every method on the QuerySet to examine active users only, we can do that by customizing the Manager itself:
class UserManager(Manager): def get_queryset(self): # Override get_queryset, so that every QuerySet created will # have this filter applied. return super(UserManager, self).get_queryset().raw( {"active": True}) class User(MongoModel): active = fields.BooleanField() users = UserManager() active_users = User.users.all()
- Construct
-
pro_images¶ A field that stores a list.
-
exception