简体   繁体   中英

Error in Django running on Apache/mod_wsgi

Recently i asked a question regarding an error in apache/mod_wsgi recognizing the python script directory. The community kindly answered the question resulting in a successful installation. Now I have a different error, the server daemon (well, technically is a windows service, I say tomato you say...) doesn't find any of the models, here's the full traceback:

Environment:

Request Method: GET
Request URL: `http://localhost/polls/`
Django Version: 1.0.2 final
Python Version: 2.6.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'mysite.polls']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')

Template error: In template c:\\users\\marcos\\documents\\djangotemplates\\polls\\poll _ list.html, error at line 1 Caught an exception while rendering: no such table: polls_poll

1 :  {% if object_list %}   
       2 :     <ul>  
       3 :     {% for poll in object_list %}  
       4 :          <li> <a href="{{poll.id}}/">{{ poll.question }} </a> </li>  
       5 :     {% endfor %}  
       6 :     </ul>  
       7 : {% else %}  
       8 :     <p>No polls are available.</p>  
       9 : {% endif %}  
       10 :

Traceback:

File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in get_response
      86.                 response = callback(request, *callback_args, **callback_kwargs)
    File "C:\Python26\lib\site-packages\django\views\generic\list_detail.py" in object_list
          101.     return HttpResponse(t.render(c), mimetype=mimetype)
    File "C:\Python26\lib\site-packages\django\template\__init__.py" in render
          176.         return self.nodelist.render(context)
    File "C:\Python26\lib\site-packages\django\template\__init__.py" in render
          768.                 bits.append(self.render_node(node, context))
    File "C:\Python26\lib\site-packages\django\template\debug.py" in render_node
          81.             raise wrapped
Exception Type: TemplateSyntaxError at /polls/
Exception Value: Caught an exception while rendering: no such table: polls_poll

somewhere someone advice me to use manage.py dbshell and the script responded:
Error: You appear not to have the 'sqlite3' program installed or on your path.

But still the Django runserver runs the app perfectly. I don't see what changed in the environment to screw the web-app so hard. Please help!

You don't have a database. It's not clear why you don't have a sqlite3 driver. However, you don't have sqlite3 and you don't have a database.

  1. Run manage.py syncdb build the database.

    • Be sure to use the same settings.py as your production instance.

    • Be sure your settings.py has the correct driver. You're using SQLite3, be sure that an absolute path name is used.

    • Be sure to use the same PYTHONPATH and working directory as production to be sure that all modules are actually found

  2. Run ordinary SQL to see that you actually built the database.

  3. Run the Django /admin application to see what's in the database.

SQLite3 is included with Python. For it to be missing, your Python installation must be damaged or incomplete. Reinstall from scratch.

我解决了将sqlite3 Binaries目录添加到PYTHONPATH环境变量的问题。

尝试manage.py syncdb以确保django可以连接到数据库并创建所有表。

Just fixed a problem similar. I think you have to add your app name to the INSTALLED_APPS list in settings.py.

None of these were right for me when I was trying to run manage.py dbshell, but then it is 3 years later, and I'm on 10.7. I added my mysql path to my PATH variable like this:

PATH=$PATH:/usr/local/mysql-5.5.16-osx10.6-x86_64/bin

Actually, it's better to put this into your .profile file. With Mac OS 10.7 you'll probably have to create one of these if you haven't already. From a Terminal window, just enter cd, then hit return to get back to your home directory, then do vi .profile to make the new file, and insert:

export PATH=$PATH:/usr/local/mysql-5.5.16-osx10.6-x86_64/bin

I'm giving a lot of detail here for people who don't know all this off the top of their head, like me. The next time you log in your path will be set automatically. To set it now from the .profile file, just do:

. ./.profile

To verify your new PATH variable, do this:

echo $PATH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM