Django console not working properly on docker

Hello! I'm working on a django project to try docker, so I've made the docker file, the docker compose, and all that stuff. The project runs fine, I can develop fine, but the problem raises when I want to use the console.

Aparently it starts ok but when I try to import stuff from my models, I'm getting this error:

django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

I've noticed the command used to start the console:

/usr/local/bin/docker-compose -f /home/santiago/PycharmProjects/dockertodo/docker-compose.yml -f /home/santiago/.PyCharm2018.3/system/tmp/docker-compose.override.331.yml run --rm -p web

Shoudn't be this comand somthing like:

/usr/local/bin/docker-compose -f /home/santiago/PycharmProjects/dockertodo/docker-compose.yml -f /home/santiago/.PyCharm2018.3/system/tmp/docker-compose.override.331.yml run --rm -p web python shell


But I can't find a way to set it up. Please, can you help me?

Thank you!!


Well I've found out the problem. I'm not sure why, but the console settings were different to the settings of another project where the console works well. I've copied the starting script and now it works fine.

import sys; print('Python %s on %s' % (sys.version, sys.platform))
import django; print('Django %s' % django.get_version())
if 'setup' in dir(django): django.setup()
import django_manage_shell;


Hi, Thank you for contacting JetBrains support. Your solution is correct, it's one way to import all Django modules into the shell. Another way is to use **Tools >> Run Task...** and then execute `shell` Let me know if you have any other questions.

@Santiagovassallo 's solution worked for me.  Thanks mate!!