Skip to main content

Django Models

Para visualizar o README em português.

PyPI latest PyPI Version PyPI License GitHub Actions Status Coverage Docs Open Source? Yes!

Django Models is a Library with several useful Models for Django to help you make your templates smart or with less code

Requirements

  • Python 3.10 or later

  • Django 5.0 to 6.x

Features

Generic Models

  • ActiveModel

    Model with is_active boolean field

  • CodeModel

    Model with a code field that automatically generates a hash of 16 characters by default. Useful to identify your record in a more humane way

  • SerializerModel

    Model to return a dict with all data of your django instance without a serializer.

Example:

Your Model

from django_models.models import SerializerModel
...

class YourModel(SerializerModel)
    name = models.CharField(max_length=255)
    ...

Usage

In[1]: from . import YourModel
In[2]: instance = YourModel.objects.first()
In[3]: user.serialize()
Out[3]: {'id': 1, 'name': 'first record', ...}
  • SlugModel

    Model with a slug field. Useful to use in urls or nominal references

  • TimestampedModel

    Model with the DateTime, created_at and updated_at fields. Useful to control when any changes were made.

  • UUIDModel

    Model that uses the id field as a UUID. Useful to be able to have a unique identifier without worrying about sequences.

History models

  • HistoryModel Model that tracks each save to generate a Change History of a record

Signals Models

With SignalsModel it allows you to handle or execute an event according to Django’s Signals.

On Save:
  • pre_save (Before Saving)

  • post_save (After Saving)

On Delete:
  • pre_delete (Before Deleting)

  • post_delete (After Deleting)

Example using Pre-save signal

Note: This will be made before you save your model

from django_models.models import SignalsModel
...

class YourModel(SignalsModel)
    ...
    def pre_save(self):
        do_something()

Soft Delete Signal Model

  • SoftDeleteSignalModel Models

    It is the SignalsModel with soft delete implemented. Ensures that nothing you delete is really deleted from the system and easy to recover

How to install

Getting It

You can get Django Models by using pip:

$ pip install django-models

If you want to install it from source, grab the git repository from GitHub and run setup.py:

$ git clone git@github.com:rhenter/django_models.git
$ cd django_models
$ python setup.py install

Settings

To enable django_models in your project you need to add it to INSTALLED_APPS in your projects settings.py file:

INSTALLED_APPS = (
    ...
    'django_models',
    ...
)

Documentation

Check out the latest django-models documentation at GitHub Pages

Contributing

Please send pull requests, very much appreciated.

  1. Fork the repository on GitHub.

  2. Make a branch off of master and commit your changes to it.

  3. Install requirements. pip install -r requirements-dev.txt

  4. Install pre-commit. pre-commit install

  5. Run the tests with cd test-django-project; py.test -vv -s

  6. Create a Pull Request with your contribution

Metadata

Release files for django-models 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-models 1.1.1
File Size Uploaded Provenance Actions
django_models-1.1.1.tar.gz 19.9 kB Without provenance Details for django_models-1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-models 1.1.1
File Interpreter ABI Platform Actions
django_models-1.1.1-py3-none-any.whl Python 3 none any Details for django_models-1.1.1-py3-none-any.whl

Total release size: 38.7 kB

Release files / django_models-1.1.1.tar.gz

Download URL django_models-1.1.1.tar.gz
Size 19.9 kB
Tags Source
SHA-256 checksum
How to use checksums
26ae89ff74ea88b5ea04af087ea673920b73b9c750f034c3135a5e74e9903255
BLAKE2b-256 checksum
How to use checksums
35e97b0f707b769dfc570deb53e76dd5b410a0828a415ae2c539049829fe6a37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / django_models-1.1.1-py3-none-any.whl

Download URL django_models-1.1.1-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
854d490ae56194d84a163ff2aecf1f3a219173f9791322da7e1b9b68543b5ea6
BLAKE2b-256 checksum
How to use checksums
1c886a5d2ecd7a549a78675077a26e630f4eb6ebd9ca3ad51d9505da26a94bf5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for django-models 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page