3👍
Below are the steps that will get you started with bare-minimum:
-
On the root directory (directory with
manage.py
)
python3 -m pip install django-postman
-
In
settings.py
:
INSTALLED_APPS = [
...,
# 'pagination' # has to be before postman
# ...
'postman',
# ...
# 'ajax_select'
# 'notification'
# 'mailer'
]
TEMPLATES = [
{
'...,
'DIRS': [BASE_DIR/ 'templates'],
...
},
]
-
On the root directory execute the following command:
python manage.py migrate
mkdir -p templates/postman
touch templates/postman/base.html
Now you should be able to see the Messages
and Pending
on the admin page of your site.
- Add the following markup to the
base.html
file we created in the above step:
<!doctype html>
<html>
<head>
<title>
{% block title %}
{% endblock %}
</title>
{% block extrahead %}
{% endblock %}
</head>
<body>
{% block content %}
{% endblock %}
{% block postman_menu %}
{% endblock %}
</body>
</html>
This is because the package expects this template to be able to render the urls.
5. Add this path path to the project’s urlpatterns:
path('messages/', include('postman.urls'), name='postman'),
-
Now you can use any of the urls on the actual site
localhost:8000/messages/write
There is one catch, by default the messages that you send will be pending so either you have to approve from the admin site ( by moderator) manually or you can set the
POSTMAN_AUTO_MODERATE_AS=True
in the settings.py.
Most of the above have been mentioned in django-postman documentation, but it was very challenging for me as a beginner to grasp these, So I have tried to simplify the steps, Hope it helps someone 🙂
0👍
Did you include the required template blocks in YOUR base.html template that the postman/base.html is extending?
From: https://bitbucket.org/psam/django-postman/wiki/quickstart#rst-header-templates
The
postman/base.html
template extends abase.html
site template, in which some blocks are expected:
•title: in<html><head><title>
, at
least for a part of the entire title string
•extrahead: in
<html><head>
, to put some<script>
and<link>
elements
•content: in
<html><body>
, to put the page contents
•postman_menu: in<html><body>
,
to put a navigation menu
- [Django]-DJANGO_SETTINGS_MODULE is undefined?
- [Django]-Populate User From Ldap Without Login in Django
- [Django]-How to stop PyCharm from autocompleting HTML and Django template tags?
0👍
Second the answer from @Amiay Narayan, with some modifications on the base.html file part.
The latest base.html from the Django-postman is:
{% extends "base.html" %}{# not myself but a site-level one (TEMPLATE_DIRS setting) #}
So in the base.html of your own Django project, the only thing that needs to be added somewhere between the <body>…..</body> is Django-postman’s simple menu:
{% block postman_menu %}
{% endblock %}
- [Django]-Django-lfs "No module named appconf"
- [Django]-URL and database routing based on language
- [Django]-Whats the difference between DjangoModelPermissions and DjangoObjectPermissions
- [Django]-Uploading Wagtail images from outside of wagtail