0

I'm following this repo but I got this error:

enter image description here

Error: Import error cannot import name 'ProfileResource' from 'crowdfunding.models' (C:\_\_\_\_\_\crowdfunding\models.py)

which supposedly makes an asynchronous import. The problem is it cannot detect my ProfileResource.

I have specified in my settings.py that my resource be retrieved from admin.py.

def resource():
    from crowdfunding.admin import ProfileResource
    return ProfileResource

IMPORT_EXPORT_CELERY_MODELS = {
    "Profile": {
        'app_label': 'crowdfunding',
        'model_name': 'Profile',
        'resource': resource,
    }
}

but it can't seem to do that.

My celery.py is this:

from __future__ import absolute_import, unicode_literals

import os
import sys

from celery import Celery

# sys.path.append("../")

# Set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mainapp.settings')

from django.conf import settings

app = Celery('mainapp',
            broker='amqp://guest:guest@localhost:15672//',
            # broker='localhost',
            # backend='rpc://',
            backend='db+sqlite:///db.sqlite3',
            # include=['crowdfunding.tasks']
            )

# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
#   should have a `CELERY_` prefix. 
app.config_from_object('django.conf:settings', namespace='CELERY')

app.autodiscover_tasks()

and the broker and backend are working fine so it's just the config not being recognized. What could be the problem?

1 Answer 1

0

I believe that the problem is that changes to the code do not apply to celery automatically. Every time you change the source code, you need to manually restart celery to apply the new changes that you made to the import path in settings.py.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.