akdev2
akdev2

Reputation: 45

How to install Django based Project?

i have Django based Blog Application.

File structure image :

https://www.dropbox.com/s/8vnqwheucjeyy43/Selection_012.png

Here no manage.py file.

How can i run it locally ?

Thanks.

Upvotes: 2

Views: 92

Answers (1)

suhailvs
suhailvs

Reputation: 21680

first create a django project: django-admin.py startproject <projectname>

then the directory with <projectname> will be created with these files:

--projectname
  --settings.py
  --urls.py
  --wsgi.py

--manage.py

now copy the folder blog to <projectname> directory.

edit settings.py:

add database details.

import os
path=os.path.dirname(__file__)
............... other settings.py variables

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': path+'/tt.db',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

add blog to settings.py INSTALLED_APPS.

INSTALLED_APPS = (
    ....other apps
    'blog',
)

edit STATICFILES_DIRS

STATICFILES_DIRS = (
    os.path.join(path, '..','blog','static') 
)

edit urls.py

add required blog urls to urls.py

urlpatterns = patterns('',
    ...other urlpatterns
    url(r'^blog/', include('blog.urls')),
)

run the site

python manage.py collectstatic
python manage.py syncdb
python manage.py runserver

you can now visit : 127.0.0.1:8000

Upvotes: 4

Related Questions