django standard install..

Posted by nopsled
2015.10.13 10:57 프로그래밍

I have to development about web project..

html and php is old.. so, i decided to use django!! django is so useful and quick and idk about web programming. but this is so good idea about using python


django division project and application. project's big notion, application's into project's small notion.

so we building about standard setting in django.

* [important] ah, django must installed!! *



1. we bulding about django project (big notion)

nopsled@localhost:/var/www (=`ω´=)$ django-admin.py startproject project

nopsled@localhost:/var/www (=`ω´=)$ ls

?/                  project/         _________.php*      index.php           p2p_crawler.tar.gz  phpmyadmin/         test@.php

nopsled@localhost:/var/www (=`ω´=)$

# we created project!!



2. confirm running django server.

nopsled@localhost:/var/www/project (=`ω´=)$ python manage.py runserver 8000

Performing system checks...


System check identified no issues (0 silenced).


You have unapplied migrations; your app may not work properly until they are applied.

Run 'python manage.py migrate' to apply them.


October 13, 2015 - 00:25:50

Django version 1.8.5, using settings 'project.settings'

Starting development server at http://127.0.0.1:8000/

Quit the server with CONTROL-C.


[13/Oct/2015 00:26:08] "GET / HTTP/1.1" 200 1767




3. if you want using database with mysql, modify database in settings.py

DATABASES = {

    'default': {

        'ENGINE': 'django.db.backends.mysql',

        'NAME': 'test', # if you custom database in mysql, modify path.

        'USER': 'root', # set your mysql user

        'PASSWORD': '???????', # set your mysql password

        'HOST':'127.0.0.1', # if you want remote connect, modify it!

        'PORT':'3306', # if you modified mysql default port, modify it too.

    }

}



4. we use django migrate for database.

nopsled@localhost:/var/www/project (=`ω´=)$ python manage.py migrate

>> ERROR : django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

# but error with MySQLdb is not defined.. we have to use wget and install it.

# or another cause error, using python manage.py syndb

nopsled@localhost:/var/www/SeoulMetro/db (=`ω´=)$ wget https://github.com/farcepest/MySQLdb1/archive/master.zip

# unzip it and use "python setup.py build;sudo python setup.py install" in command line

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/

# if you error in mac osx, using export path.





5. and create with django application (small notion)

nopsled@localhost:/var/www/project (=`ω´=)$ python manage.py startapp application

nopsled@localhost:/var/www/SeoulMetro (=`ω´=)$ ls

project/   db/           db.sqlite3    manage.py*    application/








THE END.... T.T

저작자 표시 비영리
신고