I'm trying to intergrate Facebook Connect into an GAE app. I've got a basic folder structure like so:
/gae-root
/myapp
/templates
/etc
app.yaml
settings.py
and I tried to add the PyFacebook library like so:
/gae-root
/myapp
/templates
/etc
/facebook
/djangofb
app.yaml
settings.py
I thought this would work, but now when I try to import facebook it throws a module not found error. What's even weirder is that if I rename the directory from facebook to foo, the import now works but I'll hit errors later when I try to get the current logged in user.
Literally all I did was move the directory into my folder structure and try an import. What am I missing? Sorry if this is an easy question.
It was a problem with an extra .pth file in my site-packages directory.
Related
In a django project that is served by IIS (windows), i added a local file, test.py. The project ran perfectly before and still runs perfect on localhost, however IIS appears to not recognize the new test.py file. It appears IIS access to this file fails, even if the users IUSR and IIS_USRS have full access (same as for all other files in the folder).
I get below error message, and somethimes also the same but "No module named 'app.test'. Removing the "import app.test as test" in views.py solves the issue.
Suprisingly the "import app.oldFile as oldFile" works without issue.
In my views.py, i import the python scripts like this
import app.oldFile as oldFile
import app.test as test
My django project has the structure:
djangoRest
-app
--__init__.py
--views.py
--oldFile.py
--test.py
-djangoRest
--__init__.py
--settings.py
--urls.py
--wsgi.py
I found the reason, and solution.
In the earlier import file oldFile.py i use the line
import os
os.chdir(r\\some\\other\\directory\\)
This obviously changes the current working directory and as a result the other file test.py can't be found, and cannot be imported.
This mistake does not matter when testing django on the localhost, but only manifests in an issue when served by IIS.
I'm trying to host a django app on cpanel but i cant find a way to tell passenger_wsgi.py to look for the django project(main file) inside another folder
My site structure is:
/home/project/
tmp/
public/
passenger_wsgi.py
abdi-group/
passenger_wsgi.py:
from abdiGroup.wsgi import application
this works fine if i move everything inside abdi-group/ to /home/project/
I tried this:
passenger_wsgi.py:
from abdi-group.abdiGroup.wsgi import application
but it can't find abdiGroup(django project name) inside abdi-group/
am i missing something?
abdiGroup is supposed to be a folder in your project directory that contains the wsgi file not abdi-group. If you're making it a subfolder add an empty __init__.py to any new folder so Django knows it is a package and can import from it.
Hi I had followed project organisation in directory ./my_project/
-venv/
-static/
-templates/
--index.html
--login.html
-requirements.txt
-main.py
-views.py
then i wanted to add test folder and reorganise all to following structure:
-venv/
-my_project/
--static/
--templates/
---index.html
---login.html
--requirements.txt
--main.py
--views.py
And when I am running main file, server runs, but if I open on a browser right address there is error 404. In log of a server I see that server recieves request, but something is wrong. I have no idea what is this, because I didn't change anything in code.
You need to make the my_project a Python package by adding an empty __init__.py file inside it.
See this answer here https://stackoverflow.com/a/448279/9379795
I have a python application (which we'll call app) I'd like to have a web front for. The application has many files and it's important the folder tree structure stays the way it is.
I've built a Django project and put it in a folder named "Web" in the app's folder, so now the folder tree looks like so:
[Data]
[Resources]
[Web]
[WebFront]
normal django app files
[Web]
__init__.py
settings.py
urls.py
wsgi.py
__init__.py
manage.py
main.py
Here's the code on the app's main.py:
import os
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Web.Web.settings")
django.setup()
This code causes an exception on the django.setup() line as (I think) django does not find the project modules: ImportError: No module named WebFront (WebFront is the name of the django app)
I suspect this is caused because django runs in the directory of python app, and therefore cannot find the folder WebFront - Which should actually be Web/WebFront
Can this be done? Or should I reverse the order and put the python app in the django app?
This is not a duplicate of the following questions as the folder nesting causes a different problem (I think)
Django 1.7 throws django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet
Easiest way to write a Python program with access to Django database functionality
Using only the DB part of Django
You can locate your main.py script where you like. However, if it is outside of the Web folder, then you will have to add Web to the Python path, otherwise imports like import Webfront are going to fail.
import sys
sys.path.append('/path/to/Web/')
Once you have done that, you can change the DJANGO_SETTINGS_MODULE to
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Web.settings")
Im trying to learn Django by looking at examples, but Im having a bit of a problem running the examples I find.
I downloaded 'cheeserator' from https://github.com/jacobian/cheeserater
and I tried running it with python manage.py runserver
but I get the following error -
Error: Can't find the file
'settings.py' in the directory
containing 'manage.py'. It appears
you've customized things. You'll have
to run django-admin.py, passing it
your settings module. (If the file
settings.py does indeed exist, it's
causing an ImportError somehow.)
What am I doing wrong?
You need to have a settings.py file.
As per the instructions in the link provided:
Then you'll want to create a settings.py file in this directory containing::
from settings_template import *
# Override any settings you like here.
Or if you don't want to override anything rename settings_template.py to settings.py