mirror of
https://github.com/django/django.git
synced 2025-11-02 04:48:33 +00:00
Refs #28643 -- Added MD5 database function.
Thanks Tim Graham, Nick Pope and Simon Charette for reviews.
This commit is contained in:
parent
21ff23bfeb
commit
9ff18c08c3
6 changed files with 85 additions and 5 deletions
|
|
@ -1303,6 +1303,26 @@ Usage example::
|
|||
Similar to :class:`~django.db.models.functions.Trim`, but removes only leading
|
||||
spaces.
|
||||
|
||||
``MD5``
|
||||
-------
|
||||
|
||||
.. class:: MD5(expression, **extra)
|
||||
|
||||
.. versionadded:: 3.0
|
||||
|
||||
Accepts a single text field or expression and returns the MD5 hash of the
|
||||
string.
|
||||
|
||||
It can also be registered as a transform as described in :class:`Length`.
|
||||
|
||||
Usage example::
|
||||
|
||||
>>> from django.db.models.functions import MD5
|
||||
>>> Author.objects.create(name='Margaret Smith')
|
||||
>>> author = Author.objects.annotate(name_md5=MD5('name')).get()
|
||||
>>> print(author.name_md5)
|
||||
749fb689816b2db85f5b169c2055b247
|
||||
|
||||
``Ord``
|
||||
-------
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue