django-garpix-helpers

Django helpers.


Keywords
django, garpix, helpers
License
MIT
Install
pip install django-garpix-helpers==0.1.3

Documentation

Install

$ pip install django-garpix-helpers

Using

ActiveManager

Get only active objects.

In your model:

from garpix_helpers import ActiveManager

class MyModel(models.Model):
    ...
    is_active = models.BooleanField(default=True)
    active_objects = ActiveManager()

Querieng:

MyModel.active_objects.filter(...)

get_file_path

Slugified file names:

/uploads/YEAR/MONTH/SLUGIFIED_FILENAME.EXTENSION

In your model:

from garpix_helpers import get_file_path

class MyModel(models.Model):
    ...
    image = models.ImageField(upload_to=get_file_path)

Repository

https://github.com/Garpix/django-garpix-helpers

License

MIT