tools, utilities, etc. we use across projects @ ckc
Project description
django-ckc
tools, utilities , etc. we use across projects @ ckc
installing
pip install django-ckc
# settings.py
INSTALLED_APPS = (
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.staticfiles",
# ... add ckc
"ckc",
)
distributing
# change version in setup.cfg
$ ./setup.py sdist
$ twine upload dist/*
tests
$ docker build -t django-ckc . && docker run django-ckc pytest
what's in this
SoftDeletableModel
Make your models have a deleted
bool set when they are deleted instead of actuallying
being deleted. Uses a model manager SoftDeleteModelManager
to keep them hidden.
DefaultUserCreateMixin
for ModelSerializers
This will automatically set YourModel.created_by
to request.user
. To override which
attribute the user is written to, add a user_field
to your classes Meta information
class YourModel(models.Model):
created_by = models.ForeignKey(User, on_delete=models.CASCADE)
class MySerializer(DefaultUserCreateMixin, ModelSerializer):
class Meta:
model = YourModel
DjangoGeoPointProvider
Helps generate geo points in Factory Boy factories.
# factories.py
class SomeLocationFactory(DjangoModelFactory):
location = factory.Faker('geo_point', country_code='US')
class Meta:
model = SomeLocation
# test_whatever.py
from django.contrib.gis.geos import Point
class WhateverTest(TestCase):
def test_something(self):
SomeLocationFactory() # random location
SomeLocationFactory(location=Point(x=60, y=60)) # specified location
./manage.py
commands
command | description |
---|---|
upload_file <source> <destination> |
uses django-storages settings to upload a file |
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
django-ckc-0.0.5.tar.gz
(7.1 kB
view hashes)