Skip to main content

django-dbmessages

Almost like django.contrib.messages, but doesn’t need request to message a user.

In fact, django-dbmessages is but a very thin and simple layer on top of Django’s contrib.messages.

To message a user, you simply create and save an instance of provided Message model via shell, Django admin, or some other means.

Message model has all the same attributes you’d normally pass to contrib.messages (level, message, extra_tags), and in addition a ForeignKey link to User model.

The next time given user appears on the site, middleware provided by dbmessages checks if user has any messages for them, and adds them to request using regular contrib.messages API. Then it deletes those messages from the DB. Simple as that.

Quick start

  1. Make sure to enable Django’s contrib.messages in your project (check the docs).

  2. Install django-dbmessages (it’s on PyPI).

  3. Add 'dbmessages' to your INSTALLED_APPS and 'dbmessages.middleware.DBMessageMiddleware' to MIDDLEWARE_CLASSES.

  4. Synchronize (or migrate) the DB.

Now you can get into shell and address a message to yourself:

>>> from dbmessages.models import Message
>>> from django.contrib import messages
>>> Message.objects.create(to_user=your_user, level=messages.INFO, message="Ahoy there")

Provided your front-end is integrated with Django’s contrib.messages, you should see the “Ahoy there” message the next time you log in under your account.

Metadata

Release files for django-dbmessages 0.1.1

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-dbmessages 0.1.1
File Size Uploaded
django-dbmessages-0.1.1.tar.gz 6.7 kB Details

Release files / django-dbmessages-0.1.1.tar.gz

Download URL django-dbmessages-0.1.1.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b7711dc37e3dad2f6635d5d20da8e2e87a42e99edab6c6f636883e5094f75348
BLAKE2b-256 checksum
How to use checksums
7a9681f1c407c98637cc476145fcd8a10a5c1099a5fb30154858a2b8c24a12dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1.0

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