No project description provided
Project description
A small framework helping to write reusable Django applications using generic relations
Home-page: https://github.com/marazmiki/django-generic-helpers
Author: Mikhail Porokhovnichenko
Author-email: marazmiki@gmail.com
License: MIT license
Download-URL: DOWNLOAD_URL
Description: ======================
django-generic-helpers
======================
.. image:: https://badge.fury.io/py/django-generic-helpers.png
:target: http://badge.fury.io/py/django-generic-helpers
.. image:: https://travis-ci.org/marazmiki/django-generic-helpers.png?branch=master
:target: https://travis-ci.org/marazmiki/django-generic-helpers
.. image:: https://coveralls.io/repos/marazmiki/django-generic-helpers/badge.png?branch=master
:target: https://coveralls.io/r/marazmiki/django-generic-helpers?branch=master
.. image:: https://pypip.in/d/django-generic-helpers/badge.png
:target: https://pypi.python.org/pypi/django-generic-helpers
.. image:: https://pypip.in/wheel/django-generic-helpers/badge.svg
:target: https://pypi.python.org/pypi/django-generic-helpers/
:alt: Wheel Status
.. image:: https://pypip.in/py_versions/django-generic-helpers/badge.png
:target: https://pypi.python.org/pypi/django-generic-helpers/
:alt: 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
============
.. code:: bash
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:
.. code:: python
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:
.. code:: python
>>> 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:
.. code:: python
>>> 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!
Platform: OS Independent
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 1.10
Classifier: Framework :: Django :: 1.11
Classifier: Framework :: Django :: 2.0
Classifier: Framework :: Django :: 2.1
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Home-page: https://github.com/marazmiki/django-generic-helpers
Author: Mikhail Porokhovnichenko
Author-email: marazmiki@gmail.com
License: MIT license
Download-URL: DOWNLOAD_URL
Description: ======================
django-generic-helpers
======================
.. image:: https://badge.fury.io/py/django-generic-helpers.png
:target: http://badge.fury.io/py/django-generic-helpers
.. image:: https://travis-ci.org/marazmiki/django-generic-helpers.png?branch=master
:target: https://travis-ci.org/marazmiki/django-generic-helpers
.. image:: https://coveralls.io/repos/marazmiki/django-generic-helpers/badge.png?branch=master
:target: https://coveralls.io/r/marazmiki/django-generic-helpers?branch=master
.. image:: https://pypip.in/d/django-generic-helpers/badge.png
:target: https://pypi.python.org/pypi/django-generic-helpers
.. image:: https://pypip.in/wheel/django-generic-helpers/badge.svg
:target: https://pypi.python.org/pypi/django-generic-helpers/
:alt: Wheel Status
.. image:: https://pypip.in/py_versions/django-generic-helpers/badge.png
:target: https://pypi.python.org/pypi/django-generic-helpers/
:alt: 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
============
.. code:: bash
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:
.. code:: python
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:
.. code:: python
>>> 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:
.. code:: python
>>> 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!
Platform: OS Independent
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 1.10
Classifier: Framework :: Django :: 1.11
Classifier: Framework :: Django :: 2.0
Classifier: Framework :: Django :: 2.1
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-generic-helpers-1.0.0.tar.bz2
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c226a08e47c7d7d037b3b04bb8030b658c49deed20be92c6745761aae9bdbe1 |
|
MD5 | f4bc1a62fd413b05f5b4ef3fd3768c4d |
|
BLAKE2b-256 | e51c7c09e940970f1d29c6420e650d128699a4bd54c8144526ccf90111706386 |
Close
Hashes for django_generic_helpers-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7f7543bdb5f2b3fd4d8065f05e8c8a22640f902f3e1bf5b0d4d177b3f97ee29 |
|
MD5 | e59fbef492688e210e1f091f07c30a6c |
|
BLAKE2b-256 | 9748d0d5958b7a4a8853561616e93a8cace0263a7fa31a9759c0248e8c82ad5b |