question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Import Error when trying to use set up a custom manager

See original GitHub issue

I’ve written a custom manager, but can’t use it due to an import error in settings.py. The error is:

ImportError: Cannot import social.managers.MyActionManager try fixing ACTSTREAM_SETTINGS[MANAGER]setting.

These are the settings:

ACTSTREAM_SETTINGS = {
    'MANAGER': 'social.managers.MyActionManager',
    'FETCH_RELATIONS': True,
    'USE_JSONFIELD': True
}

And this is the social.managers file:

from datetime import datetime, timedelta

from actstream.managers import ActionManager, stream
from actstream.models import following, user_stream

class MyActionManager(ActionManager):

    @stream
    def any_followed_stream(self, user, **kwargs):
        date_start = datetime.now() - timedelta(days=3)
        return user_stream(user).filter(date__gte=date_start)

The path is definitely correctly, so not sure what’s wrong here?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
justquickcommented, Jun 21, 2015

it looks like your hitting a cyclical import error when importing from actstream.models in your manager. try moving the import statements into the stream methods like so

from datetime import datetime, timedelta

from actstream.managers import ActionManager, stream

class MyActionManager(ActionManager):

    @stream
    def any_followed_stream(self, user, **kwargs):
        from actstream.models import user_stream
        date_start = datetime.now() - timedelta(days=3)
        return user_stream(user).filter(date__gte=date_start)
0reactions
silasi-valoicommented, Jun 15, 2017

Im having the same problem, Would anyone helo me?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom Django Model Managers giving error when trying to ...
I'm trying to use custom manager methods so eventually I can pass in arguments for additional filtering where needed.
Read more >
Cannot import custom objects even with the permission 'Import ...
1. Go to Setup | Object Manager | Create | Custom Object · 2. Fill-out all the necessary fields and configurations for the...
Read more >
The specified module 'Module Name' was not loaded because ...
Problem: When trying to import the PnP PowerShell module, I got an error message ... To fix the issue, You have to make...
Read more >
2088177 - What is "Custom Manager" in the application?
Custom Manager is a data field that you can add to your Employee Import File. Example. CUSTOM_MANAGER, MATRIX_MANAGER. Custom Manager (HR), Matrix Manager...
Read more >
Fix Custom Inventory Errors SCCM Hardware Inventory MOF ...
Error. You can only import hardware inventory classes for the default client settings on the central administration site. The following Classes ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found