Talk:Django

From DreamHost

Jump to: navigation, search

Contents

PS problem

I'm running a PS server with dreamhost and am getting a mkpath error while doing the easy_install.

error: Setup script exited with error: mkpath: 'name' must be a string 

has anyone else had an issue with this? I think this is directly relating to the PS side of things, but obviously dreamhost isn't helping me on this. These instructions seem relatively useless in helping me figure out how to fix this nor set up on a dreamhost PS. --Wonderfullyrich 09:24, 21 October 2009 (UTC)

Custom Python Problem

I needed to use Python 2.6 for my Django 1.0 site. I had no problems installing either Python or Django and having access to all the great utilities via the command line in my shell. But when I browse to my site through the web it appears my site is using Python 2.4, the default Python implementation on Dreamhost. How do I get my Django site to use the custom version I installed and not the default? --Natantus 08:38, 15 December 2009 (PST)

if sys.version < "2.6": os.execl("/path/to/your/copy/of/python2.6", "python2.6", *sys.argv)
Note that you'll need your own copies of Django and MySQLdb installed, as these modules are only installed for Python 2.3 and 2.4 on our system. (Nothing personal against newer versions, the release of Debian we're using just doesn't have support for anything newer.) Andrew F 17:56, 15 December 2009 (UTC)
Would I place this in the settings.py file for my django project? Thanks for the quick reply! --Natantus 13:50, 16 December 2009 (PST)
Nope, settings.py gets loaded too late. Stick it at the top of passenger_wsgi.py (after importing sys and os, of course) -- that's the first thing Passenger loads. Andrew F 22:38, 16 December 2009 (UTC)
That's exactly what I needed. Thanks! Should this info be included in the Python or Django article? I'm sure it would come in handy for others. --Natantus 14:46, 16 December 2009 (PST)
It's already alluded to in Passenger WSGI, but it's probably worth mentioning in Django as well. Go ahead! Andrew F 23:33, 16 December 2009 (UTC)

Test Module

Using the built in Django test utility seems like a great way to check out my installation. However, it requires that I be able to create and delete MySQL databases via command line utilities. Is this just not possible because of the shared database hosting on Dreamhost? I'm basically running this command:

python manage.py test

I only got it to work once. I created a database through the panel called test_django_mysite_com. When it gave me an error that said the database existed I allowed it to delete the database. After the test was done the database disappeared and now it won't come back for 5 days. Any help on this issue would be great. --Natantus 12:55, 20 December 2009 (PST)

Ideally, we'd prefer that you run unit tests on your own computer, rather than on our servers. If you absolutely need to run tests here, though, your best bet is to use the SQLite database backend for tests rather than MySQL. Andrew F 17:52, 21 December 2009 (UTC)

.htaccess

Is it possible to use a .htaccess file together with django? Main reason is hotlinking protection with mod_rewrite rules.

