How to upload the django-1.5 application in google app engine? - python

I have uploaded the my sample CRUD application in google app engine. But it riased error as shown below,
Traceback (most recent call last):
File "/base/data/home/apps/s~mobiheropython/1.367549640437962894/main.py", line 52, in <module>
main()
File "/base/data/home/apps/s~mobiheropython/1.367549640437962894/main.py", line 49, in main
util.run_wsgi_app(application)
File "/python27_runtime/python27_lib/versions/1/google/appengine/ext/webapp/util.py", line 98, in run_wsgi_app
run_bare_wsgi_app(add_wsgi_middleware(application))
File "/python27_runtime/python27_lib/versions/1/google/appengine/ext/webapp/util.py", line 116, in run_bare_wsgi_app
result = application(env, _start_response)
File "/python27_runtime/python27_lib/versions/third_party/django-1.5/django/core/handlers/wsgi.py", line 236, in __call__
self.load_middleware()
File "/python27_runtime/python27_lib/versions/third_party/django-1.5/django/core/handlers/base.py", line 51, in load_middleware
mod = import_module(mw_module)
File "/python27_runtime/python27_lib/versions/third_party/django-1.5/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/python27_runtime/python27_lib/versions/third_party/django-1.5/django/contrib/auth/middleware.py", line 3, in <module>
from django.contrib.auth.backends import RemoteUserBackend
File "/python27_runtime/python27_lib/versions/third_party/django-1.5/django/contrib/auth/backends.py", line 3, in <module>
from django.contrib.auth.models import Permission
File "/python27_runtime/python27_lib/versions/third_party/django-1.5/django/contrib/auth/models.py", line 8, in <module>
from django.db import models
File "/python27_runtime/python27_lib/versions/third_party/django-1.5/django/db/__init__.py", line 40, in <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "/python27_runtime/python27_lib/versions/third_party/django-1.5/django/db/__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/python27_runtime/python27_lib/versions/third_party/django-1.5/django/db/utils.py", line 93, in __getitem__
backend = load_backend(db['ENGINE'])
File "/python27_runtime/python27_lib/versions/third_party/django-1.5/django/db/utils.py", line 27, in load_backend
return import_module('.base', backend_name)
File "/python27_runtime/python27_lib/versions/third_party/django-1.5/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/python27_runtime/python27_lib/versions/third_party/django-1.5/django/db/backends/mysql/base.py", line 17, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
My app structure is as shown below,
mobihero
├── app.yaml
├── app.yaml~
├── favicon.ico
├── index.yaml
├── main.py
├── main.py~
├── main.pyc
├── manage.py
├── mobitracking
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── settings.py
│   ├── settings.py~
│   ├── settings.pyc
│   ├── urls.py
│   ├── urls.pyc
│   ├── wsgi.py
│   └── wsgi.pyc
├── nohup.out
├── Procfile
├── requirements.txt
├── shipment
│   ├── admin.py
│   ├── admin.pyc
│   ├── forms.py
│   ├── forms.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── models.py
│   ├── models.pyc
│   ├── tests.py
│   ├── views.py
│   └── views.pyc
├── static
│   ├── css
│   │   ├── bootstrap.css
│   │   └── styles.css
│   └── jquery
│   ├── jquery-1.9.1.js
│   ├── jquery-ui-1.10.1.custom.min.js
│   ├── ui-darkness
│   │   ├── images
│   │   │   ├── animated-overlay.gif
│   │   │   ├── ui-bg_flat_30_cccccc_40x100.png
│   │   │   ├── ui-bg_flat_50_5c5c5c_40x100.png
│   │   │   ├── ui-bg_glass_20_555555_1x400.png
│   │   │   ├── ui-bg_glass_40_0078a3_1x400.png
│   │   │   ├── ui-bg_glass_40_ffc73d_1x400.png
│   │   │   ├── ui-bg_gloss-wave_25_333333_500x100.png
│   │   │   ├── ui-bg_highlight-soft_80_eeeeee_1x100.png
│   │   │   ├── ui-bg_inset-soft_25_000000_1x100.png
│   │   │   ├── ui-bg_inset-soft_30_f58400_1x100.png
│   │   │   ├── ui-icons_222222_256x240.png
│   │   │   ├── ui-icons_4b8e0b_256x240.png
│   │   │   ├── ui-icons_a83300_256x240.png
│   │   │   ├── ui-icons_cccccc_256x240.png
│   │   │   └── ui-icons_ffffff_256x240.png
│   │   ├── jquery-ui-1.10.1.custom.css
│   │   └── jquery-ui-1.10.1.custom.min.css
│   └── ui-lightness
│   ├── images
│   │   ├── animated-overlay.gif
│   │   ├── ui-bg_diagonals-thick_18_b81900_40x40.png
│   │   ├── ui-bg_diagonals-thick_20_666666_40x40.png
│   │   ├── ui-bg_flat_10_000000_40x100.png
│   │   ├── ui-bg_glass_100_f6f6f6_1x400.png
│   │   ├── ui-bg_glass_100_fdf5ce_1x400.png
│   │   ├── ui-bg_glass_65_ffffff_1x400.png
│   │   ├── ui-bg_gloss-wave_35_f6a828_500x100.png
│   │   ├── ui-bg_highlight-soft_100_eeeeee_1x100.png
│   │   ├── ui-bg_highlight-soft_75_ffe45c_1x100.png
│   │   ├── ui-icons_222222_256x240.png
│   │   ├── ui-icons_228ef1_256x240.png
│   │   ├── ui-icons_ef8c08_256x240.png
│   │   ├── ui-icons_ffd27a_256x240.png
│   │   └── ui-icons_ffffff_256x240.png
│   ├── jquery-ui-1.10.2.custom.css
│   └── jquery-ui-1.10.2.custom.min.css
└── templates
├── add_shipment.html
├── all_shipments.html
├── base.html
├── home.html
├── search.html
├── shipment
│   └── shipment_confirm_delete.html
├── shipment_detail.html
└── update_shipment.html
I have uploaded code using the command as shown below,
appcfg.py update mobihero
It is successfully deployed.
Please solve my problem. Thanks.....

