Nugroho's blog.: Creating Django Apps on OS X Lion 10.7.2

Sunday, December 11, 2011

Creating Django Apps on OS X Lion 10.7.2

As this is my first time using Django, I have to take care of some initial setup. Namely, I’ll need to auto-generate some code that establishes a Django project – a collection of settings for an instance of Django, including database configuration, Django-specific options and application-specific settings.


From the command line, cd into a directory where you’d like to store your code, I use my python directory,then run the following command:
django-admin.py startproject mysite
This will create a mysite directory in my python. Here tho result.
Nugrohos-MacBook-Pro:python nugroho$ pwd
/Users/nugroho/python
Nugrohos-MacBook-Pro:python nugroho$ ls
appender.py distribute-0.6.24.tar.gz graphy graphy.pyc
apprunner.py f.py graphy.py
Nugrohos-MacBook-Pro:python nugroho$ django-admin.py startproject mysite
Nugrohos-MacBook-Pro:python nugroho$ ls
appender.py distribute-0.6.24.tar.gz graphy graphy.pyc
apprunner.py f.py graphy.py mysite
Nugrohos-MacBook-Pro:python nugroho$ cd mysite/
Nugrohos-MacBook-Pro:mysite nugroho$ ls
__init__.py manage.py settings.py urls.py
Nugrohos-MacBook-Pro:mysite nugroho$
These files in mysite directory are:
__init__.py: An empty file that tells Python that this directory should be considered a Python package. (Read more about packages in the official Python docs if you're a Python beginner.)
manage.py: A command-line utility that lets you interact with this Django project in various ways. You can read all the details about manage.py in django-admin.py and manage.py.
settings.py: Settings/configuration for this Django project. Django settings will tell you all about how settings work.
urls.py: The URL declarations for this Django project; a "table of contents" of your Django-powered site. You can read more about URLs in URL dispatcher.
To verify that it works do this
Nugrohos-MacBook-Pro:mysite nugroho$ python manage.py runserver
Validating models...


0 errors found
Django version 1.3.1, using settings 'mysite.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Yup, it works…
Try to access http://127.0.0.1:8000 with your browser, :)
Here screenshot from Safari on my Lion









From Blogsy Photos



If we want to show off on other computer, use command below. It will listen on all public IP's

Nugrohos-MacBook-Pro:mysite nugroho$ python manage.py runserver 0.0.0.0:8000
Validating models...


0 errors found
Django version 1.3.1, using settings 'mysite.settings'
Development server is running at http://0.0.0.0:8000/
Quit the server with CONTROL-C.


Here screenshot from my iPad

No comments:

323f (5) amp (1) android (12) apple (7) arduino (18) art (1) assembler (21) astina (4) ATTiny (23) blackberry (4) camera (3) canon (2) cerita (2) computer (106) crazyness (11) debian (1) delphi (39) diary (286) flash (8) fortran (6) freebsd (6) google apps script (8) guitar (2) HTML5 (10) IFTTT (7) Instagram (7) internet (12) iOS (5) iPad (6) iPhone (5) java (1) javascript (1) keynote (2) LaTeX (6) lazarus (1) linux (29) lion (15) mac (28) macbook air (8) macbook pro (3) macOS (1) Math (3) mathematica (1) maverick (6) mazda (4) microcontroler (35) mountain lion (2) music (37) netbook (1) nugnux (6) os x (36) php (1) Physicist (29) Picture (3) programming (189) Python (109) S2 (13) software (7) Soliloquy (125) Ubuntu (5) unix (4) Video (8) wayang (3) yosemite (3)