Install the pip package:
pip install django-simplefeedback
Install django-rest-framework
if not already installed
add simple_feedback
and rest_framework
to INSTALLED_APPS
include 'simple_feedback.urls' into urlpatterns
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path("api/", include("simple_feedback.urls")),
]
Migrate the db to crate simple-feedback models
python manage.py migrate
SIMPLE_FEEDBACK_NOTIFICATIONS_ENABLED
default: False
It needs to be enabled explicitly in settings to send out emails.
SIMPLE_FEEDBACK_SEND_TO
- email string or a list of email strings
valid examples:
SIMPLE_FEEDBACK_SEND_TO =
SIMPLE_FEEDBACK_SEND_TO = '[email protected]'
SIMPLE_FEEDBACK_SEND_TO = ['[email protected]', '[email protected]']
When SIMPLE_FEEDBACK_SEND_TO is empty or not defined, the email recepients will be all the superusers in the system.
SIMPLE_FEEDBACK_SEND_MAIL_FUNC_OVERRIDE
- function to send email with
needs to implement two kwargs message
and recipients
valid example:
settings.py:
SIMPLE_FEEDBACK_SEND_MAIL_FUNC_OVERRIDE = send_email_function
def send_email_function(message, recipients):
send_email()
Clone the repo
git clone [email protected]:pulilab/django-simple-feedback.git
Test standalone app:
$ export DATABASE_URL='your_db' # you can skip this, defaults to 'localhost' (use postgres.app for simplicity)
$ pip install -r requirements.txt
$ python runtests.py
Create a new django project and install the package in develop mode
django-admin startproject simple_feedback_demo
cd simple_feedback_demo
pip install -e ~LOCAL_PATH_TO_DJANGO_SIMPLEFEEDBACK
Add simple_feedback
and rest_framework
to INSTALLED_APPS
in settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'simple_feedback'
]
Configure demo app urls
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path("api/", include("simple_feedback.urls")),
]
SqlLite is not supported
Change the db config to use postgres in settings.py
:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'postgres',
'USER': 'postgres',
'HOST': os.environ.get("DATABASE_URL", 'localhost'),
'PORT': 5432,
}
}
Migrate db, create super user and run your demo app:
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
open the browser at http://localhost:8000/admin