Jump to content

is There Anyone Who is Running a Django Powered Website at Heliohost?


Possibility of Using Django Framework to Build a Website at Heliohost  

16 members have voted

You do not have permission to vote in this poll, or see the poll results. Please sign in or register to vote in this poll.

Recommended Posts

Posted

Hello

I wanted to know if there is anyone who is running a Django powered website at heliohost?

I mean using Django framework with a database to build a website.

I'm going to make such a website but before that I need to be assured it's possible at heliohost

 

If you believe it's possible please let me know

 

I doubt it and I need to be persuaded

 

Thank you all

Posted

Why exactly do you need Django? There are tons of CMS out there and it sounds like you're having trouble with this specific one.

Posted
Why exactly do you need Django? There are tons of CMS out there and it sounds like you're having trouble with this specific one.

  1. I chose heliohost because of this feature.
  2. Django is not a CMS but is a Framework so you shouldn't compare it to CMSes, you can just compare it to other frameworks like ROR
  3. I don't know any kind of programming language other than C and C++ that I have forgotten very much since I haven't never used them in action.I just learnt them theoretically.
  4. I'm going to learn python soon and you know django is based on python
  5. I think it's the best framework at least for my needs

Thank you for asking

 

 

 

Posted

I was able to run my django project:

create

/home/simbairk/.python_egg_cache (chmod 775)

/home/simbairk/public_html/.htaccess (chmod 644)

AddHandler wsgi-script .wsgi
RewriteEngine On
RewriteBase /
RewriteRule ^(dispatch\.wsgi/.*)$ - [L]
RewriteRule ^(.*)$ dispatch.wsgi/$1 [QSA,PT,L]

 

I'm using django 1.1 and uploaded it to the public_html

 

/home/simbairk/public_html/dispatch.wsgi (chmod 755)

import os, sys
sys.path.append("/home/simbairk/public_html/")
sys.path.append("/home/simbairk/public_html/django")
os.environ['DJANGO_SETTINGS_MODULE'] = 'phonebook.settings' #my project name phonebook
os.environ['PYTHON_EGG_CACHE'] = '/home/simbairk/.python_egg_cache' #right 775
import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

 

to create a database and user, I used the following script

/home/simbairk/public_html/phonebook/scripts.py

#-*-coding:utf-8-*-
from django.template.loader import get_template
from django.template import Context
from django.http import HttpResponse
from django.contrib.auth.models import User
from django.core.management import call_command
import os

def init_db(request):
    call_command('syncdb', interactive=False)
    t = get_template('index.html')
    html = t.render(Context({'content':u'База инициализирована'}))
    return HttpResponse(html)

def create_su(request):
    call_command("createsuperuser", interactive=False, username="simba", email="haha@bugoga.yes")
    u = User.objects.get(username__exact='simba')
    u.set_password('simba')
    u.save()
    t = get_template('index.html')
    html = t.render(Context({'content':u'su создан'}))
    return HttpResponse(html)

do not forget to add in url.py anchor

 

in plane:

  1. make /admin
  2. make /admin/syncdb
  3. block up the access /initdb /create_su
Posted

Oh I'm very happy you did it simbairk.Actually I know very little django.Now I'm going to play with it more and I'll come back to ask you my questions.I need so much help

 

Thank you very much for your contribution

 

By the way set debug and template_debug in settings.py file to False when making your site available on the internet.It's a security advice

Posted
By the way set debug and template_debug in settings.py file to False when making your site available on the internet.It's a security advice

already done:)

Posted
so you have to upload django first?

perhaps this is too much

in sys.path must be the way to django, I did not know, and uploaded their

Posted
so you have to upload django first?

perhaps this is too much

in sys.path must be the way to django, I did not know, and uploaded their

Actually simbairk is not using the django that's installed on the server in python "lib/site-packages" folder which is normally used as where 3rd party packages are installed.He is using the django ,he himself has uploaded to his account by changing the python path to point to his uploaded django folder.

It seems this kind of using django can be accompllished on any hosting that's just offering python too.Look at this link:Setting up Django at Webreus.nl

 

It seems there are two ways of using databases without shell access:

1.using python scripts(which can be used for running other cammands of shell too);An example of such script is script.py file ,simbairk has used.

