Trouble with Django in production server.

186 views
Skip to first unread message

Omar Acevedo

unread,
Mar 1, 2014, 5:52:56 PM3/1/14
to django...@googlegroups.com
Hello people, I'm having an issue in/with Django, which is on a shared hosting, and I'm using virtualenv and fastcgi.  (<- saying this, just in case it helps in something)

I'm getting
"OperationalError at /admin/
no such table: auth_user"
after entering my credentials (username & pw) set when asked after running the syncdb.
Yes, I created a project (django-admin.py startproject the_project),  then ran python manage.py syncdb.
So it's supposed (which it says it does) to create the tables for the admin, but still, I'm getting that error when going to the admin through mydomain.com/admin.

I'm a first-timer hosting a django app, so, what else I'm supposed to know, to do?  

When I put Debug to False (DEBUG = False) inside the settings.py file and my email in the ADMINS tuple (inside settings.py) I do get this error message to my email. 
Which is (I'm posting it, to see if someone can tell me what's going on.):

 'HTTP_CONNECTION': 'close',
 'HTTP_COOKIE': 'csrftoken=Ds5T9Lx4JLgO9m6vCu0EEeLX4tVHr7dH',
 'HTTP_HOST': 'thisisnottherealdomain .com',
 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36',
 'HTTP_X_FORWARDED_FOR': '##.###.###.###',
 'HTTP_X_REAL_IP': '##.###.###.###',
 'PATH': '/sbin:/usr/sbin:/bin:/usr/bin',
 'PATH_INFO': u'/',
 'PATH_TRANSLATED': 'redirect:/dispatch.fcgi/',
 'QUERY_STRING': '',
 'REDIRECT_STATUS': '200',
 'REDIRECT_UNIQUE_ID': 'UxJiK0Fj7YUAAE6ava0AAAAN',
 'REDIRECT_URL': '/',
 'REMOTE_ADDR': '##.###.###.###',
 'REMOTE_PORT': '39403',
 'REQUEST_METHOD': 'GET',
 'REQUEST_URI': '/',
 'SCRIPT_FILENAME': '/home/somename/public_html/dispatch.fcgi',
 'SCRIPT_NAME': u'',
 'SERVER_ADDR': '###.##.##.###',
 'SERVER_ADMIN': 'webmaster @ thisisnottherealdomain .com',
 'SERVER_NAME': 'thisisnottherealdomain .com',
 'SERVER_PORT': '80',
 'SERVER_PROTOCOL': 'HTTP/1.0',
 'SERVER_SIGNATURE': '',
 'SERVER_SOFTWARE': 'Apache',
 'UNIQUE_ID': 'UxJiK0Fj7YUAAE6ava0AAAAN',
 'wsgi.errors': <flup.server.fcgi_base.OutputStream object at 0x7f0b2868bf50>,
 'wsgi.input': <flup.server.fcgi_base.InputStream object at 0x7f0b2868bf90>,
 'wsgi.multiprocess': False,
 'wsgi.multithread': True,
 'wsgi.run_once': False,
 'wsgi.url_scheme': 'http',
 'wsgi.version': (1, 0)}>

Jonathan Baker

unread,
Mar 1, 2014, 7:11:58 PM3/1/14
to django...@googlegroups.com
When you ran the 'syncdb' management command, was 'auth_user' listed in the output as a table that was created?


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3afc2a85-5bf1-4170-ace2-bd789babdb33%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Omar Acevedo

unread,
Mar 1, 2014, 7:12:42 PM3/1/14
to django...@googlegroups.com
Yes!


--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/VXpy867egD8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

Jonathan Baker

unread,
Mar 1, 2014, 7:34:23 PM3/1/14
to django...@googlegroups.com
Are you using multiple settings files, for example: dev.py, pro.py, etc.? Are you sure that the settings file you're using is configured to use the database on your production server?



For more options, visit https://groups.google.com/groups/opt_out.



--
Jonathan D. Baker
Developer
http://jonathandbaker.com

Omar Acevedo

unread,
Mar 1, 2014, 7:36:57 PM3/1/14
to django...@googlegroups.com
While trying and trying different stuff, turned out to be a bad path configuration with the NAME inside the DATABASES dictionary within the settings.py file.


Omar Acevedo

unread,
Mar 1, 2014, 7:39:26 PM3/1/14
to django...@googlegroups.com
I explicitly wrote '/home/catacafe/.env/env/lib/python2.7/db.sqlite3' in the NAME option of the DATABASES dictionary.

Omar Acevedo

unread,
Mar 1, 2014, 7:41:31 PM3/1/14
to django...@googlegroups.com
To see if it worked, and yes it did!
So, I'm just having trouble with the paths.
I'm using a virtual environment.
So I guess I'll have to deal with the paths.
Thank you a lot anyways!!! :)

Jonathan D. Baker

unread,
Mar 1, 2014, 8:16:10 PM3/1/14
to django...@googlegroups.com
Instead of hard-coding paths, check out os.path, os.abspath and os.sep (and the rest of the os module) for such needs. I usually declare a PROJECT_ROOT var at the top of my settings.py using the aforementioned os module, and then hang paths (like your db path) off of that instead of building each path individually.

Glad you figured it out.

Sent from my iPhone
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

Camilo Torres

unread,
Mar 2, 2014, 6:19:35 PM3/2/14
to django...@googlegroups.com
You also should be activating your virtualenv to run the server.

