سؤال

enter image description here

I'm following the tango with django tutorial and everything was going great until I got to this section: http://www.tangowithdjango.com/book/chapters/models.html#creating-a-population-script I got an error that stated 'django.db not found'. I imported models from django.db in the models file and after doing some investigation, I noticed that my path seems to be off.

   BASE_DIR =  os.path.dirname(__file__) 

points to the location of the pycharm IDE - /users/applications/pycharm.app. I use a MAC.

I tried to get the base to point to the root of the project file by doing the following: Preferences -> Python Console -> I selected the tango_with_django_project and made it the source. However, this does not seem to help.

Please assist!!!

Thanks!

Update: I'm still unsuccessful with this. I have tried configuring the paths in virtualenv but to no avail. Help, please!

Attached is my project path. when i run 'python populate_rango.py' from the terminal, i get this error:

Traceback (most recent call last):
  File "populate_rango.py", line 62, in <module>
    from rango.models import Category, Page
هل كانت مفيدة؟

المحلول

I was having the EXACT same issue. I am using Pycharm on a windows PC. What I was doing was dropping in to a terminal session by going to tools>open terminal, and running the populate_rango.py from there.

I was getting the same issue until I ran it by right clicking on the file (populate_rango.py) from within pycharm and selecting run. See screen shotL

enter image description here

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top