It seems possible with Passenger, but placing the usual .htaccess file in my passenger public directory doesn't work. So either some admin configuration is required or i'm doin it wrong (or it's impossible) Any pointers? --Lajcik 23:18, 3 February 2010 (UTC)

I figured it out seconds after posting on the wiki - it works if you place the .htaccess file in the root of your domains web directory where (where your passenger-wsgi.py file goes) --Lajcik 23:23, 3 February 2010 (UTC)

Script Sometimes Does Not Work

I tried to follow this methodology to install Django, but got an error:

Uh-oh, it looks like your server doesn't have django installed.
Ask DreamHost Support to install it for you!
[ Executable: /usr/bin/python ]

However, because Django isn't officially supported, you're not actually supposed to ask dreamhost support to install it for you; I asked and they very politely (and quite rightly) refused and pointed me here.

Anyone have any information doing the actual Django install itself? --Aphoenix 18:42, 3 March 2010 (UTC)

Support is incorrect in this case; Django is supposed to be installed system-wide, and they should be either installing it on request or asking an admin to do so. Tell them I sent you. Andrew F 19:06, 3 March 2010 (UTC)

Awesome - Thanks Andrew F! i will commence with the name dropping. Though now that I've gotten back to it, I see that I'm no longer getting that error; my 3am deduction abilities tell me that you likely fixed it for me. Thanks! Aphoenix 07:53, 6 March 2010 (UTC)

Pinax Installation with Virtualenv

I'm trying to install a Django based social website called Pinax (http://www.pinaxproject.com). Pinax is essentially a large number of reusable Django apps all rolled together. To make it all work they give you a package that installs a virtualenv with exactly the dependencies needed to get it going, which makes this type of product very powerful. My problem is that I'm unsure how to point at my new virtualenv from my passenger_wsgi.py file. The documentation I got from the pinax site resides here: http://pinaxproject.com/docs/dev/deployment.html?highlight=mod_wsgi

Where do I put the wsgi script and how do I access it? I'd love to write up an article on your wiki about Pinax once I get this thing going. --Natantus 09:05, 17 March 2010 (PST)

EDIT: Figured this one out. Took a fair amount of research to find a simple solution already on your wiki. I'll still write up the Pinax article once I'm finished doing a bit of testing. Turns out I didn't need to use the wsgi script, which is ok because i'd probably need to sign up for a Private Server to go that route. --Natantus 18:05, 19 March 2010 (PST)

Django-setup.py on Wiki

I don't think the wiki is the best place for this file, as the wget command brought me the source code of an html page (the wiki page), and things worked better by copying the contents of that page into a cat writing to the setup.py I noticed this after I had "corrected" the capitalization because MediaWiki upper-cases the first letter, and still got an error. Qayshp

Was a configuration issue with the wiki -- we used to have a custom rewrite rule for that URL, which was inadvertently lost. Fixed now. Andrew F 16:39, 14 June 2010 (UTC)

PhpMyAdmin not working

I successfully installed Django using these instructions, but now I cannot use phpMyAdmin to view the databases under that domain. Django is installed into <domain> and I used mysql.<domain> to host the databases. It looks like the phpMyAdmin link in Dreamhost's Control Panel gets forwarded from http://mysql.<domain>/ to http://<domain>/dh_phpmyadmin/mysql.<domain>/ . This gets gobbled up by Django and returns a 404.

What's the best way to correct this? --Brousch 19:51, 28 July 2010 (UTC)


Create a subdomain of your domain, and hit phpMyAdmin at http://subdomain.example.com/dh_phpmyadmin/mysql.example.com/ -- Andrew F 18:13, 23 July 2010 (UTC)

Thank you, this works fine. I ended up going with mysql.db.<domain> --Brousch 19:51, 28 July 2010 (UTC)

Setup Script fails on Django 1.2.1

The server I'm on (forge) just updated to Django 1.2.1, and now the install script fails after entering the database info:

Checking connection...  looks good!
Creating project framework...  creating passenger_wsgi.py...  customizing settings...  setting permissions...  copying admin media...  OK
Running manage.py syncdb...
Traceback (most recent call last):
  File "./HalfOfMyLife/manage.py", line 11, in <module>
    execute_manager(settings)
  File "/var/lib/python-support/python2.5/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/var/lib/python-support/python2.5/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/var/lib/python-support/python2.5/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/var/lib/python-support/python2.5/django/core/management/base.py", line 218, in execute
    output = self.handle(*args, **options)
  File "/var/lib/python-support/python2.5/django/core/management/base.py", line 347, in handle
    return self.handle_noargs(**options)
  File "/var/lib/python-support/python2.5/django/core/management/commands/syncdb.py", line 52, in handle_noargs
    cursor = connection.cursor()
  File "/var/lib/python-support/python2.5/django/db/backends/dummy/base.py", line 15, in complain
    raise ImproperlyConfigured("You haven't set the database ENGINE setting yet.")
django.core.exceptions.ImproperlyConfigured: You haven't set the database ENGINE setting yet.
oops, manage.py failed!

django-setup.py Script had me create 2 super users

Not sure if it is an error or not, but...

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (Leave blank to use 'qayshp'): 
E-mail address: qayshp@###.###
Password: 
Password (again): 
Superuser created successfully.
Installing index for admin.LogEntry model
Installing index for auth.Permission model
Installing index for auth.Group_permissions model
Installing index for auth.User_user_permissions model
Installing index for auth.User_groups model
Installing index for auth.Message model
No fixtures found.
Creating a Django superuser...
Username: qayshp
Error: That username is already taken.
Username: 
Error: That username is invalid. Use only letters, digits and underscores.
Username: admin
E-mail address: admin@###.###.###
Password: 
Password (again): 
Superuser created successfully.


SUCCESS! Your Django application is fully set up - enjoy!

I dropped all tables and removed all files created just to retry it, this time entering a username instead of letting it default to mine... same thing.

I cleaned up and ran the script again, this time entering 'no' when prompted if I wanted to create a superuser... it still prompted me to create a user, but only one this time. Just thought it was noteworthy

DJango Tutorial Tips

Are you going through the DJango tutorials? Here's some helpful advice.

  1. Upon finishing the dreamhost setup wizard- go to http://yoursite.com/ you should get a django 404 message.
  2. Don't run manageserver.py runserver (this is against DH policy and you'll get an alert telling you the same- but the alert will arrive in 8 hours or so).
  3. if you go to http://yoursite.com/admin/ you should get the admin server but I don't (i'm troubleshooting and if I can solve it or if anyone else can - please feel free to update this section)


