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
Related
I have encountered a hodgepodge of errors trying to bring my django site into production with Apache. Having finally gotten mod_wsgi sorted and Apache at least seeming to be trying to load the site I'm seeing a number of confusing problems in the debug details when the homepage fails to load.
None of these errors emerge when I fire up the site using python manage.py runserver 10.10.10.214:8080 - it works 100% fine that way
Import errors - I cannot from x import y - for some reason it will only allow me to do from x import * An example was #from django.conf.urls import patterns, include, url gave an error - I had to change to from django.conf.urls.defaults import *
Permission errors - for example, I had to chmod the DB file which worked fine before. No big deal I suppose but I just wondered why
DB field errors: Cannot resolve keyword 'user_id' into field. Choices are: end_date, id, singleDate, start_date, user user_id worked just fine in standalone mode.
Apache log was giving errors like TemplateSyntaxError: Caught ImportError while rendering: No module named staticfiles which I just lazily bypassed by commenting out django.contrib.staticfiles in settings.py. This solved nothing, needless to say
It almost felt like the files were being handled on a standalone basis and not within the django framework. Has anyone experienced these kind of teething problems before? I was foolishly thinking I could just plug in. I have a (unfounded) optimistic feeling it must just be a directive in some file.
Cheers, Arthur
Are you sure the target system has the same version of Django installed?
Is the mod_wsgi even compiled for the version of Python you want to use? It is a common mistake that people don't realise that mod_wsgi is actually for a different Python version and so not using the same Python installation as you expect and therefore using different versions of packages.
As to the permissions errors, this is because the code when run under Apache is running as the Apache user by default. It will not have access rights the same as you do when run manually. You also have to be careful on making assumptions about what the working directory of the process is.
https://code.google.com/p/modwsgi/wiki/ApplicationIssues#Access_Rights_Of_Apache_User
https://code.google.com/p/modwsgi/wiki/ApplicationIssues#Application_Working_Directory
In order to try and sort out things out, you may be better to try and use mod_wsgi-express in your development environment. This way development environment is closer to your target system.
http://blog.dscpl.com.au/2015/04/integrating-modwsgi-express-as-django.html
http://blog.dscpl.com.au/2015/04/using-modwsgi-express-with-django.html
http://blog.dscpl.com.au/2015/05/using-modwsgi-express-as-development.html
I am using satchless app in my local server. It is installed at python path.
Later i have create my project in my home directory and modify the settings.py file as described in this doc
But when i am running my server and goes to localserver localhost:8000 it gives me the error cannot import name cart_app I think it does not imort none of the app (cart, product or anything i have mention in my doc).
My url.py file is similar as it is specified in the doc i have mentioned above.
So any one who have used satchless app can tell me where i am wrong
Any suggestions would be appreciated
Thanks
Try to runserver --traceback, sometimes the error comes from somewhere else.
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.
What does this actually do? I recently branched out my project from 1 app into 6 different apps and forgot to update the INSTALLED_APPS part of my settings file. Everything still works even though I didn't list the new apps in. Is that supposed to happen? Do I need to include all my apps in INSTALLED_APPS?
yes.
INSTALLED_APPS helps django to sync the database, run tests, get the urls to work and more related issues.
Maybe your installed apps still works because the main one calls the others with imports, a django app is nothing more that a simple python module that is imported when called in the settings file, that's why you get a invalid syntax error after you run the development server because an import won't work with invalid syntax.
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.