Swingers’ custom models, abstract models, model managers, etc.
A constant that indicates whether any of the currently defined databases is GEO-enabled as well as django.contrib.gis being in settings.INSTALLED_APPS.
If GIS_ENABLED, then swingers.base.models imports * from django.contrib.gis.db.models as well as redefines GeoManager as Manager, ActiveGeoModel as ActiveModel and ActiveModelManager as ActiveModelManager. All these redefinitions can be overwritten by importing from the base django/swingers modules. If not GIS_ENABLED, the swingers.base.models imports * from django.db.models and exports ActiveModel and ActiveManager.
Audit is an abstract Django model that handles adding additional auditing attributes to any model that inherits from it. It will automatically version any changes and update the time it was modified and who it was modified by. This makes it easy to see a list of changes and roll back changes that were unintended.
The datetime that this model instance was created on.
The datetime that this model instance was last modified on.
Extends FileField and adds validation for two additional things:
To specify either of these things, add them to the constructor of your model field. Example usage:
from django.db import models
class Application(models.Model):
name = models.CharField(max_length=30)
approved = models.BooleanField()
passport_photo = ContentTypeRestrictedField(
content_types=['image/jpeg'], max_upload_size=10485760)
This will restrict the file uploaded to be a JPEG image of no more than 10MiB.* ContentTypeRestrictedFileField
Default model manager for the ActiveModel. It excludes the inactive (“deleted”) objects from the queryset.
Similar to ActiveModelManager but for Geo models.
A model mixin to allow objects to be saved as ‘non-current’ or ‘inactive’. This will preserve the instance in the database when it is deleted. The standard delete() method is overridden and when an object is removed, sets the models’ effective_to as the current datetime.
The time from which this object is effective from. Allows ‘past’ and/or ‘future’ objects to be saved.
This is only set once the model has been deleted. When deleted, effective_to is set to the datetime that the model was tagged as deleted on.
A custom objects manager ActiveManager that excludes the ‘inactive’ objects.
A default Manager class that includes all objects (including the ‘inactive/deleted’ ones).
Returns True if an object is not deleted.
Returns True if an object is deleted.
Similar to ActiveModel but for Geo models.
Generic class for supporting documents. It can be attached to any other object via GenericForeignKey.
Return the file name of the uploaded file, minus the server file path.
Return the file extension of the uploaded file.
Return the filesize as a nicely human-readable string (kB, MB, GB, etc.).
A model mixin to provide a polygon field called the_geom with a default SRID of 4326 (WGS84).
The PolygonField for this class.
A model mixin to provide a line string spatial field called the_geom with a default SRID of 4326 (WGS84).
The LineStringField for this class.
A model mixin to provide a point spatial field called the_geom with a default SRID of 4326 (WGS84).
The PointField for this class.