Forums

django cms - how to link from cms-project-folder to www.myusername.pythonanywhere.com

Hello!

I sucessfully installed django-cms on "home > Ferki2 > my-site > env > projektordner > meinprojekt" . But when i go to my domain " Ferki2.pythonanywhere.com " I still get the following standard-message:

It worked! Congratulations on your first Django-powered page.

I would like to see the frontend or the backend of the django-cms on " Ferki2.pythonanywhere.com ". Can someboy tell me, which file(s) I have to modify and to what I have to change the code inside this file(s)?

Thank your very much! Bernd

Hi, did you included the urls in your project's urls.py?

url(r'^', include('cms.urls')),

Also, if you are not familiar with Django-CMS you should check it out:

http://docs.django-cms.org/en/support-3.0.x/introduction/install_from_scratch.html

Thank you very much for the tip, but the cms-installer did that for me. What I was looking for, was the "WSGI configuration file" in the web-tab: I have to change 2 entries. I`m not sure if my modifications where correct. Fact is, that I still get error messages. Any Idea?

My WSGI configuration file:

# This file contains the WSGI configuration required to serve up your
# web application at http://Ferki2.pythonanywhere.com/
# It works by setting the variable 'application' to a WSGI handler of some
# description.
#
# The below has been auto-generated for your Django project

import os
import sys

# add your project directory to the sys.path
# sicherung: project_home = u'/home/Ferki2/gravity'
project_home = u'/home/Ferki2/my-site/env/projektordner
if project_home not in sys.path:
    sys.path.append(project_home)

# set environment variable to tell django where your settings.py is
# sicherung: os.environ['DJANGO_SETTINGS_MODULE'] = 'gravity.settings'
os.environ['DJANGO_SETTINGS_MODULE'] = 'meinprojekt.settings'

# serve django via WSGI
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

[edited by admin: formatting]

Does this help? https://www.pythonanywhere.com/wiki/DebuggingImportError

Hi harry! Before I try out your suggestion, I want to test another thing. My project is within an virtual environment. Do I have do change the "WSGI configuration file" to something like I can see here: https://www.pythonanywhere.com/wiki/VirtualEnvForNewerDjango? Or is this an old text?

Thank you very much

Bernd

Yes, you'll need the activate_this lines in your wsgi file...

Yes, you do.

. My installation is here:

/ > home > Ferki2 > my-site > env > projektordner = (on this path the manage.py is located)

/ > home > Ferki2 > my-site > env > projektordner > meinprojekt =(And here the settings.py is located)

I used the following code, which I found on https://www.pythonanywhere.com/wiki/VirtualEnvForNewerDjango, but I cant find the mistake(s). Can you please help me and have a look at it?:)

activate_this = '/home/Ferki2/my-site/env/bin/activate_this.py'
with open(activate_this) as f:
    code = compile(f.read(), activate_this, 'exec')
    exec(code, dict(__file__=activate_this))

import os
import sys

path = '/home/Ferki2/my-site/env/projektordner/'


if path not in sys.path:
    sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'meinprojekt.settings'

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

[edited by admin: formatting]

Did you follow the debugging tips in https://www.pythonanywhere.com/wiki/DebuggingImportError? Did they reveal anything?

Yes, I now followed the debugging tips. I was able to import my.project.settings and I can also run the wsgi-file itself. I am a little bit confused about that I was able to run the files " trying to import with python" "/home/Ferki2/my-site/env/projektordner/meinprojekt/settings.py" but when I do it in the web app the error log "tells" me I should use "/home/Ferki2/my-site/env/projektordner/settings.py". When I use the second path the message changes from:

Traceback (most recent call last):
2015-01-21 14:15:57,475 :  File "/bin/user_wsgi_wrapper.py", line 130, in __call__
2015-01-21 14:15:57,476 :    self.error_log_file.logger.exception("Error running WSGI application")
2015-01-21 14:15:57,476 :  File "/usr/lib/python3.4/logging/__init__.py", line 1296, in exception
2015-01-21 14:15:57,476 :    self.error(msg, *args, **kwargs)
2015-01-21 14:15:57,477 :  File "/usr/lib/python3.4/logging/__init__.py", line 1289, in error
2015-01-21 14:15:57,477 :    self._log(ERROR, msg, args, **kwargs)
2015-01-21 14:15:57,477 :  File "/usr/lib/python3.4/logging/__init__.py", line 1395, in _log
2015-01-21 14:15:57,478 :    self.handle(record)
2015-01-21 14:15:57,478 :  File "/usr/lib/python3.4/logging/__init__.py", line 1404, in handle
2015-01-21 14:15:57,479 :    if (not self.disabled) and self.filter(record):
2015-01-21 14:15:57,479 :  File "/usr/lib/python3.4/logging/__init__.py", line 692, in filter
2015-01-21 14:15:57,479 :    for f in self.filters:
2015-01-21 14:15:57,480 :  File "/bin/user_wsgi_wrapper.py", line 122, in __call__
2015-01-21 14:15:57,480 :    app_iterator = self.app(environ, start_response)
2015-01-21 14:15:57,480 :  File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
2015-01-21 14:15:57,480 :    self.load_middleware()
2015-01-21 14:15:57,480 :  File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py", line 44, in load_middleware
2015-01-21 14:15:57,481 :    for middleware_path in settings.MIDDLEWARE_CLASSES:
2015-01-21 14:15:57,481 :  File "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 54, in __getattr__
2015-01-21 14:15:57,481 :    self._setup(name)
2015-01-21 14:15:57,481 :  File "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 49, in _setup
2015-01-21 14:15:57,481 :    self._wrapped = Settings(settings_module)
2015-01-21 14:15:57,481 :  File "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 132, in __init__
2015-01-21 14:15:57,482 :    % (self.SETTINGS_MODULE, e)
2015-01-21 14:15:57,482 :ImportError: Could not import settings 'meinprojekt.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named 'meinprojekt'

into

Traceback (most recent call last):
2015-01-21 08:19:41,028 :  File "/bin/user_wsgi_wrapper.py", line 130, in __call__
2015-01-21 08:19:41,028 :    self.error_log_file.logger.exception("Error running WSGI application")
2015-01-21 08:19:41,028 :  File "/usr/lib/python3.4/logging/__init__.py", line 1296, in exception
2015-01-21 08:19:41,030 :    self.error(msg, *args, **kwargs)
2015-01-21 08:19:41,030 :  File "/usr/lib/python3.4/logging/__init__.py", line 1289, in error
2015-01-21 08:19:41,030 :    self._log(ERROR, msg, args, **kwargs)
2015-01-21 08:19:41,031 :  File "/usr/lib/python3.4/logging/__init__.py", line 1395, in _log
2015-01-21 08:19:41,031 :    self.handle(record)
2015-01-21 08:19:41,031 :  File "/usr/lib/python3.4/logging/__init__.py", line 1404, in handle
2015-01-21 08:19:41,032 :    if (not self.disabled) and self.filter(record):
2015-01-21 08:19:41,032 :  File "/usr/lib/python3.4/logging/__init__.py", line 692, in filter
2015-01-21 08:19:41,032 :    for f in self.filters:
2015-01-21 08:19:41,032 :  File "/bin/user_wsgi_wrapper.py", line 122, in __call__
2015-01-21 08:19:41,032 :    app_iterator = self.app(environ, start_response)
2015-01-21 08:19:41,033 :  File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
2015-01-21 08:19:41,033 :    self.load_middleware()
2015-01-21 08:19:41,033 :  File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py", line 47, in load_middleware
2015-01-21 08:19:41,034 :    mw_instance = mw_class()
2015-01-21 08:19:41,034 :  File "/usr/local/lib/python3.4/dist-packages/django/middleware/locale.py", line 24, in __init__
2015-01-21 08:19:41,034 :    for url_pattern in get_resolver(None).url_patterns:
2015-01-21 08:19:41,034 :  File "/usr/local/lib/python3.4/dist-packages/django/core/urlresolvers.py", line 365, in url_patterns
2015-01-21 08:19:41,035 :    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
2015-01-21 08:19:41,035 :  File "/usr/local/lib/python3.4/dist-packages/django/core/urlresolvers.py", line 360, in urlconf_module
2015-01-21 08:19:41,035 :    self._urlconf_module = import_module(self.urlconf_name)
2015-01-21 08:19:41,035 :  File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
2015-01-21 08:19:41,040 :    return _bootstrap._gcd_import(name[level:], package, level)
2015-01-21 08:19:41,040 :  File "<frozen importlib._bootstrap>", line 2231, in _gcd_import
2015-01-21 08:19:41,041 :  File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
2015-01-21 08:19:41,041 :  File "<frozen importlib._bootstrap>", line 2203, in _find_and_load_unlocked
2015-01-21 08:19:41,041 :  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
2015-01-21 08:19:41,042 :  File "<frozen importlib._bootstrap>", line 1129, in _exec
2015-01-21 08:19:41,042 :  File "<frozen importlib._bootstrap>", line 1448, in exec_module
2015-01-21 08:19:41,042 :  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
2015-01-21 08:19:41,042 :  File "/home/Ferki2/my-site/env/projektordner/meinprojekt/urls.py", line 2, in <module>
2015-01-21 08:19:41,044 :    from cms.sitemaps import CMSSitemap
2015-01-21 08:19:41,045 :ImportError: No module named 'cms'

This is the reason why I think, that this is the correct path

Anything else, what I can do?

Thank you

[edit by admin: formatting]

The error No module named 'cms' suggests that it can't find the Django-CMS install. How did you create the virtualenv? And how did you install Django-CMS into it?

I set up another webapp with a new user. I tried to take the same way to install it. Could you please have a look at it. I tried to bring it in a more comfortable format to read it. I always get problems to follow the installation-tutorial on "https://github.com/divio/django-cms-tutorial/blob/master/Step%201%20-%20Initial%20Setup.md" between 11:28 and 11:29. Maybe the mistake is there (activating the env and installing the cms)?

Thank you very much

13:19 ~ $ cd /home/Ferki4

13:20 ~ $ cd page_eg/page_eg

13:21 ~/page_eg/page_eg $ mkdir my-site && cd my-site

13:22 ~/page_eg/page_eg/my-site $ virtualenv env New python executable in env/bin/python2.7Also creating executable in env/bin/pythonInstalling setuptools, pip...done.

13:26 /home $ cd Ferki413:26 ~ $ cd page_eg

13:26 ~/page_eg $ cd page_eg

13:28 ~/page_eg/page_eg $ cd my-site

13:28 ~/page_eg/page_eg/my-site $ source env/bin/activate(env)

13:29 ~/page_eg/page_eg/my-site $ pip install djangocms-installer Downloading/unpacking djangocms-installer Downloading djangocms_installer-0.7.1-py2.py3-none-any.whl (45kB): 45kB downloadedDownloading/unpacking dj-database-url (from djangocms-installer) Downloading dj_database_url-0.3.0-py2.py3-none-any.whlDownloading/unpacking requests (from djangocms-installer) Downloading requests-2.5.1-py2.py3-none-any.whl (464kB): 464kB downloadedRequirement already satisfied (use --upgrade to upgrade): pip in ./env/lib/python2.7/site-packages (from djangocms-installer)Downloading/unpacking six (from djangocms-installer) Downloading six-1.9.0-py2.py3-none-any.whlRequirement already satisfied (use --upgrade to upgrade): argparse in /usr/lib/python2.7 (from djangocms-installer)Installing collected packages: djangocms-installer, dj-database-url, requests, sixSuccessfully installed djangocms-installer dj-database-url requests sixCleaning up...

(env)13:29 ~/page_eg/page_eg/my-site $ djangocms -p home/Ferki4/page_eg/page_eg/my-site/env/projektdirectory_eg

mysiteDatabase configuration (in URL format) [default sqlite://localhost/project.db]:

django CMS version (choices: 2.4, 3.0, stable, develop) [default stable]:3.0

Django version (choices: 1.4, 1.5, 1.6, 1.7, stable) [default stable]: 1.7

Activate Django I18N / L10N setting (choices: yes, no) [default yes]:

Install and configure reversion support (choices: yes, no) [default yes]:

Languages to enable. Option can be provided multiple times, or as a comma separated list. Only language codes supported by Django can be used here: en,de

Optional default time zone [default America/Chicago]: Activate Django timezone support (choices: yes, no) [default yes]:
Activate CMS permission management (choices: yes, no) [default yes]:

Use Twitter Bootstrap Theme (choices: yes, no) [default no]: yes

Use custom template set [default no]:

Load a starting page with examples after installation. Choose "no" if you use a custom template set. (choices: yes, no) [default no]: yes

and so on .............

[edit by admin: formatting]

I think this may be a version mismatch problem. I can see that your web app is configured to use Python 3.4, but you're installing everything for Python 2.7. Perhaps if you create a Python 2.7 web app everything will work better?

Thank you for the tip with the version. I think that was a step forward. I now get another message that the system is missing a table:

Exception Type: OperationalError at / Exception Value: no such table: django_site

But this is not true. The installer istalled it:

Creating tables ...Creating table djangocms_text_ckeditor_text

Creating table django_session Creating table django_admin_log Creating table django_site Creating table cms_usersettings Creating table cms_placeholder

Do you think its possible that the system now dont find the database, although before everything was created in the database during the installation?

have you run syncdb yet?

Yes I have (the system told me, I should use python "manage.py migrate", but I still get the following:

Request Method: GET Request URL: http://ferki6.pythonanywhere.com/ Django Version: 1.6.10 Exception Type: OperationalError Exception Value:

no such table: django_site

Exception Location: /home/Ferki6/gravity/my-site/env/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py in execute, line 452 Python Executable: /usr/local/bin/uwsgi Python Version: 2.7.6 Python Path:

['/home/Ferki6/gravity/my-site/env/lib/python2.7/site-packages', '/var/www',

Do you think that the following code(autogenerated by django-cms-istall) in the settings.py is the reason?

DATABASES = { 'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'project.db', 'HOST': 'localhost', 'USER': '', 'PASSWORD': '', 'PORT': ''} }

Should I try to setup a mysql-database instead of the sqlite3?

Use the full path to your database file. The migrate you're running in the console is working on a different file to the one that your web app is reading.