Omar Acevedo

unread,
Mar 2, 2014, 10:06:51 PM3/2/14
to django...@googlegroups.com
I have inside a file called .bashrc, 
source /home/userName/.env/env/bin/active, 
which makes me be in in a virtual environment already, no?
It has a (env) to the left all the time.
I presume that that is "activating virtualenv to run the server", right?
(:


--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/VXpy867egD8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

Camilo Torres

unread,
Mar 3, 2014, 7:16:59 PM3/3/14
to django...@googlegroups.com
On Sunday, March 2, 2014 10:36:51 PM UTC-4:30, Omar Acevedo wrote:
I have inside a file called .bashrc, 
source /home/userName/.env/env/bin/active, 
which makes me be in in a virtual environment already, no?
It has a (env) to the left all the time.
I presume that that is "activating virtualenv to run the server", right?
On Sun, Mar 2, 2014 at 7:19 PM, Camilo Torres <camilo...@gmail.com> wrote:
You also should be activating your virtualenv to run the server.

No. You are running your commands in a virtualenv, but I don't know if you are running your server in a virtualenv. For server I mean the software that is serving your web application. You wrote in a previous message that you are using a  shared hosting service, that it means that the same web server is serving for every domain or account? You don't mention what server you are using, for example: apache, lighttpd, nginx. Does the server instance runs in the virtualenv? May be not.

Try to install your application and dependencies out of a virtualenv, server wide.

Omar Acevedo

unread,
Mar 3, 2014, 7:45:43 PM3/3/14
to django...@googlegroups.com
No, the server itself it's not running in a virtualenv.
Yes, it is a shared hosting service which it's both domain and account.  
And about the server, ... well, (idk), I'm using FastCGI, also, I followed this tutorial first ->
https://help.asmallorange.com/index.php?/Knowledgebase/Article/View/140 , then days later they posted this link ( https://help.asmallorange.com/index.php?/Knowledgebase/Article/View/305/0/installing-django-using-virtualenv ) about using the virtualenv, so, it's like that.

Anyways, I noticed that inside the settings.py file, when I put a absolute path in the NAME of the DATABASE, then it kinda worked.
"Kinda worked" in a sense that it actually let me go to the admin with no problem, ... BUT, ... when I create an application with the startapp command, and then create a model and then add it to the admin so I can see the model inside the admin, THEN it shows this error message -> "Unhandled Exception An unhandled exception was thrown by the application." 

And yes, I do run the syncbd so the tables get created, but still nothing.
:(

Omar Acevedo

unread,
Mar 3, 2014, 7:54:48 PM3/3/14
to django...@googlegroups.com
Also there's a file called .bashrc which activates the virtualenv.
This is the line that does that:
    source /home/userName/.env/env/bin/activate
So it runs (the virtualenv) always.

Probably I'm still having problem because of the database file, ... but I don't know that else to do! Where to put it!
Because I tried to do the SAME as I do Django but locally, which is, to just name the name of the database file in the NAME option of the DATABASE dictionary inside the settings file and it gets created when syncdb is run, it gets created inside the django project I create with startproject.
So inside of /myDjangoProject/ (parent) which contains manage.py and the folder myDjangoProject (child), where the settings.py is, then inside the parent folder /myDjangoProject/ (parent) the database file named inside the NAME of DATABASES dictionary it DOES gets created, and it works perfectly, but when LOCAL.

Here on this Shared Hosting Server it doesn't work just like that.
I'm just struggling with that.

I did everything the tutorial on https://help.asmallorange.com/index.php?/Knowledgebase/Article/View/140 tells me to do, and yes I do get the Welcome Page from Django, ... but besides that, when I try to create even an app, it gives me an error.  The Unhandled one even in Debug = True.

I can give more information so this issue can be better resolved.

Daniel Roseman

unread,
Mar 4, 2014, 2:11:27 PM3/4/14
to django...@googlegroups.com
On Tuesday, 4 March 2014 00:54:48 UTC, Omar Acevedo wrote:
Also there's a file called .bashrc which activates the virtualenv.
This is the line that does that:
    source /home/userName/.env/env/bin/activate
So it runs (the virtualenv) always.

But the web server is not running as you! So whatever is in your .bashrc is completely irrelevant. That's why, as everyone keeps telling you, you need to activate the virtualenv in your server, which is normally done in the wsgi file. 
--
DR.

Tom Evans

unread,
Mar 4, 2014, 2:26:31 PM3/4/14
to django...@googlegroups.com
On Tue, Mar 4, 2014 at 7:11 PM, Daniel Roseman <dan...@roseman.org.uk> wrote:
> That's why, as everyone keeps telling you, you need
> to activate the virtualenv in your server, which is normally done in the
> wsgi file.

Is it? I keep my wsgi.py exactly as startproject created it, I set
python-path when setting WSGIDaemonProcess in httpd.conf, eg (1.6
layout):

WSGIScriptAlias / /usr/local/mediabox/source/mediabox/wsgi.py
WSGIDaemonProcess mediabox.foo.com
python-path=/usr/local/mediabox/source:/usr/local/mediabox/env_mediabox/lib/python2.7/site-packages
WSGIProcessGroup mediabox.nubtek.com

Cheers

Tom
Reply all
Reply to author
Forward
0 new messages