Bring services to Django
Project description
dj-services
Thanks to this library, you can build your business logic in beautiful services, not in huge views and fat models.
Getting Started
Install this library using pip
$ pip install dj-services
Create services.py
module in your Django app and create your first service
# services.py
from djservices import CRUDService
from .models import MyModel
from .forms import MyForm
class MyService(CRUDService):
model = MyModel
form = MyForm
After that you can use this service in views.py
# views.py
from django.shortcuts import render
from .services import MyService
def list_entries(request):
service = MyService()
entries = service.get_all()
return render(request, 'some_template.html', {'entries': entries})
That's all. Now you can add business logic in your service. Let's go!
Documentation
You can read documentation in this repository wiki
Running the tests
If you want to run the tests you need to run the following command:
$ ./manage.py test
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Artyom Loskan - artemowkin
See also the list of contributors who participated in this project.
License
This project is licensed under the GNU General Public License v3.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file dj-services-2.0.0.tar.gz
.
File metadata
- Download URL: dj-services-2.0.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4033274bf8a4d292ea3e5a110eb62a408376aee29fbad3b91831eefb06892187 |
|
MD5 | 9448db36a23516a1a8bcd88e09181ed5 |
|
BLAKE2b-256 | 28741db82f497b3510d659bd6106e4f40001bd3b0effa84e89ab504df73dd94d |