Service objects for Django
Likely abandoned. No release or commit for years (last release over 4 years ago).
pip install django-service-objectsdjango-service-objects 
Service objects for Django
What?
This is a small library providing a Service base class to derive your service objects from. What are service objects? You can read more about the whys and hows in this blog post, but for the most part, it encapsulates your business logic, decoupling it from your views and model methods. Put your business logic in service objects.
Installation guide
Install from pypi:
pip install django-service-objects
Add service_objects to your INSTALLED_APPS:
# settings.py
INSTALLED_APPS = (
...
'service_objects',
...
)
Example
Let's say you want to register new users. You could make a CreateUser service.
from django import forms
from service_objects.services import Service
class CreateUser(Service):
email = forms.EmailField()
password = forms.CharField(max_length=255)
subscribe_to_newsletter = forms.BooleanField(required=False)
def process(self):
email = self.cleaned_data['email']
password = self.cleaned_data['password']
subscribe_to_newsletter = self.cleaned_data['subscribe_to_newsletter']
self.user = User.objects.create_user(username=email, email=email, password=password)
self.subscribe_to_newsletter = subscribe_to_newsletter
if self.subscribe_to_newsletter:
newsletter = Newsletter.objects.get()
newsletter.subscribers.add(self.user)
newsletter.save()
return self.user
def post_process(self):
WelcomeEmail.send(self.user, is_subscribed=self.subsribe_to_newsletter)
# Calling a celery task after successfully creating the user.
create_billing_account.delay(self.user.id)