You can't create your own app, notifications
, because you already have an installed app called notifications
. This is the app you downloaded/installed and added to your_project/settings.py
under INSTALLED_APPS
To view the default list, you can python manage.py runserver
, and navigate to localhost:8000/notifications/' to see the default
list.html`.
From there, I recommend creating your own list. Looking at the documentation here, you'll find all the QuerySet methods. You can build a view based on these queries. e.g. your-app/views.py
:
...
# Get all unread notifications for current user.
def unread_notifications(request):
context = {
'notifications': request.user.notifications.unread()
}
return render(request, 'your-app/unread_notifications.html', context)
And your your-app/unread_notifications.html
(assuming bootstrap):
<ul class="notifications">
{% for notice in notifications %}
<div class="alert alert-block alert-{{ notice.level }}">
<a class="close pull-right" href="{% url 'notifications:mark_as_read' notice.slug %}">
<i class="icon-close"></i>
</a>
<h4>
<i class="icon-mail{% if notice.unread %}-alt{% endif %}"></i>
{{ notice.actor }}
{{ notice.verb }}
{% if notice.target %}
of {{ notice.target }}
{% endif %}
</h4>
<p>{{ notice.timesince }} ago</p>
<p>{{ notice.description|linebreaksbr }}</p>
<div class="notice-actions">
{% for action in notice.data.actions %}
<a class="btn" href="{{ action.href }}">{{ action.title }}</a>
{% endfor %}
</div>
</div>
{% endfor %}
</ul>