django cannot import name patterns on app engine as app is working fine on heroku but not working on app engine - django

I am learning django and i have deployed it on heroku it is working fine here it is the link http://whispering-bayou-9769.herokuapp.com/ but on app engine it is not working giving me error
500 please try again in few time
it is the url for app engine http://djangocomment.appspot.com/
Please help me i think it may be problem of app.yml because on app engine logs there is log telling me error
'exceptions.ImportError'>: cannot import name pattern i have check url.py it is fine already working on heroku
in app.yml i have wriiten
application: djangocomment
runtime: python
version: 1
api_version: 1
handlers:
- url: .*
script: /post/urls.py
env_variables:
DJANGO_SETTINGS_MODULE: 'post.settings'
urls.p[y in post folder contain the path
file structure
app/
build/
categopry/
admin.py
templates/
models.py
urls.py
tests.py
post/
urls.py
forms.py
settings.py
wsgi.py
static/
admin.py
templates/
models.py
urls.py
tests.py
template/
registration/
userprofile/
admin.py
templates/
models.py
urls.py
tests.py
app.yml
manage.py
procfile
README.md
requiremtn.txt

That really isn't how you run a Django app on GAE. What gave you the idea to point the script to urls.py?
For a start, you need to reference Django in the libraries setting in your app.yaml. Then, you need to set the script to the WSGI object within your project's wsgi.py file: perhaps something like post.wsgi.app. See the documentation.

Related

How do I customize the admin page in Django 1.7?

I've been learning from the Django Documentation and have stumbled upon a road block in the section: https://docs.djangoproject.com/en/1.7/intro/tutorial02/#customize-the-admin-look-and-feel
My files are arranged as:
mysite/
mysite/
__pycache__/
...
__init__.py
settings.py
urls.py
wsgi.py
polls/
__pycache__/
...
migrations/
...
__init__.py
admin.py
models.py
tests.py
views.py
templates/
admin/
base_site.html
db.sqlite3
manage.py
I have modified the text in the file base_site.html to "Polls App" but the admin site continues to display "Django Administration".
PS: I'm using Win8
You need to place that templates folder in the project directory, not on the same level as the project as it currently is.
So place it under mysite/templates and you should be close.
EDIT: Actually, put the templates folder under your application so that it is Polls/templates
I have it at the same place as you, right under the project root. Make sure that django.contrib.admin is defined before your polls app in INSTALLED_APPS.

How To Find Current Django App Name

I have an app. I think I know the name, instamagic, but I get django.core.exceptions.ImproperlyConfigured: App with label instamagic could not be found
when I try to do a migration of the database
How do I find my app's name?
My folder structure
instamagic
__init__.py (empty file)
manage.py
settings.py
urls.py
api/
image/
templates/
userprofile/
Have you added 'instamagic' to your INSTALLED_APPS in settings.py?
[EDIT]
When calling south migrations, use: `manage.py schemamigration [migration_name] --auto

ImportError After Moving App to Nested Folder

My application was working fine when I wanted to see whether I could organize my project in a better way. I read through this tutorial on structuring a django project.
Before my project structure was as follows:
camucamu
books
admin.py
models.py
views.py
__init__.py
static
templates
urls.py
views.py
settings.py
wsgi.py
__init__.py
What I wanted to do was move the books app into an apps folder. Thus I did that and changed the project structure to the following:
camucamu
apps
books
admin.py
models.py
views.py
__init__.py
static
templates
urls.py
views.py
settings.py
wsgi.py
__init__.py
I then changed the imports in views.py and admin.py
from books.models to apps.books.models.
I also changed INSTALLED_APPS in settings.py from books to apps.books.
When I then tried to run syncdb, I get the following error:
raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0]))
django.core.exceptions.ImproperlyConfigured: ImportError apps.books: No module named apps.books
What am I messing up here so it can't find my app anymore?
Your apps folder does not have an __init__.py file so it cannot be recognized as a python module
I got the same error, following the same guide, as the last point of the following list was not cited. Make sure you performed the following changes:
Create a blank __init__.py file inside the apps folder (needed for python to recognize it as a package)
Update the import statements wherever you refer to an external app:
from projectname.apps.appname.models import YourModel, YourOtherModel
Inside settings.py edit INSTALLED_APPS such that it looks like this:
INSTALLED_APPS = (
...
# apps
'projectname.apps.appname1',
'projectname.apps.appname2',
)
This one is not specified in the guide: In all your urls.py files, update the urlpatterns!
BEFORE:
# client views
urlpatterns += patterns('appname',
...
)
AFTER:
# client views
urlpatterns += patterns('projectname.apps.appname',
...
)
Finally remember to update your changes by calling python manage.py syncdb
Hope that helped.

Where should i create django apps in django 1.4?

I've just started a new project in django 1.4 and since they've changed the default layout for manage.py and the whole folder hierarchy (see https://docs.djangoproject.com/en/dev/releases/1.4/#updated-default-project-layout-and-manage-py) i cannot decide where should i put my app packages - inside mysite or outside it? What's the best practice? For some reason, startapp command creates the app outside of the mysite package, but this feels somehow wrong.
So, what's the best? This:
manage.py
mysite/
__init__.py
settings.py
urls.py
myapp/
__init__.py
models.py
or this:
manage.py
myapp/
__init__.py
models.py
mysite/
__init__.py
settings.py
urls.py
?
The second way.
manage.py
myapp/
__init__.py
models.py
mysite/
__init__.py
settings.py
urls.py

djangorecipe test command

I've got a question about testing my Django applications in a built out Django project.
First, I've got the same project not built out and everything works fine. This project follows the standard Django project architecture apart from putting my tests in their own directory:
django_project/
manage.py
settings.py
urls.py
app1/
models.py
views.py
urls.py
tests/
app2/
...
If I run the tests in this situation great!
This is all a little bit different when it comes to buildout environment. There I've tried to svn check my project and applications and make the paths to all of them available in my bin directory (and I hope that also means making it available for whatever magic djangorecipe is doing). Anyway this is what my buildout looks like:
[buildout]
parts =
django_project
app1
app2
django
extra-paths =
${buildout:directory}
${buildout:directory}/parts
${buildout:directory}/parts/django_project
${buildout:directory}/parts/app1
${buildout:directory}/parts/app2
[django_project]
recipe = infrae.subversion
urls =
https://svn/django_projects/trunk/ .
[app1]
recipe = infrae.subversion
urls
= https://svn/path/app1/trunk/ .
[app2]
recipe = infrae.subversion
urls =
https://svn/path/app2/trunk/ .
[django]
recipe = djangorecipe
version = 1.2
project = django_project
projectegg = django_project
wsgi=true
settings=settings
extra-paths = ${buildout:extra-paths}
test =
app1
app2
When I run the buildout I get the following directory tree.
django_buidout/
...
bin/
django
django.wsgi
test
parts/
django/
django_project/
__init__.py
settings.py
...
app1/
setup.py
app1/
__init__.py
tests/
app2/
setup.py
app2/
__init__.py
tests/
I can get to the django shell so that works. But if I run ./bin/test I get an 'ImportError: No module named django.project.urls'. (the dot notation is not a mistake my django_project.settings.URL_CONF=django_project.urls) This is interesting because if I start the shell I can import django_project.urls. In addition to that if I run the tests through the ./bin/django test app1 all the test run. app1 is interesting because it has no tests on views.
In the views tests I'm using urlresolvers.reverse and that also shows up in the traceback along with the django.tests Client() class.
Is there something in my architecture that is messed up, or is urlresolvers.reverse doing something I'm not aware of?
Many thanks,
Todd