2.some kind of replicating your home database in your hosting account using for example phpmyadmin ,etc.

 

I'll explain these more in the near future.

 

By the way ,simbairk ,whould you please send us your urls.py file too?

Posted

The following are some posts I have found at Django Users mailing list, about deploying Django without shell access.They include hints on what i mentioned above:

 

Ivan Sagalaev

Shell access is highly recommended for initial app setup, otherwise you would have to write and upload small scripts each time you create or change database layout.

 

Walterbyrd

What I usually do is develop an app on my home linux box, then transfer that app to the remote host. Of course I have to create the same database, with the same name on the host.

 

Eric Abrahamsen

Django is a Python library like any other, so you'll need to be able to add new libraries to your webhost's python installation. Whether you do that as a svn checkout or upload a directory doesn't matter, but you will need access to the python installation (or be able to talk them into installing the library themselves). Django doesn't really need to be compiled/executed, if you can just get the source directory uploaded, into a place that's accessible to the python path, that will be enough.

 

Once you've got django installed, your own website is a similar deal: a set of files in a directory that needs to be on the python path. If you can install django you can install your own website. If you cant do one, you can't do the other.

 

Larrik Jaerico

I'll bet a lot of the mailing list will faint when they see this, but I've gotten it to work pretty easily by just dropping the django directory directly into my project directory.

 

Darryl Ross

>Is there any way to get django to not process files in a dir (i'm trying to install phpMyAdmin to look at the DB)?

 

In apache's config file I use the following inside my virtualhost block:

Alias /phpmyadmin/ /home/httpd/phpMyAdmin/ 
<Location /phpmyadmin/> 
    SetHandler none 
</Location>

Change path to suit.

 

Michael Josephson

In terms of having shell access, it would be handy in terms of being able to run django-admin.py commands but you can probably work around this. e.g. do a "django-admin.py sql" on your local development machine and create the schema using whatever method you normally use to access the database.

 

Carlos Yoder

Since I don't have shell access (they don't support ssh for 'security reasons'), I understand I won't be able to use manage.py, so "syncdb" will have to be via phpMyAdmin or similar, and so on.

 

Darryl Ross

 

Create a view that imports django and puts django.VERSION into the context. A simple (untested) way in the urls.py by using the generic views is:

