-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Cannot access project models in my tasks.py #2613
Comments
As a sidenote -> When I transfer everything to the tasks.py in the users app then it works. It must have something to do with the other generated django app. But obviously this screws my internal logic quite a bit. |
Doe you import the task in models.py? It looks like a circular dependency:
-> models.py |
Hi, unfortunately, that is not the case. These are the imports in my projects.models.py:
I do want to change the user import to get user model, but I don't image that will cause this issue. |
Where do you import this line then: |
I import that in the projects.signals.py file and in the projects.views.py file - although in the view that is still from an older version and is not used anymore And yes, I'm aware of that, but thank you. I learned while coding this actually, because I was wondering at an early stage why the task didn't update, ever since then I knew to restart the containers. Since I'm still developing it's quick to just compose down and up again. |
Last guess: projects.signals is imported in users.models.py? To help you any further you need to post more information. |
When importing with cookiecutter-django, you have to start from the project name, then the project app, then the file:
I hope this helps |
I really think this is it:
The stack trace points at:
Sorry if this feel like repeating what the other said earlier, but the files inside your running container might be different than the one in your local file system (especially in prod). Do you have such imports at the exact lines from the exception? If not that might be your issue. To get changes propagated in the container, make sure to:
And just to be clear on the circular import issue, usually one resolve this by either:
I'll close this for now. It doesn't look like an issue with the project at this point. |
What happened?
I'm trying to have a celery task access my models.py to create an object, based on a result from a task chain.
No matter what I tried I always get the error message
ImportError: cannot import name 'CrawlURL' from 'simpledash.projects.models' (/app/simpledash/projects/models.py)
I'm also confused by the path /app/ -> Then all the proper path
Also the tasks in the tasks.py file get recognized just fine.
What should've happened instead?
The model should load fine.
Steps to reproduce
I used the docker configuration without much changes. I only use a personal postgres and not a container, but I've not ran into issues with that so far. I needed that initially to easier test outside access. This is what I'm trying to change now, since I want to create model instances from django and not via sql from an outside script.
//: # (* Host system configuration: OS, Docker & friends' versions etc.)
DigitalOcean Ubuntu running Docker
//: # (* Logs)
error.txt
The text was updated successfully, but these errors were encountered: