Skip to main content

The small frameworks that helps to write reusable django apps with generic relations

Project description

https://badge.fury.io/py/django-generic-helpers.png https://travis-ci.org/marazmiki/django-generic-helpers.png?branch=master https://coveralls.io/repos/marazmiki/django-generic-helpers/badge.png?branch=master https://pypip.in/d/django-generic-helpers/badge.png Wheel Status Supported Python versions

This app provides some snippets (such as abstract models and managers with some useful methods) to simplyfy creation of another pluggable apps.

The license is MIT.

Installation

pip install django-generic-helpers

After you can add the generic_helpers app into your INSTALLED_APPS. If you aren’t want to run test, you can skip this step.

Usage

To use this app, just import GenericRelationModel class from generic_helpers.models package and inherit your model from it:

from django.db import models
from generic_helpers.models import GenericRelationModel

class MyModel(GenericRelationModel):
    title = models.CharField(max_length=255)

Now MyModel class has content_object attribute and you can create MyModel instances using generic relation:

>>> from django.contrib.auth.models import User
>>> user = User.objects.get(pk=1)
>>>
>>> my_model = MyModel.objects.create(title='title',
...                                   content_object=user)
>>>

In this example how you can see we have used User.

Also your model manager has a get_for_object method for quick filtering by content_object complex field:

>>> from django.contrib.auth.models import User
>>> user = User.objects.get(pk=1)
>>>
>>> models_for_user = MyModel.objects.get_for_object(user)
>>>

Contributing

If you’ve found a bug, implemented a feature and think it is useful, or you’ve own pluggable app and want to use django-generic-helpers in it, then please consider contributing. Patches, pull requests or just suggestions are welcome!

0.3.4

  • Remove deprecation warning

0.3.3

  • Moved the ct shortcut into utils module

0.3.2

  • Added CHANGELOG :)

  • Added Python 3.4x support;

  • Dropped Python 3.2x support;

  • Improved code styling with pep8;

  • Wheel available;

  • Coverage support;

  • Updated Django head version;

  • Fix 0.3.1 install bug (import six from django).

Project details


Download files

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

Source Distributions

django-generic-helpers-0.3.4.zip (12.7 kB view details)

Uploaded Source

django-generic-helpers-0.3.4.tar.gz (5.6 kB view details)

Uploaded Source

django-generic-helpers-0.3.4.tar.bz2 (5.8 kB view details)

Uploaded Source

Built Distribution

django_generic_helpers-0.3.4-py2.py3-none-any.whl (9.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-generic-helpers-0.3.4.zip.

File metadata

File hashes

Hashes for django-generic-helpers-0.3.4.zip
Algorithm Hash digest
SHA256 81e7931dc424b30367bb651b54d76e4d9d38234d02f2c770168a7a56ce27a54d
MD5 1b0f924b65c592f270fa99f8092bdf5b
BLAKE2b-256 2580d8bbfcd22c0101f365fcdd7fef2c594f7e0529bbc06e7a7fc24b3122567c

See more details on using hashes here.

File details

Details for the file django-generic-helpers-0.3.4.tar.gz.

File metadata

File hashes

Hashes for django-generic-helpers-0.3.4.tar.gz
Algorithm Hash digest
SHA256 6def4a9a2bf21f1c9743ab48bca4ddce5415c394c37232d8736e41ab226c30b3
MD5 3b4eff3abda25822a8dbc57d135292c9
BLAKE2b-256 fd96ebc828caf3a74751a2efbc49b35d2ae285cfb3f6874f441d542038dde1c5

See more details on using hashes here.

File details

Details for the file django-generic-helpers-0.3.4.tar.bz2.

File metadata

File hashes

Hashes for django-generic-helpers-0.3.4.tar.bz2
Algorithm Hash digest
SHA256 789f02f45f0a1d68954113c3c0a4e530d44991a3808797dbc8674464864d71f3
MD5 436dbfeeac3c6bab376ebe61470e8ffc
BLAKE2b-256 716e7da1b2f5807af3493e2b75f425dd590bcc9c321f54583d96e84a993db3f1

See more details on using hashes here.

File details

Details for the file django_generic_helpers-0.3.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_generic_helpers-0.3.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 744fb7b3fb740d7175cc12d790a65efa1f0b2905d4eab973cd64bf328f5bc8fe
MD5 6ebf3e5751fca0aa37d7d73ccb0363cc
BLAKE2b-256 4ea2ff49e9de134279d690f09185fcda871504d00fd6a95edf017126aba2803a

See more details on using hashes here.

Supported by

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