import django 
from django.conf.urls.defaults import * 
urlpatterns = patterns('' 
    (r'^private/info/$', 
      'django.views.generic.simple.direct_to_template', 
      {'template': 'info.html', 
       'extra_context': {'version': django.VERSION'}}), 
)

And then you just need to create a simple info.html:

<html> 
<head> 
<title>Info!</title> 
</head> 
<body> 
The django version is {{version}}. 
</body> 
</html>

> I don't think you can do django with only ftp access

 

Sure you can, if django is installed into the server by the hosting company. I'm in the process of getting a django hosting company in Australia going and it's not that hard to run a django site without shell access.

 

Gabor Farkas

regarding the ftp+syncdb problem:

 

then probably the easiest way is to syncdb somewhere else, and then dump the database to a file, and restore it on the servage-database.

 

also to make python know about django, is nothing magical. as you see in the dreamhost-wiki django howto, they simple create a suitable django-fastcgi python script, and inside they add the django-dir to sys.path.

 

alex.gaynor@gmail.com

I don't think that is true, the only time I needed root was when I was symlinking django into /usr/lib/python2.5/site-packages/ but since you can put it anywhere on your python path, you just need to symlink it somewhere that's on your path and doesn't require root, since you need a location like this to run any python software this doesn't seem like an issue to me.

 

Andrew Ingram

It is possible to get django running without root access but you will need certain levels of permissions to do things like adding libraries to the python path, there are guides to installing Django on shared hosting environments like dreamhost where they don't give you root - though they do give you more access than the average shared host might. My personal feelings are that if you're trying to do things properly you're going to want complete control over your server config and access to services like memcached. Whilst you can get Django running on a range of hosting solutions I can't see myself doing anything more than a simple blog without looking into a VPS or dedicated server with root access.

 

Dan Ellis

The only thing you really /need/ root for is having some web server process (usually Apache or lighttpd, for example) bind to port 80. Everything else can be done without it. In fact, in any typical set up, once port 80 has been bound to you're not running as root any more anyway.

 

Daniel Roseman

> Hi.

> I have a problem with django project that is beeing hosting in a server where i have no shell access... so how can i do syncdb there.

> doing mysql dumps in development db and updating hosting mysql is kinda slow..

> Is it possible do this run syncdb script over web?

> Alan

 

You could have a view that does django.core.management.call_command('syncdb'). Make sure you've got proper authentication on it though.

 

viestards

Because many hosting providers does not allow shell access, I decided to create web version of syncdb. I made this simple function, and looks like it works

def db_sync(request): 
    from django.core import management 
    management.syncdb() 
return HttpResponse("Db sync in progress.")

 

Brian Jackson

you can run sqlall on your local copy and then just paste the resulting sql into whatever admin you have for the database server

 

Steven Armstrong

Haven't tried this, but in theory something like this should/could work.

def my_syncdb_view(request): 
   # check if user has permission to run this here 


   # prepare to capture output of syncdb() 
   import sys 
   orig_stdout = sys.stdout 
   orig_stderr = sys.stderr 
   from cStringIO import StringIO 
   sys.stdout = StringIO() 
   sys.stderr = StringIO() 


   from django.core.management import syncdb 
   syncdb() 


   # rewind stringio instances 
   sys.stdout.seek(0) 
   sys.stderr.seek(0) 


   output = [] 
   output.append("<h3>Output:</h3>") 
   output.append('<pre>') 
   output.append(sys.stdout.read()) 
   output.append('</pre>') 


   output.append("<h3>Errors:</h3>") 
   output.append('<pre>') 
   output.append(sys.stderr.read()) 
   output.append('</pre>') 


   # set stdout and stderr back just in case 
   sys.stdout = orig_stdout 
   sys.stderr = orig_stderr 


   return HttpResponse('\n'.join(output))

 

Kenneth Gonsalves

you can create everything, directory structure etc etc offline on your dev machine and upload it to your production machine (too much to expect svn on that?). You could also pipe the sqlall to a file and create a script to initialise/update your database which you can run using phppgadmin or whatever.

Ideally, if there is some way you could use svn on your production machine, you could do everything on your local machine and just svn up whenever you want changes. Even creating a superuser can be done by creating an sql script offline.

 

Deryck Hodge

My hosting provider doesn't offer shell access, and I run Django for my personal site. I did what's mentioned above -- built the site initially on my own box, uploaded files via ftp, loaded the initial mysql via phpmyadmin. For the stuff I really needed to run via shell,

I did something like:

import os 
import commands 
os.chdir('/dir/on/srv') 
out = commands.getoutput("some command") 
print 'Content-type: text/plain\r\n' 
print out

I ran this as cgi and could run commands as needed and see their output. Like Kenneth says, not ideal for serious development, but for a personal site it's not bad. And now that it's up, I do everything through the Django admin anyway.

It's hackish, but it works. Just an idea...

 

Jason F.McBrayer

If you can access the database provided by your hosting provider remotely, then you can use your local copy of your project to run syncdb: just modify your local settings.py to point to your database on your provider, and run syncdb there.

 

Vance Dubberly

You'll need to insert all the appropriate paths but it would look something like this:

os.system('/path/to/python /path/to/manage.py syncdb');

 

n00m

You need no at all to ask the hoster to install Django on his machine.

Apache (etc) + installed mod_python is quite enough to get your django app running.

The django package (and e.g. PIL) can be copied to there along with your django web dirs, as if it's a part of your web site/app.

 

Example:

 

htdocs/
my_dirs/
django/
...

my_django_app/

...

settings.py

urls.py

PIL/

...

...

LoadModule python_module modules/mod_python.so 
<Location /> 
    SetHandler mod_python 
    PythonPath "['htdocs/my_dirs'] + sys.path" 
    PythonHandler django.core.handlers.modpython 
    SetEnv DJANGO_SETTINGS_MODULE my_django_app.settings 
    PythonDebug On 
</Location>

 

Mr.Carra

I'm wondering if it's possible to deploy custom django application with django embedded? ie that user have to only run install script on they web server and it would "locally" install webaplication.

 

Michael Newman

You can put Django where ever as long as you add it to your python path then.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...