Skip to main content

Django Extensions

Project description

Django Ext

Some extensions for Django.

Models

TimestampModel

Add created_at and updated_at for model.

TimeRangeModel

Add started_at and ended_at for model.

UserTrackModel

Add created_by and update_by for model.

This model requires django-currentuser, and should add it to the middleware classes in your settings.py:

MIDDLEWARE = (
    ...,
    'django_currentuser.middleware.ThreadLocalUserMiddleware',
)

ExtraFieldsManager

ExtraFieldsManager is intended to be used in conjunction with ExtraFieldsQuerySet to filter extra added fields using custom filter conditions.

While initializing the ExtraFieldsManager class, it is necessary to use the fields parameter to specify extra fields and their corresponding filter conditions generation functions.

Usage:

class MyModel(models.Model):
    relation = models.ForeignKey(RelationModel, models.CASCADE, +, null=False)

    objects = ExtraFieldsManager(fields={
        # users: an extra field that is not present in the model
        # lambda function: used to generate complex query conditions
        'users': lambda x: Q(relation__data__users__contained_by=[str(user.id) for user in x]) | \
        Q(relation__data__groups__contained_by=Group.objects.filter(user__in=x).distinct().values_list('id', flat=True))
    })

Commands

translate

Translate the permission names into the local language.

$ python manage.py translate

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_ext-0.12.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_ext-0.12-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file django_ext-0.12.tar.gz.

File metadata

  • Download URL: django_ext-0.12.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.14

File hashes

Hashes for django_ext-0.12.tar.gz
Algorithm Hash digest
SHA256 ea8b0b5aa83b28daa7a98873275768fed35d8bdb4783b08ef673bf77752e94d1
MD5 c3f7eb1826464de0fe5193b43e9e3cb2
BLAKE2b-256 807421c35b1c5adb2a11676e396b7aff7aace88b9b5c2be1e6414fd9a9c9ee02

See more details on using hashes here.

File details

Details for the file django_ext-0.12-py3-none-any.whl.

File metadata

  • Download URL: django_ext-0.12-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.14

File hashes

Hashes for django_ext-0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 c6fe8a82fef255c4847bf08a17b2e902fc74b13c06f2c8cacd5df8fbb723e114
MD5 a13987af4002bf06b535884d61a8456a
BLAKE2b-256 fe0dc78dbf41fa181edd6b6e7c888ff41452bee73f53362ac14d741e02079ad0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page