Lonto81
Lonto81

Reputation: 93

Django project on pythonanywhere

I uploaded my app that worked fine on my local machine to pythonanywhere. I got it to work but instead of showing the homepage of my blog it shows the "It worked, welcome to Django" page. Could someone please help me?

Upvotes: 2

Views: 149

Answers (2)

magula
magula

Reputation: 151

OK I got it. Here's what I did:


1) If the Django shells insist on prepending 'magula4' to the model name, why not prepend magula4 to the table name when I create the table? Click on mesas676$magula4 database on pythonanywhere Databases tab:

mysql> CREATE TABLE mesas676$magula4.cw_operator (id INT, name CHAR(255), slug CHAR(255));
mysql> INSERT INTO mesas676$magula4.cw_operator (id,name,slug) VALUES(4255,'ARMER M B', 'armermb');
mysql> SELECT * FROM mesas676$magula4.cw_operator;

| id   | name            | slug          |
| 4255 | ARMER M B       | armermb       |

2) ALTER TABLE as needed until you have all the fields that are in the Django model e.g.:

mysql> ALTER TABLE mesas676$magula4.cw_operator ADD COLUMN wells BOOLEAN;

3) change Django DATABASES settings to magula4:

DATABASES = {'default': {'ENGINE': 'django.db.backends.mysql', 'NAME': 'mesas676$magula4', 'USER': 'mesas676', 'PASSWORD' : bigsecretR5%t*', 'HOST': 'mesas676.mysql.pythonanywhere-services.com', 'PORT': '3306', } }

4) Django shell:

`$ ./manage.py shell
In [4]: from cw.models import *
In [5]: o=Operator.objects.get(id=4255)
In [6]: o.name
Out [14]: 'ARMER M B'`

hurrah!

Upvotes: 0

hwjp
hwjp

Reputation: 16071

the two main stumbling blocks for people uploading apps to PythonAnywhere tend to be getting the correct version of django, and getting the WSGI configuration right.

For the former, we recommend using a virtualenv. There's a detailed how-to guide here: https://www.pythonanywhere.com/wiki/Virtualenvs

For the wsgi file, there's a detailed guide to getting imports correct here: https://www.pythonanywhere.com/wiki/DebuggingImportError

Upvotes: 2

Related Questions