justquick / django-activity-stream

Generate generic activity streams from the actions on your site. Users can follow any actors' activities for personalized streams.
http://django-activity-stream.rtfd.io/en/latest/
BSD 3-Clause "New" or "Revised" License
2.38k stars 482 forks source link

The model User is not registered. Please use actstream.registry to register it. #490

Closed zyjswiadomielife closed 2 years ago

zyjswiadomielife commented 3 years ago

Hi, I try to register user. I find other posts with this (eg. https://github.com/justquick/django-activity-stream/issues/216)

But not work for me. I have Django 3.1.7 version.

I create new app for this: regstreams, and then add this code to apps.py:

from django.apps import AppConfig, apps
from actstream import registry

class ActivityConfig(AppConfig):
    name = 'regstreams'

    def ready(self):
        registry.register(apps.get_model('auth.User')) 

And in init.py

default_app_config = 'regstreams.apps.ActivityConfig'

But still I have error:

raise AppRegistryNotReady("Apps aren't loaded yet.")
| django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

Please help.

Ok I get solution. Just move from actstream import registry to def ready(self) like this:


    def ready(self):
        from actstream import registry
        registry.register(apps.get_model('auth.User')) 
sklaghari commented 3 years ago
def ready(self):
    from actstream import registry
    from django.contrib.auth.models import User
    registry.register(User)

register inside ready function instead of outside