Upgraded to Django 4.0 and notification errors

I inherited this code from the previous Software Engineer. I am still new to Python and Django. In my development environment I updated Django to 4.0. I am able to resolve most issues except one for notifications.

The error:

File "C:\Users\da\Desktop\EnvAug10\lib\site-packages\notifications\admin.py", line 8, in Notifications = load_model('notifications', 'Notification') 
File "C:\Users\da\Desktop\EnvAug10\lib\site-packages\swapper_*init*_.py", line 79, in load_model raise ImproperlyConfigured( django.core.exceptions.ImproperlyConfigured: Could not find notifications.PushNotification!

I have installed:
django-notifications-hq==1.8.2
notifications==0.3.2

site-packages\notifications\admin.py:

''' Django notifications admin file '''
# -*- coding: utf-8 -*-
from django.contrib import admin
from django.utils.translation import gettext_lazy
from notifications.base.admin import AbstractNotificationAdmin
from swapper import load_model

Notification = load_model('notifications', 'Notification')


def mark_unread(modeladmin, request, queryset):
    queryset.update(unread=True)
mark_unread.short_description = gettext_lazy('Mark selected notifications as unread')


class NotificationAdmin(AbstractNotificationAdmin):
    raw_id_fields = ('recipient',)
    readonly_fields = ('action_object_url', 'actor_object_url', 'target_object_url')
    list_display = ('recipient', 'actor',
                    'level', 'target', 'unread', 'public')
    list_filter = ('level', 'unread', 'public', 'timestamp',)
    actions = [mark_unread]

    def get_queryset(self, request):
        qs = super(NotificationAdmin, self).get_queryset(request)
        return qs.prefetch_related('actor')


admin.site.register(Notification, NotificationAdmin)

I do have a PushNotification model in my notification app:

from django.contrib import admin
from notification.models import PushNotification, EMailLogs
from dashboard.admin import DontLog

# Register your models here.
@admin.register(PushNotification)

class PushNotificationAdmin(DontLog, admin.ModelAdmin):
    search_fields = ['recipient__username', 'recipient__first_name', 'recipient__last_name', 'verb']
    pass

class EMailLogsAdmin(DontLog, admin.ModelAdmin):
    search_fields = ['sent_from__username','subject','content', 'application']
    fieldsets = [
    (None, {'fields': ['sent_from', 'sent_to', 'subject', 'content', 'application']}),
    ('Object Fields', {'fields': ['related_object_content_type', 'related_object_id']})
    ]
    autocomplete_fields=['sent_from', 'sent_to']

admin.site.register(EMailLogs, EMailLogsAdmin)

Is there anything else you need to help me fix this error?

I have tried upgrading and downgrading various versions of Django, notifications, django-notification-hq. I have searched ChatGPT, Bard, Stack Overflow, and other sites. At one point I tried putting in a PushNotifications class in notifications. It worked for a while but then started producing errors when other packages were upgraded.

When I look for “notifications” on pypi, I only find links to a 12-year-old project, where version 0.3.2 was released in November 2011.

However, that project also doesn’t include an admin.py file.

This makes me think that your notifications package is not the one on pypi. Ahh - I see it in the docs at django-notifications-hq · PyPI - the “notifications” app is to be installed directly from github, and has a different name django-notifications.

So did you install those packages from pypi, or did you install them directly from github?

They were already installed. I just used pip to upgrade them.

But the problem is that the version in pypi are not as current as what you get from installing from github. You want to delete what you installed from pypi, and reinstall directly from github.

I went to GitHub but it turns out that’s the django-notifications-hq that I had already installed. I’m now back to the same problem.

When I follow the instructions on GitHub and look at my settings.py file, I do have these items:
#Notification settings
NOTIFICATIONS_NOTIFICATION_MODEL = ‘notification.PushNotification’
DJANGO_NOTIFICATIONS_CONFIG = { ‘USE_JSONFIELD’: True}