Home General Computer Multimedia Business Lounge
|
how to create login auth with django framework (python)
|
|
11-17-2010, 08:38 AM
|
|||
|
|||
|
how to create login auth with django framework (python)
tulisan ini sebelumnya saya tulis di forum rekan saya di cp27, so contoh2 apps dan projectnya masih nama cp27
ingin membuat website dengan python? kita bermain sedikit dengan framework django download django 1.2.1 here: http://www.djangoproject.com/download/1.2.1/tarball/ extract & install: Code: tar xzvf Django-1.2.1.tar.gzutk check apakah lib django sudah terinstall silahkan masuk ke shell python: Code: Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) buat project utk web pertama kita di django: Code: $ django-admin.py startproject cp27Code: `-- cp27untuk menjalankan server masuk ke direktori cp27 kemudian: Code: $ python manage.py runserverCode: Validating models...check di browser dgn URL http://127.0.0.1:8000: ![]() pada project voidnetwork kita akan buat aplikasi bernama 'cp27' Code: $ python manage.py startapp cp27nb: cp27 akan dikenali sebagai package pada direktori kerja voidnetwork sekarang kita develop login page: buat url login dan url utama yg diinginkan pada file cp27/urls.py Code: from django.conf.urls.defaults import *setting database dan INSTALLED_APPS pada cp27/settings.py contoh disini kita menggunakan postgresql. lengkapi isi dari file settings.py terutama DATABASES, TEMPLATE_DIRS, dan INSTALLED_APPS settings.py Code: ...masuk ke db engine menggunakan psql: Code: $ psql -h 127.0.0.1 -U postgres -WCode: postgres=# CREATE DATABASE voidnetwork;synchronize database: Code: $ python manage.py sql cp27Code: Creating table auth_permissionsetelah berhasil mari kita lihat halaman admin django dengan URL: http://127.0.0.1:8000/admin jgn lupa utk menjalankan server (wsgi django). kurang lebih tampilan admin pagenya adalah sbb: ![]() yak kita skip dlu mainan admin nya, sekarang kita bangun halaman utama dan halaman login yg kita inginkan. Kita akan membuat login page berdasarkan authentification user yg ada di django sendiri (kita tidak membuat tabel sendiri untuk user). nb: ada beberapa cara untuk membuat login page, yg saya contohkan adalah cara paling jadul, next tutor akan saya berikan cara mudahnya menggunakan decorator login required sebelumnya kita sudah isi absolute path utk template, di laptop gw mungkin di '/home/synl0rd/voidnetwork/cp27/template' (sesuaikan dengan kondisi direktori masing2). pada direktori template buatlah 2 buah page html. untuk contoh ini gw asumsikan sbb: nb: template gw buat seadanya, hias sendiri selebihnya kalo mau keren cp27/template/index.html Code: <html>cp27/template/login.html Code: <html>selanjutnya kita isi cp27/views.py dengan script sbb: Code: from django.http import HttpResponse, HttpResponseRedirect- cpmain() = sebagai handle halaman utama perhatikan urls.py Code: url(r'^$', 'cpmain', name='cpmain'),- cplogin() = function yang dijalankan ketika URL mengarah ke http://127.0.0.1:8000/login - cplogout() = function yang dijalankan ketika URL mengarah ke http://127.0.0.1:8000/logout untuk screenshot mungkin tidak perlu, karena hanya halaman login biasa dan welcome page utk index (bisa lihat di template/) nb: tutorial kali ini belum masuk ke models hanya sebatas authentification semata kalau ada yg bingung di diskusikan saja, banyak yg mesti dijelaskan seperti templating atau tanda @csrf_exempt, dll semoga bermanfaat, mohon maaf apabila ada kekurangan. thnks & regards 5ynL0rd cth site sederhana menggunakan django framework: http://void-labs.org (my site with django + mongodb [document oriented database]) http://www.lawrence.com/ http://projects.washingtonpost.com/ http://www.tabblo.com/ dan masih banyak lagi |
|||
|
11-17-2010, 04:01 PM
(This post was last modified: 11-17-2010 04:01 PM by supermenganteng.)
|
|||
|
|||
|
RE: how to create login auth with django framework (python)
wow..nice bro..ijin mempelajari , biar gak ketinggalan ilmu ane
|
|||
|
08-20-2011, 08:44 PM
|
|||
|
|||
|
RE: how to create login auth with django framework (python)
bro, boleh add ym ga nih? mau tanya2 seputar python n django nih
|
|||
|
10-20-2012, 12:36 AM
|
|||
|
|||
|
RE: buy nexium online 15853
waawww...
tread a bagus tapi sangat susah di pelajari nice tread a kk, ![]()
|
|||
|
12-07-2012, 11:57 AM
|
|||
|
|||
|
RE: how to create login auth with django framework (python)
nice thread kk
![]() ane pelajari dulu kk
|
|||
|
04-25-2013, 06:17 AM
|
|||
|
|||
|
RE: how to create login auth with django framework (python)
wow good jom synlord
|
|||
|
04-25-2013, 08:06 AM
|
|||
|
|||
|
nordstrom coupon code Nkkfgqx
Cover it all with water, bring to a boil and then simmer, covered for three hours or so. We talked a little about water safety. Nike Free Run I weigh 210lbs plus 80 pounds of gear.. It all depends on your skin tone, hair, and other physical features.
nike free run 2 The first is that dogs don't have feelings. The look of both the Beetle and the PT Cruiser provoked an emotional response in buyers who had a fondness for the cars' predecessors. The captivating looks were created by folding single pieces of jewel-toned silk twill and wool Melton. Normally i don act as flamboyant as my disposition gives off but i don act "manly" at the same time. http://www.brandsunglassesaustralia.com You need to have socks and probably run out of them frequently or run through them often if you are like most people. This could result in slipped discs and torn tendons. http://www.frairmaxpascher.fr Residents of Michigan may purchase any pellet gun except for pellet guns or BB guns measuring 30 inches or less (overall length). |
|||
|
« Next Oldest | Next Newest »
|
| Topic Tools | ||||||
| ||||||
| Users Browsing |
| 1 Guest(s) |



![[Image: x.png]](http://voidnetwork.org/images_ss/x.png)
![[Image: y.png]](http://voidnetwork.org/images_ss/y.png)












