I'm new at this and stuck. What would cause Django to run without error when I do python manage.py runserver but then throw Internal Server Error when I try to access it through the web? I have another project giving the Congratulations on your first Django-powered page, and I got the same result with the same .wsgi file initially with this project.
It wasn't until I tried to install this script in massivecoupon project that I got Internal Server Error:
http://github.com/coulix/Massive-Coupon---Open-source-groupon-clone
UPDATE:
I set Debug to True in settings.py and now I am getting the django error:
ViewDoesNotExist at /
Could not import massivecoupon.engine.views. Error was: No module named libs
You can use in command line
[user]$ python manage.py check
Regards
Quick answer: check your apache/tomcat access.log and error.log
Next, the other (not really dup) question I quoted above may be a different situation, but I recommend looking into the same things:
Your PYTHONPATH may not contain your project directory, or your DJANGO_SETTINGS_MODULE may not contain 'mysite.website', at least from apache's point of view. Whatever user apache runs as for your website needs to have that set up for it, like in its .profile. Or if you're using mod_python, they need to be set up in the .htaccess or apache's httpd.conf. Or if you're using mod_wsgi, it needs to be in the wsgi setup file -- passenger_wsgi.py or the like -- whatever apache's module will be looking for.
Next:
check if the files it needs to access are accessible by what apache runs your django site as
make sure your database is accessible by that user
and that the database setup/password is accessible by that user
make sure you have SITE_ID=1 set
make sure that you have a site record added into the database
First off check the Apache error log. If there is nothing in Apache error log, due to it being an internal error to your code or Django while handling a request, set DEBUG to True in Django site settings file and restart Apache so details of error display in the browser.
Related
I'm new to Django. My localhost site is running fine. Since I am using pycharm it is easy to run any file. I decided to run each file in my django project, and came across several errors, such as this one in my views.py:
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Even though the site is running, what seems like properly, I'm seeing this message. What is causing this, and is it typical?
You cannot run each file present in your django project individual.
No matter those are file with .py extension. They depend on the django framework to get the project running.
The reason you might be seeing that error is because you might be using the attributes present in the settings.py file which in turn requires django to set the application running like starting the WSGI server, getting all the dependencies and the installed apps ready before you actually use anything.
Understand that Django is a Framework and it relies on many underlying components to actually work. Even thought you can technically run any file in any manner, you cannot start the application itself.
There are other ways to do it if you like to test the application like using django shell by python manage.py shell to check and test the application, which would be a better way of doing individual testing rather than running each file standalone.
You can run any individual python file in a Django Project with Django, but keep in mind that the settings for Django must be supplied. This is not a good practise to run individual file with Django but for debugging purposes you may use it (for example. to test a parser that you wrote with database access),
You have to configure the Django settings before you can do anything with Django on a single file.
from django.conf import settings
settings.configure()
def do_something_with_a_model():
# does something with a model
print "I am done!!"
Note that relative imports may break when running on single files.
(for example. imports like from .another_module import AnotherClass may break when working with single file.)
I started from the Django template application in OpenShift, pushed it to OpenShift, and it ran without issue. After making a couple minor changes to settings.py and /.openshift/action_hooks/deploy, the application no longer runs (404 not found). In the command window, during deployment, I see CLIENT_ERROR: WSGI application not found. The build/deploy succeeds and finishes deployment.
As stated before, the home page now returns a 404. The logs indicate that application.py is not found. If I SSH into the deployment folder, I can find the file exactly where it is reported missing. Any ideas?
What changes did you make? If you changed the entry point you need to update your OPENSHIFT_PYTHON_WSGI_APPLICATION environment variable as per this release article: https://www.openshift.com/blogs/openshift-online-march-2014-release-blog
i'm working on web.py project with separated code in different files
- urls.py for urls,
- views.py for controllers,
- server.py for describing my application and it's option.
But i got a big problem - i need to restart my server (python server.py) every time when code was changed.
it makes me crazy.
I've tried 'touch server.py' and all other project files, tried to remove all *.pyc from project but without restart server code not updated.
May be someone knows how to fix this and save time?
Thanks!
http://webpy.org/docs/0.3/tutorial#developing states:
web.py also has a few tools to help us with debugging. When running with the built-in webserver, it starts the application in debug mode. In debug mode any changes to code and templates are automatically reloaded and error messages will have more helpful information.
The debug is not enabled when the application is run in a real webserver. If you want to disable the debug mode, you can do so by adding the following line before creating your application/templates.
web.config.debug = False
Are you using the internal webserver or an external one?
So, I'm running Apache2 on a Linux machine, and I'm trying to serve pages with Django 1.3. I found a guide to do this here.
I have the django.wsgi configured, the settings.py configured, and the database created and successfully in sync with Django. However, when I try to visit the website, I am shown a page served by Apache, instead of Django. I get no errors/warnings at all.
I put print statements in both django.wsgi and settings.py (since they're both just python files), but nothing gets printed.
Does anyone have any idea as to what may be going wrong or any diagnostic steps I might be able to take?
Thanks!
As everyone has said in the comments, you need to add a WSGIServerAlias directive to the Apache configuration before anything will work. Otherwise, Apache can't possibly know to use WSGI to serve your site.
I've been developing on my laptop.
Now, I've uploaded my development project from Django 1.2/Python 2.7 up to Dreamhost created using the Passenger setup. I am using South for migration.
I modified settings.py to access MySQL. Got Admin working.
Questions:
1) Where is the std out shown when you hit the site? (all my print statements)
2) I had to add
from decimal import Decimal
to get the settings.py to run.
Now, hitting the server gives me a 500. When I go to the commandline and try any manage.py command I'm getting:
Error: Could not import settings 'pholdershare.settings' (Is it on sys.path? Does it have syntax errors?): No module named settings
I modified the permissions for my folder to 755 but that didn't change anything.
3) Regarding development to testing to live, I'm totally unclear on how to do this. I want to have a nice solid system for development where I can do releases but I've never done that. I have been using GIT locally. Can anybody point me to the tutorial on setting up the release system?
Suggestions?
Thanks much!
"Could not import settings 'pholdershare.settings'"
...usually means either settings.py has an import error or syntax error, or pholdershare has not been added to sys.path in your wsgi.py