0

Here is my project setup.

  • ProjectDirectorty
    • AppDirectory
      • model.py
      • serializer.py
    • scripts Directory
      • init.py
      • main.py
    • manage.py

I am trying to call external API and get JSON data. Later deserialize it and store in the DB created by App.

When I am running main.py using python manage.py runscript main , I get error "Cannot import module 'scripts.main': No module named 'mix.mixapp'"

project setup

I understand diffrence between Script vs. Module and read Relative imports for the billionth time

I got stuck in this part of article "perhaps you don't actually want to run moduleX, you just want to run some other script, say myfile.py, that uses functions inside moduleX. If that is the case, put myfile.py somewhere else – not inside the package directory – and run it. If inside myfile.py you do things like from package.moduleA import spam, it will work fine."

It is similar to my case. I am running main.py which is in the "scripts" dir and using function from AppDirectory.

It didn't help. Please guide me to solve this problem.

Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
  • I don't understand `python manage.py runscript main` - can you provide the actual command line or a screenshot of the pycharm run configuration? – Mr_and_Mrs_D Jan 05 '23 at 14:19

0 Answers0