Do you change your Mysql backend?
Support for using Google Cloud SQL with Django is provided by a custom Django database backend which wraps Django's MySQL backend.
edit your settings.py:
DATABASES = {
'default': {
'ENGINE': 'google.appengine.ext.django.backends.rdbms',
'INSTANCE': 'my_project:instance1',
'NAME': 'my_database',
}
}

Related

How to solve UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

I'm trying to use Black to format my Django code. It works fine in most directories. However, I get the Unicode decode error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte on the .py files in one directory in particular. The files are in UTF-8, but I have tried multiple different other encodings and have tried deleting and recreating files which hasn't resolved the issue. I'm working in an Anaconda environment, but deactivating that doesn't make any difference. I've also disabled most of my VS Code extensions.
I have looked at many SO postings on this, but none of the suggestions thus far have helped. I'm using VS Code on a Mac and have a feeling it is something to do with the fact that in the past I have edited the same code on a Windows machine using VS Code with WSL (code synced with a GitHub repo), but can't figure out how to address it. I've put a sample Traceback call below. Any help would be much appreciated!
Edit: If I cut and paste any of the files into another directory, then Black works fine and I don't get any encoding error messages. Which suggests there may be a directory-level issue at play?
(base) ➜ healthtic git:(master) ✗ black pages/views.py
Traceback (most recent call last):
File "/Users/jh/opt/anaconda3/bin/black", line 8, in <module>
sys.exit(patched_main())
File "/Users/jh/opt/anaconda3/lib/python3.8/site-packages/black/__init__.py", line 1130, in patched_main
main()
File "/Users/jh/opt/anaconda3/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/Users/jh/opt/anaconda3/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/Users/jh/opt/anaconda3/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/jh/opt/anaconda3/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/Users/jh/opt/anaconda3/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/Users/jh/opt/anaconda3/lib/python3.8/site-packages/black/__init__.py", line 411, in main
sources = get_sources(
File "/Users/jh/opt/anaconda3/lib/python3.8/site-packages/black/__init__.py", line 477, in get_sources
gitignore = get_gitignore(root)
File "/Users/jh/opt/anaconda3/lib/python3.8/site-packages/black/files.py", line 123, in get_gitignore
lines = gf.readlines()
File "/Users/jh/opt/anaconda3/lib/python3.8/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
Further edit: As mentioned above if I move files out of this directory, Black works fine, if I move them back (without any changes), the 0xFF unicode error recurs. I have attached my directory structure below, as it may be relevant that I have webpack and node modules in there for some of the frontend. My impression is that maybe a BOM may be being added somehow in the directory?
├── Dockerfile
├── accounts
│   ├── __init__.py
│   ├── __pycache__
│   ├── admin.py
│   ├── apps.py
│   ├── forms.py
│   ├── migrations
│   ├── models.py
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── appointments
│   ├── __init__.py
│   ├── __pycache__
│   ├── admin.py
│   ├── apps.py
│   ├── forms.py
│   ├── migrations
│   ├── models.py
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── cloud_sql_proxy
├── cloudmigrate.yaml
├── config
│   ├── __init__.py
│   ├── __pycache__
│   ├── asgi.py
│   ├── basesettings.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── db.sqlite3
├── docker-compose.yaml
├── front-end
│   ├── App\ copy.js
│   ├── App.js
│   ├── index\ copy.js
│   └── index.js
├── logfile
├── manage.py
├── node_modules
│   ├── #babel
│   ├── #discoveryjs
│   ├── #types
│   ├── #webassemblyjs
│   ├── #webpack-cli
│   ├── #xtuc
│   ├── acorn
│   ├── ajv
│   ├── ajv-keywords
│   ├── ansi-styles
│   ├── babel-loader
│   ├── babel-plugin-dynamic-import-node
│   ├── babel-plugin-polyfill-corejs2
│   ├── babel-plugin-polyfill-corejs3
│   ├── babel-plugin-polyfill-regenerator
│   ├── big.js
│   ├── browserslist
│   ├── buffer-from
│   ├── call-bind
│   ├── caniuse-lite
│   ├── chalk
│   ├── chrome-trace-event
│   ├── clone-deep
│   ├── color-convert
│   ├── color-name
│   ├── colorette
│   ├── commander
│   ├── commondir
│   ├── convert-source-map
│   ├── core-js-compat
│   ├── cross-spawn
│   ├── debug
│   ├── define-properties
│   ├── electron-to-chromium
│   ├── emojis-list
│   ├── enhanced-resolve
│   ├── envinfo
│   ├── es-module-lexer
│   ├── escalade
│   ├── escape-string-regexp
│   ├── eslint-scope
│   ├── esrecurse
│   ├── estraverse
│   ├── esutils
│   ├── events
│   ├── execa
│   ├── fast-deep-equal
│   ├── fast-json-stable-stringify
│   ├── fastest-levenshtein
│   ├── find-cache-dir
│   ├── find-up
│   ├── function-bind
│   ├── gensync
│   ├── get-intrinsic
│   ├── get-stream
│   ├── glob-to-regexp
│   ├── globals
│   ├── graceful-fs
│   ├── has
│   ├── has-flag
│   ├── has-symbols
│   ├── human-signals
│   ├── import-local
│   ├── interpret
│   ├── is-core-module
│   ├── is-plain-object
│   ├── is-stream
│   ├── isexe
│   ├── isobject
│   ├── jest-worker
│   ├── js-tokens
│   ├── jsesc
│   ├── json-parse-better-errors
│   ├── json-schema-traverse
│   ├── json5
│   ├── kind-of
│   ├── loader-runner
│   ├── loader-utils
│   ├── locate-path
│   ├── lodash
│   ├── lodash.debounce
│   ├── loose-envify
│   ├── make-dir
│   ├── merge-stream
│   ├── mime-db
│   ├── mime-types
│   ├── mimic-fn
│   ├── minimist
│   ├── ms
│   ├── neo-async
│   ├── node-releases
│   ├── npm-run-path
│   ├── object-assign
│   ├── object-keys
│   ├── object.assign
│   ├── onetime
│   ├── p-limit
│   ├── p-locate
│   ├── p-try
│   ├── path-exists
│   ├── path-key
│   ├── path-parse
│   ├── pkg-dir
│   ├── punycode
│   ├── randombytes
│   ├── react
│   ├── react-dom
│   ├── rechoir
│   ├── regenerate
│   ├── regenerate-unicode-properties
│   ├── regenerator-runtime
│   ├── regenerator-transform
│   ├── regexpu-core
│   ├── regjsgen
│   ├── regjsparser
│   ├── resolve
│   ├── resolve-cwd
│   ├── resolve-from
│   ├── safe-buffer
│   ├── scheduler
│   ├── schema-utils
│   ├── semver
│   ├── serialize-javascript
│   ├── shallow-clone
│   ├── shebang-command
│   ├── shebang-regex
│   ├── signal-exit
│   ├── source-list-map
│   ├── source-map
│   ├── source-map-support
│   ├── strip-final-newline
│   ├── supports-color
│   ├── tapable
│   ├── terser
│   ├── terser-webpack-plugin
│   ├── to-fast-properties
│   ├── unicode-canonical-property-names-ecmascript
│   ├── unicode-match-property-ecmascript
│   ├── unicode-match-property-value-ecmascript
│   ├── unicode-property-aliases-ecmascript
│   ├── uri-js
│   ├── v8-compile-cache
│   ├── watchpack
│   ├── webpack
│   ├── webpack-cli
│   ├── webpack-merge
│   ├── webpack-sources
│   ├── which
│   ├── wildcard
│   └── yocto-queue
├── notes.md
├── package-lock.json
├── package.json
├── pages
│   ├── __init__.py
│   ├── __pycache__
│   ├── admin.py
│   ├── apps.py
│   ├── migrations
│   ├── models.py
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── patient
│   ├── __init__.py
│   ├── __pycache__
│   ├── admin.py
│   ├── apps.py
│   ├── migrations
│   ├── models.py
│   ├── serializers.py
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── patientinfo
│   ├── __init__.py
│   ├── __pycache__
│   ├── admin.py
│   ├── apps.py
│   ├── migrations
│   ├── models.py
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── readme.md
├── requirements.txt
├── static
│   ├── css
│   ├── images
│   ├── index-bundle.js
│   ├── index-bundle.js.LICENSE.txt
│   └── js-bundle.js
├── staticfiles
│   ├── admin
│   ├── css
│   └── images
├── templates
│   ├── _base.html
│   ├── account
│   ├── appointments
│   ├── frontend.html
│   ├── hello_webpack.html
│   ├── home.html
│   ├── patient
│   └── patientinfo
├── todos.md
└── webpack.config.js
Turns out it was my .gitignore file that was encoded in UTF-16 that was the problem. This seemed to stop Black from working in the whole directory. When I moved all of my files to another directory, I only moved the visible files (so not .gitignore), hence the unusual behaviour. Changing the .gitignore to UTF-8 solved the problem.
I don't even know what django is, but I had the same problem in a non-django program.
In that code fragment was the problem that now is fixed:
open(document.txt, mode= "r", encoding="utf8")
As you can see, the encoding it's utf8, without the "-". I used that code to open documents and read it. I hope it'll be useful!

Django error with test module while running tests

When i run python manage.py tests i get an error saying that some test module is not found.
I am using PyCharm, Django 2.1.4 and W10 on Ubuntu.
The error:
======================================================================
ERROR: projectname.projectname (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: projectname.projectname
Traceback (most recent call last):
File "/usr/lib/python3.6/unittest/loader.py", line 462, in _find_test_path
package = self._get_module_from_name(name)
File "/usr/lib/python3.6/unittest/loader.py", line 369, in _get_module_from_name
__import__(name)
ModuleNotFoundError: No module named 'projectname.projectname'
What I've tried
python manage.py runserver and it runs just fine.
Add projectname to INSTALLED_APPS
Create and app called tests
My project structure
Django
│   ├── requirements.txt
│   └── projectname
│   ├── __init__.py
│   ├── manage.py
│   └── projectname
│   ├── apps
│   │   ├── accounts
│   │   │   ├── admin.py
│   │   │   ├── apps.py
│   │   │   ├── __init__.py
│   │   │   ├── migrations
│   │   │   │   ├── __init__.py
│   │   │   ├── models
│   │   │   │   ├── __init__.py
│   │   │   │   ├── profiles.py
│   │   │   │   └── users.py
│   │   │   ├── serializers
│   │   │   │   └── __init__.py
│   │   │   ├── tests.py
│   │   │   ├── urls.py
│   │   │   └── views
│   │   │   └── __init__.py
│   │   ├── __init__.py
│   ├── db.sqlite3
│   ├── __init__.py
│   ├── settings
│   │   ├── base.py
│   │   ├── development.py
│   │   ├── production.py
│   ├── static
│   ├── templates
│   ├── urls.py
│   └── wsgi.py
I just want to run my tests like in any other django project...
I have never encountered this problem before so any help is appreciated! :)
Well, well...it turns out that changing the folder was the solutio, though i have projects working that share the same folder name so i don't really know what happend with this one.
Before:
Django
│ └── projectname
│ └── projectname
After:
Django
│ └── othername
│ └── projectname

django - cannot import name settings

I'm working on a site in django that is actually in production. I'm trying to run it in local but i get the error: cannot import name settings when i try to access the main page.
This page use the bbcode apps that's correctly installed but that I suspect to be the source of my problem (pages without bbcode work well).
First, as asked here is the hierarchy of my project. Files with a ~ at the end are temporary files created by emacs, so don't pay attention to them. The correct settings.py is the one in /jdrpoly/, The other one was a test to see if it was helping
├── bbcode
│   ├── bbtags
│   │   ├── advanced.py
│   │   ├── advanced.pyc
│   │   ├── brainfuck.py
│   │   ├── brainfuck.pyc
│   │   ├── functional.py
│   │   ├── functional.pyc
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── lists.py
│   │   ├── lists.pyc
│   │   ├── smilies.py
│   │   ├── smilies.pyc
│   │   ├── table.py
│   │   ├── table.pyc
│   │   ├── text_formatting.py
│   │   ├── text_formatting.pyc
│   │   └── web.py
│   ├── cli.py
│   ├── fields.py
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── mypygments.py
│   ├── templates
│   │   └── bbcode
│   │   ├── bbhelp.html
│   │   └── bbtag.html
│   ├── templatetags
│   │   ├── bbcode.py
│   │   ├── bbcode.pyc
│   │   ├── __init__.py
│   │   └── __init__.pyc
│   └── views.py
├── events
│   ├── admin.py
│   ├── admin.pyc
│   ├── forms.py
│   ├── forms.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── migrations
│   │   ├── 0001_initial.py
│   │   ├── 0001_initial.pyc
│   │   ├── __init__.py
│   │   └── __init__.pyc
│   ├── models.py
│   ├── models.pyc
│   ├── tests.py
│   ├── tests.pyc
│   ├── urls.py
│   ├── urls.pyc
│   ├── views.py
│   └── views.pyc
├── jdrpoly
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── settings~
│   ├── settings.py
│   ├── settings.py~
│   ├── settings.pyc
│   ├── urls.py
│   ├── urls.pyc
│   ├── utils
│   │   └── text.py
│   ├── utils.py
│   ├── utils.pyc
│   ├── wsgi.py
│   └── wsgi.pyc
├── LICENSE
├── main
│   ├── admin.py
│   ├── admin.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── migrations
│   │   ├── 0003_contest.py
│   │   ├── 0003_contest.py~
│   │   ├── 0003_contest.pyc
│   │   ├── 0004_comitymember_mainpagesection_news.py
│   │   ├── 0004_comitymember_mainpagesection_news.pyc
│   │   ├── __init__.py
│   │   └── __init__.pyc
│   ├── models.py
│   ├── models.pyc
│   ├── tests.py
│   ├── tests.pyc
│   ├── urls.py
│   ├── urls.pyc
│   ├── views.py
│   └── views.pyc
├── manage.py
├── members
│   ├── admin.py
│   ├── admin.pyc
│   ├── forms.py
│   ├── forms.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── migrations
│   │   ├── 0001_initial.py
│   │   ├── 0001_initial.pyc
│   │   ├── 0002_code_member.py
│   │   ├── 0002_code_member.py~
│   │   ├── 0002_code_member.pyc
│   │   ├── 0003_member.py
│   │   ├── 0003_member.pyc
│   │   ├── __init__.py
│   │   └── __init__.pyc
│   ├── models.py
│   ├── models.pyc
│   ├── templates
│   │   ├── base.html
│   │   ├── comity.html
│   │   ├── concours.djhtml
│   │   ├── contact.html
│   │   ├── contact_success.html
│   │   ├── events
│   │   │   ├── attending.djhtml
│   │   │   ├── campaign_delete.djhtml
│   │   │   ├── campaign_detail.djhtml
│   │   │   ├── campaign_list.djhtml
│   │   │   ├── create.djhtml
│   │   │   ├── edition_view.djhtml
│   │   │   ├── list.djhtml
│   │   │   ├── menu_event.djhtml
│   │   │   ├── new_campaign.djhtml
│   │   │   ├── propose.djhtml
│   │   │   └── view.djhtml
│   │   ├── gallery
│   │   │   ├── list.html
│   │   │   └── view.html
│   │   ├── mainpage.html
│   │   ├── members
│   │   │   ├── code.html
│   │   │   ├── code_mail.txt
│   │   │   ├── code_use.html
│   │   │   ├── create.html
│   │   │   ├── edit.html
│   │   │   ├── main.html
│   │   │   ├── password_change.html
│   │   │   ├── password_change_ok.html
│   │   │   ├── password_reset.html
│   │   │   └── view.html
│   │   ├── news
│   │   │   ├── letter.html
│   │   │   ├── letter_ok.html
│   │   │   └── view.html
│   │   ├── registration
│   │   │   └── login.html
│   │   └── svz
│   │   ├── admin.html
│   │   ├── generic.html
│   │   └── index.html
│   ├── tests.py
│   ├── tests.pyc
│   ├── urls.py
│   ├── urls.pyc
│   ├── views.py
│   └── views.pyc
├── pictures
│   ├── admin.py
│   ├── admin.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── migrations
│   │   ├── 0001_initial.py
│   │   ├── 0001_initial.pyc
│   │   ├── 0002_auto_20150831_1452.py
│   │   ├── 0002_auto_20150831_1452.pyc
│   │   ├── 0003_auto_20161213_2212.py
│   │   ├── 0003_auto_20161213_2212.pyc
│   │   ├── __init__.py
│   │   └── __init__.pyc
│   ├── models.py
│   ├── models.pyc
│   ├── tests.py
│   ├── tests.pyc
│   ├── urls.py
│   ├── urls.pyc
│   ├── views.py
│   └── views.pyc
├── settings.py
├── static
│   ├── assets
│   │   ├── css
│   │   │   ├── font-awesome.min.css
│   │   │   ├── ie8.css
│   │   │   ├── images
│   │   │   │   └── bracket.svg
│   │   │   └── main.css
│   │   ├── fonts
│   │   │   ├── FontAwesome.otf
│   │   │   ├── fontawesome-webfont.eot
│   │   │   ├── fontawesome-webfont.svg
│   │   │   ├── fontawesome-webfont.ttf
│   │   │   ├── fontawesome-webfont.woff
│   │   │   └── fontawesome-webfont.woff2
│   │   ├── js
│   │   │   ├── ie
│   │   │   │   ├── backgroundsize.min.htc
│   │   │   │   ├── html5shiv.js
│   │   │   │   ├── PIE.htc
│   │   │   │   └── respond.min.js
│   │   │   ├── jquery.dropotron.min.js
│   │   │   ├── jquery.min.js
│   │   │   ├── main.js
│   │   │   ├── skel.min.js
│   │   │   ├── skel-viewport.min.js
│   │   │   └── util.js
│   │   └── sass
│   │   ├── ie8.scss
│   │   ├── libs
│   │   │   ├── _functions.scss
│   │   │   ├── _mixins.scss
│   │   │   ├── _skel.scss
│   │   │   └── _vars.scss
│   │   └── main.scss
│   ├── images
│   │   ├── banner.jpg
│   │   ├── banner.png
│   │   ├── default.jpg
│   │   ├── no-image.png
│   │   ├── pic01.jpg
│   │   ├── pic02.jpg
│   │   ├── pic03.jpg
│   │   ├── pic04.jpg
│   │   ├── pic05.jpg
│   │   ├── pic06.jpg
│   │   └── pic07.jpg
│   └── svz
│   ├── assets
│   │   ├── css
│   │   │   ├── font-awesome.min.css
│   │   │   ├── ie8.css
│   │   │   ├── ie9.css
│   │   │   ├── images
│   │   │   │   └── intro.svg
│   │   │   └── main.css
│   │   ├── fonts
│   │   │   ├── FontAwesome.otf
│   │   │   ├── fontawesome-webfont.eot
│   │   │   ├── fontawesome-webfont.svg
│   │   │   ├── fontawesome-webfont.ttf
│   │   │   ├── fontawesome-webfont.woff
│   │   │   └── fontawesome-webfont.woff2
│   │   ├── js
│   │   │   ├── admin.js
│   │   │   ├── ie
│   │   │   │   ├── html5shiv.js
│   │   │   │   └── respond.min.js
│   │   │   ├── jquery.min.js
│   │   │   ├── jquery.scrollex.min.js
│   │   │   ├── jquery.scrolly.min.js
│   │   │   ├── main.js
│   │   │   ├── skel.min.js
│   │   │   └── util.js
│   │   └── sass
│   │   ├── base
│   │   │   ├── _page.scss
│   │   │   └── _typography.scss
│   │   ├── components
│   │   │   ├── _box.scss
│   │   │   ├── _button.scss
│   │   │   ├── _features.scss
│   │   │   ├── _form.scss
│   │   │   ├── _icon.scss
│   │   │   ├── _image.scss
│   │   │   ├── _list.scss
│   │   │   ├── _section.scss
│   │   │   ├── _split.scss
│   │   │   ├── _spotlights.scss
│   │   │   ├── _table.scss
│   │   │   └── _wrapper.scss
│   │   ├── ie8.scss
│   │   ├── ie9.scss
│   │   ├── layout
│   │   │   ├── _footer.scss
│   │   │   ├── _header.scss
│   │   │   ├── _intro.scss
│   │   │   ├── _sidebar.scss
│   │   │   └── _wrapper.scss
│   │   ├── libs
│   │   │   ├── _functions.scss
│   │   │   ├── _mixins.scss
│   │   │   ├── _skel.scss
│   │   │   └── _vars.scss
│   │   └── main.scss
│   └── images
│   ├── pic01.jpg
│   ├── pic02.jpg
│   ├── pic03.jpg
│   ├── pic04.jpg
│   ├── pic05.jpg
│   └── pic06.jpg
└── svz
├── admin.py
├── admin.pyc
├── apps.py
├── __init__.py
├── __init__.pyc
├── migrations
│   ├── 0001_initial.py
│   ├── 0001_initial.pyc
│   ├── 0002_auto_20161213_2212.py
│   ├── 0002_auto_20161213_2212.pyc
│   ├── 0003_auto_20170209_1516.py
│   ├── 0003_auto_20170209_1516.pyc
│   ├── 0004_auto_20170209_1612.py
│   ├── 0004_auto_20170209_1612.pyc
│   ├── 0005_auto_20170209_1621.py
│   ├── 0005_auto_20170209_1621.pyc
│   ├── 0006_auto_20170224_1248.py
│   ├── 0006_auto_20170224_1248.pyc
│   ├── 0007_player_faction.py
│   ├── 0007_player_faction.pyc
│   ├── 0008_auto_20170313_1033.py
│   ├── 0008_auto_20170313_1033.pyc
│   ├── __init__.py
│   └── __init__.pyc
├── models.py
├── models.pyc
├── templates
│   └── svz
│   └── concours_affiche.html
├── tests.py
├── tests.pyc
├── urls.py
├── urls.pyc
├── views.py
└── views.pyc
When i run manage.py runserver everything goes well
Then here is the StackTrace when i'm trying to access the main page:
Traceback (most recent call last):
File "/usr/lib64/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/usr/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
return self.application(environ, start_response)
File "/usr/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 170, in __call__
response = self.get_response(request)
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 124, in get_response
response = self._middleware_chain(request)
File "/usr/lib/python2.7/site-packages/django/core/handlers/exception.py", line 44, in inner
response = response_for_exception(request, exc)
File "/usr/lib/python2.7/site-packages/django/core/handlers/exception.py", line 94, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/usr/lib/python2.7/site-packages/django/core/handlers/exception.py", line 42, in inner
response = get_response(request)
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
response = self._get_response(request)
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 217, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 215, in _get_response
response = response.render()
File "/usr/lib/python2.7/site-packages/django/template/response.py", line 109, in render
self.content = self.rendered_content
File "/usr/lib/python2.7/site-packages/django/template/response.py", line 84, in rendered_content
template = self.resolve_template(self.template_name)
File "/usr/lib/python2.7/site-packages/django/template/response.py", line 66, in resolve_template
return select_template(template, using=self.using)
File "/usr/lib/python2.7/site-packages/django/template/loader.py", line 48, in select_template
return engine.get_template(template_name)
File "/usr/lib/python2.7/site-packages/django/template/backends/django.py", line 39, in get_template
return Template(self.engine.get_template(template_name), self)
File "/usr/lib/python2.7/site-packages/django/template/engine.py", line 160, in get_template
template, origin = self.find_template(template_name)
File "/usr/lib/python2.7/site-packages/django/template/engine.py", line 134, in find_template
name, template_dirs=dirs, skip=skip,
File "/usr/lib/python2.7/site-packages/django/template/loaders/base.py", line 44, in get_template
contents, origin, origin.template_name, self.engine,
File "/usr/lib/python2.7/site-packages/django/template/base.py", line 191, in __init__
self.nodelist = self.compile_nodelist()
File "/usr/lib/python2.7/site-packages/django/template/base.py", line 233, in compile_nodelist
return parser.parse()
File "/usr/lib/python2.7/site-packages/django/template/base.py", line 518, in parse
raise self.error(token, e)
ImportError: cannot import name settings
[02/Nov/2017 19:10:31] "GET / HTTP/1.1" 500 59
I checked all the imports and they are correct, tried to specify the settings directly when running manage.py with --settings=..., tried also to specify the PYTHONPATH.
I've run out of ideas.
One last thing, this website, with exactly the same files is currently running on a server and do not have any problems of this kind.
Try this:
from django.conf import settings

Issue with turning a test file into a package with __init__.py

I am following along with this tutorial:
http://www.marinamele.com/taskbuster-django-tutorial/create-home-page-with-tdd-staticfiles-templates-settings
When I run:
(tb_test)metersk:functional_tests metersky$ python test_all_users.py
.
----------------------------------------------------------------------
Ran 1 test in 2.313s
OK
The test works as it should. The test being :
from selenium import webdriver
import unittest
class NewVisitorTest(unittest.TestCase):
def setUp(self):
self.browser = webdriver.Firefox()
self.browser.implicitly_wait(3)
def tearDown(self):
self.browser.quit()
def test_it_worked(self):
self.browser.get('http://localhost:8000')
self.assertIn('Welcome to Django', self.browser.title)
if __name__ == '__main__':
unittest.main(warnings='ignore')
However, when I follow the step to add a blank __init__.py file to the directory, and I run the test like so: python manage.py test functional_tests
I get a the following failure:
Traceback (most recent call last):
File "/Users/metersky/code/taskbuster_project/taskbuster/settings/base.py", line 20, in get_env_variable
return os.environ[var_name]
File "/Users/metersky/.virtualenvs/tb_test/bin/../lib/python3.4/os.py", line 633, in __getitem__
raise KeyError(key) from None
KeyError: 'SECRET_KEY'
File "/Users/metersky/code/taskbuster_project/taskbuster/settings/__init__.py", line 2, in <module>
from .base import *
File "/Users/metersky/code/taskbuster_project/taskbuster/settings/base.py", line 31, in <module>
SECRET_KEY = get_env_variable('SECRET_KEY')
File "/Users/metersky/code/taskbuster_project/taskbuster/settings/base.py", line 23, in get_env_variable
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: set the SECRET_KEY environment variable
I don't quite understand how calling the test script differently from the command line would prevent the program from finding the secret key environment variable. It clearly works when I call the script on its own.
Folder structure:
├── TaskBuster.sublime-project
├── TaskBuster.sublime-workspace
├── db.sqlite3
├── functional_tests
│   ├── __init__.py
│   └── test_all_users.py
├── manage.py
├── requirements
│   ├── base.txt
│   ├── development.txt
│   ├── production.txt
│   └── testing.txt
└── taskbuster
├── __init__.py
├── __pycache__
│   ├── __init__.cpython-34.pyc
│   ├── settings.cpython-34.pyc
│   ├── urls.cpython-34.pyc
│   └── wsgi.cpython-34.pyc
├── db.sqlite3
├── settings
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-34.pyc
│   │   ├── base.cpython-34.pyc
│   │   └── development.cpython-34.pyc
│   ├── base.py
│   ├── development.py
│   ├── production.py
│   ├── staging.py
│   └── testing.py
├── static
│   ├── css
│   │   ├── bootstrap-theme.css
│   │   ├── bootstrap-theme.css.map
│   │   ├── bootstrap-theme.min.css
│   │   ├── bootstrap.css
│   │   ├── bootstrap.css.map
│   │   ├── bootstrap.min.css
│   │   └── main.css
│   ├── favicon.ico
│   ├── fonts
│   │   ├── glyphicons-halflings-regular.eot
│   │   ├── glyphicons-halflings-regular.svg
│   │   ├── glyphicons-halflings-regular.ttf
│   │   └── glyphicons-halflings-regular.woff
│   ├── img
│   └── js
│   ├── main.js
│   └── vendor
│   ├── bootstrap.js
│   ├── bootstrap.min.js
│   ├── jquery-1.11.2.min.js
│   ├── modernizr-2.8.3-respond-1.4.2.min.js
│   └── npm.js
├── templates
│   ├── 404.html
│   ├── base.html
│   ├── humans.txt
│   └── robots.txt
├── urls.py
└── wsgi.py

Import Error, Django CMS

Hello I am working on a converting mine django app to django cms 3.0.
After I have connected mine django app, installed third party apps, done syncdb, migrate etc, and go whit runserver, I have encounter this Error:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/en/
Django Version: 1.6.11
Python Version: 2.7.6
Installed Applications:
('djangocms_admin_style',
'djangocms_text_ckeditor',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'django.contrib.messages',
'cms',
'menus',
'sekizai',
'mptt',
'djangocms_style',
'djangocms_column',
'djangocms_file',
'djangocms_flash',
'djangocms_googlemap',
'djangocms_inherit',
'djangocms_link',
'djangocms_picture',
'djangocms_teaser',
'djangocms_video',
'south',
'reversion',
'djangotocms',
'social_auth',
'crispy_forms',
'django.contrib.sites',
'allauth',
'allauth.account',
'djangotocms.django_app.project_template',
'djangotocms.django_app.profiles',
'djangotocms.django_app.pricing',
'djangotocms.django_app.blog',
'djangotocms.django_app.contacts')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware')
Traceback:
File "/home/petarp/.virtualenvs/cms_daryl/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
112. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/petarp/.virtualenvs/cms_daryl/local/lib/python2.7/site-packages/cms/views.py" in details
74. page = get_page_from_request(request, use_path=slug)
File "/home/petarp/.virtualenvs/cms_daryl/local/lib/python2.7/site-packages/cms/utils/page_resolver.py" in get_page_from_request
116. page = get_page_from_path(path, preview, draft)
File "/home/petarp/.virtualenvs/cms_daryl/local/lib/python2.7/site-packages/cms/utils/page_resolver.py" in get_page_from_path
72. return get_page_queryset_from_path(path, preview, draft).get()
File "/home/petarp/.virtualenvs/cms_daryl/local/lib/python2.7/site-packages/cms/utils/page_resolver.py" in get_page_queryset_from_path
32. admin_base = admin_reverse('index')
File "/home/petarp/.virtualenvs/cms_daryl/local/lib/python2.7/site-packages/cms/utils/urlutils.py" in admin_reverse
101. current_app=current_app
File "/home/petarp/.virtualenvs/cms_daryl/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse
507. app_list = resolver.app_dict[ns]
File "/home/petarp/.virtualenvs/cms_daryl/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in app_dict
329. self._populate()
File "/home/petarp/.virtualenvs/cms_daryl/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in _populate
290. for name in pattern.reverse_dict:
File "/home/petarp/.virtualenvs/cms_daryl/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse_dict
315. self._populate()
File "/home/petarp/.virtualenvs/cms_daryl/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in _populate
290. for name in pattern.reverse_dict:
File "/home/petarp/.virtualenvs/cms_daryl/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse_dict
315. self._populate()
File "/home/petarp/.virtualenvs/cms_daryl/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in _populate
303. lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args))
File "/home/petarp/.virtualenvs/cms_daryl/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in callback
230. self._callback = get_callable(self._callback_str)
File "/home/petarp/.virtualenvs/cms_daryl/local/lib/python2.7/site-packages/django/utils/functional.py" in wrapper
32. result = func(*args)
File "/home/petarp/.virtualenvs/cms_daryl/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in get_callable
101. not module_has_submodule(import_module(parentmod), submod)):
File "/home/petarp/.virtualenvs/cms_daryl/local/lib/python2.7/site-packages/django/utils/importlib.py" in import_module
40. __import__(name)
Exception Type: ImportError at /en/
Exception Value: No module named contacts
Can someone please tell me what am I missing here?
Tank you.
This is tree of mine project:
Djangotocms
├── djangotocms
│   ├── django_app
│   │   ├── blog
│   │   │   ├── admin.py
│   │   │   ├── admin.pyc
│   │   │   ├── __init__.py
│   │   │   ├── __init__.pyc
│   │   │   ├── migrations
│   │   │   │   ├── 0001_initial.py
│   │   │   │   ├── 0001_initial.pyc
│   │   │   │   ├── __init__.py
│   │   │   │   └── __init__.pyc
│   │   │   ├── models.py
│   │   │   ├── models.pyc
│   │   │   ├── tests.py
│   │   │   ├── views.py
│   │   │   └── views.pyc
│   │   ├── contacts
│   │   │   ├── admin.py
│   │   │   ├── admin.pyc
│   │   │   ├── forms.py
│   │   │   ├── forms.pyc
│   │   │   ├── __init__.py
│   │   │   ├── __init__.pyc
│   │   │   ├── migrations
│   │   │   │   ├── 0001_initial.py
│   │   │   │   ├── 0001_initial.pyc
│   │   │   │   ├── __init__.py
│   │   │   │   └── __init__.pyc
│   │   │   ├── models.py
│   │   │   ├── models.pyc
│   │   │   ├── tests.py
│   │   │   ├── views.py
│   │   │   └── views.pyc
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── pricing
│   │   │   ├── admin.py
│   │   │   ├── admin.pyc
│   │   │   ├── __init__.py
│   │   │   ├── __init__.pyc
│   │   │   ├── migrations
│   │   │   │   ├── 0001_initial.py
│   │   │   │   ├── 0001_initial.pyc
│   │   │   │   ├── __init__.py
│   │   │   │   └── __init__.pyc
│   │   │   ├── models.py
│   │   │   ├── models.pyc
│   │   │   ├── tests.py
│   │   │   ├── views.py
│   │   │   └── views.pyc
│   │   ├── profiles
│   │   │   ├── admin.py
│   │   │   ├── admin.pyc
│   │   │   ├── __init__.py
│   │   │   ├── __init__.pyc
│   │   │   ├── migrations
│   │   │   │   ├── 0001_initial.py
│   │   │   │   ├── 0001_initial.pyc
│   │   │   │   ├── __init__.py
│   │   │   │   └── __init__.pyc
│   │   │   ├── models.py
│   │   │   ├── models.pyc
│   │   │   ├── tests.py
│   │   │   ├── views.py
│   │   │   └── views.pyc
│   │   └── project_template
│   │   ├── __init__.py
│   │   ├── __init__.pyc
│   │   ├── settings.py
│   │   ├── settings.pyc
│   │   ├── urls.py
│   │   ├── urls.pyc
│   │   ├── wsgi.py
│   │   └── wsgi.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── settings.py
│   ├── settings.pyc
│   ├── static
│   ├── templates
│   │   ├── base.html
│   │   ├── fullwidth.html
│   │   ├── home.html
│   │   ├── navbar.html
│   │   ├── sidebar_left.html
│   │   └── sidebar_right.html
│   ├── urls.py
│   ├── urls.pyc
│   ├── wsgi.py
│   └── wsgi.pyc
├── manage.py
├── media
├── project.db
├── requirements.txt
├── static
├── untitled.sublime-project
└── untitled.sublime-workspace

Categories