Skip to main content

Bring services to Django

Project description

dj-services

Build Status Coverage Status PEP8 Documentation Status

Thanks to this library, you can build your business logic in beautiful services, not in huge views and fat models.

Summary

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!

Running the tests

If you want to run the tests you need to run the following command:

$ ./manage.py test tests.base

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

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

dj-services-0.2.0.tar.gz (5.1 kB view hashes)

Uploaded Source

Supported by

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