顯示具有 Django 標籤的文章。 顯示所有文章
顯示具有 Django 標籤的文章。 顯示所有文章

2009年1月4日 星期日

如何Reset Django user 密碼


[Windows Platform] : 
c:\: python manage.py shell

your acccount=admin
password=new_password
from django.contrib.auth.models import User
 
user = User.objects.get(username='admin')
user.set_password('new_password')
user.save()

2008年11月28日 星期五

Debugging django with PyScripter

Debugging django with PyScripter

Here is how you can debug Django applications with Pyscripter in six simple steps:
  1. In the File explorer locate the root directory of your Django application. You may want to right click on the directory name and select File Explorer, Explore here.
  2. Open the project files in Pyscripter (e.g., models,py, views.py etc.) and set whatever breakpoints you want.
  3. Select Run, Command Line Parameters... and set the command line to "runserver --noreload". Also check the "Use Command line" checkbox.
  4. Make sure the remote engine is selected (Run, Python Engine, Remote).
  5. Open the manage.py file and press the debug button (or press F9).
  6. Start a web browser and test your application. Pyscripter should now stop at whatever breakpoints you have set and you can use the various debugging facilities (call stack, variables, interpreter prompt etc.)

To stop debugging, right-click on the interpreter window and select "Reinitialize Interpreter", then go to the browser and reload the document.

Django 學習筆記(1)

如何安裝: 現在version Django-1.0.2-Final
1.Django Homepage and Download
Homepage => http://www.djangoproject.com/
Download =>http://www.djangoproject.com/download/

2.解壓縮方法: window 就用 7-zip 解,然後放到你的 Python中
把Django\"Django" 放到 如:C:\Python25\Lib\site-packages\django

3.把 django-admin.py copy 到 "C:\Python25\Scripts"
django-admin.py 應該在"C:\Python25\Lib\site-packages\django\bin"

4.把 c:\python25\scripts 加到環境變數中
[window版] 控制台-->系統-->進階 -->環境變數 -->path

5.如何產生網站:django-admin.py startproject mysite
看一下目錄 c:\mysite

6.mysite 內容:
mysite/
__init__.py

manage.py

settings.py
urls.py

7.開起web server -> 到 c:\mysite 打 python mange.py runserver ,
然後 http://127.0.0.1:8000/
要換port 就用 ==> python mange.py runserver
8080

8.Edit
c:\mysite\settings.py
  • DATABASE_ENGINE = 'sqlite3'
  • DATABASE_NAME = r'c:\mysite\django.db'
7. 先把admin 裝起來 Edit c:\mysite\settings.py ,找一下INSTALLED_APPS
加入 'django.contrib.admin',
'mysite.blog',
改成中文/台灣地區
TIME_ZONE = 'Asia/Taipei'
LANGUAGE_CODE = 'zh-tw'

8. python manage.py syncdb 產生DB table