So the problem is that there is no default page setup, so when you go to your domain, Django has no rule to say "Show this page" it only has rules for 'admin' and 'admin/docs'. "but these don't work either". That is true and we can fix that, BUT only by creating a default page, you can't get both "welcome screen" and "Admin" working at once (or atleast i can't).

To get the proper 'welcome" screen after installing

  1. To stop getting a 404 after following the tutorial, edit the 'urls.py' and comment out '(r'^admin/doc/', include('django.contrib.admindocs.urls')),' and '(r'^admin/', include(admin.site.urls)),'.

To get the Admin docs area working

  1. If you followed the step above to get the welcome screen going and you want to get the admin working:
    • To get 'http://yoursite.com/admin/' working, uncomment ' 'django.contrib.admin',' from the bottom of the settings.py.
    • From 'urls.py', make sure '(r'^admin/', include(admin.site.urls)),' isn't commented out (Even though I told you to comment it out before, that was to get the 404 working).
    • For the docs:
      • un comment '(r'^admin/doc/', include('django.contrib.admindocs.urls'))' from urls.py.
      • Add "'django.contrib.admindocs'," to the 'INSTALLED_APPS' array.
  2. You will now notice the 'welcome screen' doesn't work. That is because you have you pages built yet.


If you can't use manageserver.py runserver

If you can't use manageserver.py runserver then how do you get the "Welcome to Django" page described in the tutuorial [1]? I tried to just forge ahead, but I'm getting an "ImportError" on the hello world example, which I suspect is related.

Augustfirst 15:35, 22 December 2010 (PST)

Script Error Breaks Installation

I received the following error (domain details changed to protect the innocent):

 ... (lots of preliminary stuff removed) ...
 What would you like to name your project?
 >> xyz
 An excellent name!
 
 
 You'll need a database for your Django project. If you don't already
 have one ready, you can create one from the DreamHost Panel at:
 
   https://panel.dreamhost.com/index.cgi?tree=goodies.mysql
 
 MySQL hostname: mysql.xyz.com
  Database name: djangodb
 MySQL username: django
   and password: 12345
 Checking connection...  looks good!
 Creating project framework...  oops, django-admin failed to run!

This is a result of a file path in the script pointing to the wrong place. To correct this:

  1. On the command line, type: emacs django-setup.py (or use any other editor that shows line numbers)
  2. Scroll down to line 126
  3. Change "/usr/bin/django-admin" to "/usr/bin/django-admin.py"
  4. Save and exit: <ctrl>-x, <ctrl>-s, <ctrl>-x, <ctrl>-c

Run the script again. It should work now.

Does anyone know who to contact to get the actual script updated?

Personal tools