Skip to main content

Sloop

This package contains some tools that will ease the implementation of push notifications using AWS SNS and other backends into django projects.

Django-Sloop

Installation

  1. Install the package via Github or PIP (pip install django-sloop)

  2. Add django_sloop to the INSTALLED_APPS list in the settings file.

  3. Extend the django_sloop.models.AbstractSNSDevice class and create your own push token device model.

# models.py

from django_sloop.models import AbstractSNSDevice


class Device(AbstractSNSDevice):
    pass
    
    # (Optional) if you need to override Meta.
    class Meta(AbstractSNSDevice.Meta):
        pass
  1. Make sure that you fill necessary information at the settings file:
# settings.py

DJANGO_SLOOP_SETTINGS = {
    "AWS_REGION_NAME": "",
    "AWS_ACCESS_KEY_ID": "",
    "AWS_SECRET_ACCESS_KEY": "",
    "SNS_IOS_APPLICATION_ARN": "test_ios_arn",
    "SNS_IOS_SANDBOX_ENABLED": False,
    "SNS_ANDROID_APPLICATION_ARN": "test_android_arn",
    "LOG_SENT_MESSAGES": False,  # False by default.
    "DEFAULT_SOUND": "",
    "DEVICE_MODEL": "module_name.Device",
}

You cannot change the DEVICE_MODEL setting during the lifetime of a project (i.e. once you have made and migrated models that depend on it) without serious effort. The model it refers to must be available in the first migration of the app that it lives in.

  1. Create migrations for newly created Device model and migrate.

Note: django_sloop's migrations must run after your Device is created. If you run into a problem while running migrations add following to the your migration file where the Device is created.

run_before = [
   ('django_sloop', '0001_initial'),
]
  1. Add django_sloop.models.PushNotificationMixin to your User model.
class User(PushNotificationMixin, ...):
    pass

user.send_push_notification_async(message="Sample push notification.")
  1. Add django_sloop.admin.SloopAdminMixin to your UserAdmin to enable sending push messages to users from Django admin panel.
# admin.py

from django_sloop.admin import SloopAdminMixin
from django.contrib import admin

class UserAdmin(SloopAdminMixin, admin.ModelAdmin):
    
    actions = ("send_push_notification", )
    
  1. Add django rest framework urls to create and delete device.
# urls.py
from django.urls import path
from django.urls import include

urlpatterns = [
    # ...
    path('api/devices/', include('django_sloop.urls')),
    # ...
]

Done!

Release files for django-sloop 1.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-sloop 1.0.7
File Size Uploaded
django-sloop-1.0.7.tar.gz 16.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-sloop 1.0.7
File Interpreter ABI Platform
django_sloop-1.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 35.4 kB

Release files / django-sloop-1.0.7.tar.gz

Download URL django-sloop-1.0.7.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
74feecb06afae7c4ca24b75bdc478d0bdc5c477476d580095f50acd990bb1211
BLAKE2b-256 checksum
How to use checksums
dfd552d8cb6894ae8f108cb68a124d463c22cc949087acb06e342a21f38b6943
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / django_sloop-1.0.7-py3-none-any.whl

Download URL django_sloop-1.0.7-py3-none-any.whl
Size 19.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1b9df1295a00b5734ad79097d4fa427d903d2c0b33fedd1694e6a8a29609c70d
BLAKE2b-256 checksum
How to use checksums
22af23c6bf9a5f05fce85a39f197926cc7dc9381edc83475da6687153a4c2fe1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

1.0.7 This release

2 release files

1.0.6

2 release files

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page