-
-
AbstractBaseModel
same as django's defaultdjango.db.models.Model
but contains additional methods and fields.- field
creation_date
: Stores creation date of the object. - field
update_date
: Stores last update date of the object. - method
set_request
||set_request(self, request: HttpRequest)
: Sets request object in model so that it used be used internally or by inherited models. Request object is stored in_request
which can be accessed throughget_request()
. - method
get_request
||get_request(self)
: Gets request object in model so that it used be used internally or by inherited models. - method
humanized_creation_date
||humanized_creation_date(self)
: Getscreation_date
as3 days ago
,hour ago
etc. - method
humanized_update_date
||humanized_update_date(self)
: Getsupdate_date
as3 days ago
,hour ago
etc. - method
is_new
||is_new(self)
: returnsTrue
if the object is being created. returnsFalse
if the object is being updated. - method
get_fields
||get_fields(self, as_list=False, include_parents=True, include_hidden=False) -> (dict, list)
: returns name of fields asdict
, if passedas_list=False
, thenlist
will be returned. - method
serialize
||serialize(self, fields: dict = None, exclude: iter = None, format_: str = "json") -> dict
: returns model data in provided format, available format:["json"]
(Other format support will be added soon). - method
get_excluded_fields
||get_excluded_fields(self)
: Override this method to return excluded fields, these fields will never be included when using serialize, even if field name is passed. Please refer to docstrings and comments for more info.
- field
-
AbstractBaseUUIDModel
contains all features ofAbstractBaseModel
except primary key datatype is changed toUUID
.- field
id
: same as django model default pk, exceptdefault=uuid.uuid4
is set for creating unique value by default.
- field
-
- constant field
SLUG_FROM_FIELD
: field provided will be used for creatingslug by default
, random hex value will be appended at the end. - field
slug
: stores slug for the object, will be auto generated if not set usingSLUG_FROM_FIELD
value. - method
get_slug_value
||get_slug_value(self)
: is used internally to get slug value, override this if you wish to change howslug
is formed.Slug must be unique
- constant field
-
-
-
JsonModelForm
same as django'sdjango.forms.ModelForm
, But contains additional features and accepts optionalrequest
as keyword argument when initializing the form.- method
pre_init
||pre_init(self)
: override this method to run code after the form is initialized. - method
post_init
||post_init(self)
: override this method to run code before the form is initialized. - method
get_request
||get_request(self)
: Gets therequest
object. If not setValueError will be raised
. - method
set_request
||set_request(self, request)
: Sets therequest
object. - method
get_errors
||get_errors(self, format_="json")
: Gets error in the format specified, for now supportsJSON
only. - method
set_field_attr
||set_field_attr(self, fields: list, attr: str, value=None)
: Sets field attribute in bulk,set_field_attr(self, fields: list, attr: str, value=None)
;value
will be set to theeach field
'sattr
. - method
make_fields_required
||def make_fields_required(self, fields)
: Makes provided fields required.
- method
-
-
Notifications
You must be signed in to change notification settings - Fork 0
vaskrneup/django_contrib_common
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Django app for better managing API driven apps
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published