Skip to content

Commit 7b4b72c

Browse files
doc: Adjust the querying notifications example in README (#5)
Just a couple small things that help add a bit more clarity to the example: - Add the import for `WebsiteChannel` - Change the variable name for the queryset result to reflect the channel being queried - Grab the first "result" from the queryset so the variable isn't unbound
1 parent 3464cde commit 7b4b72c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ class SecurityAlert(NotificationType):
227227
### Querying Notifications
228228

229229
```python
230+
from generic_notifications.channels import WebsiteChannel
230231
from generic_notifications.models import Notification
231232
from generic_notifications.lib import get_unread_count, get_notifications, mark_notifications_as_read
232233

@@ -237,9 +238,10 @@ unread_count = get_unread_count(user=user, channel=WebsiteChannel)
237238
unread_notifications = get_notifications(user=user, channel=WebsiteChannel, unread_only=True)
238239

239240
# Get notifications by channel
240-
email_notifications = Notification.objects.for_channel(WebsiteChannel)
241+
website_notifications = Notification.objects.for_channel(WebsiteChannel)
241242

242243
# Mark as read
244+
notification = website_notifications.first()
243245
notification.mark_as_read()
244246

245247
# Mark all as read

0 commit comments

Comments
 (0)