![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Django
liukeforever
一个十年的程序员
展开
-
Django中使用tiny_mce
<br />1、在django项目的settings.py中添加 STATIC_PATH = './static', 并在urls.py的urlpatterns加入<br />(r'^static/(?P<path>.*),'django.views.static.serve',{'document_root':settings.STATIC_PATH}), #注意别掉了这里的逗号<br />2、在前台模板页面<head></head>之间加入<script type="text/javascript"原创 2011-03-16 08:48:00 · 2220 阅读 · 0 评论 -
Django Model Object Serialize By SpitEat
django model object 最简单的方法s = NagiosHoststatus.objects.all()[0]print s.__dict__但是这个方法有一个缺点, 外键所关联的对象并不会被Serialize, class Model1(models.Model): name=models.CharField() ch原创 2012-11-12 14:55:31 · 1039 阅读 · 0 评论 -
查看Django ORM执行的SQL语句
In [1]: from django.contrib.auth.models import UserIn [2]: User.objects.all()[0]Out[2]: In [3]: from django.db import connectionIn [4]: connection.queriesOut[4]:[{'sql': u'SELECT `au转载 2012-02-08 09:55:30 · 6123 阅读 · 0 评论 -
resize script for galleria
$(window).resize(function() { var h = $(window).height(); var galleriaHeight = h-54; var w = $(".content").width(); var原创 2011-08-15 16:47:47 · 739 阅读 · 0 评论 -
Django Ajax POST请求失败解决办法
Django到了1.2.5版本以上,Ajax POST请求的使用发生了一些改变,我们还记得前些版本1.2,Django加入了CSRF机制,大大增强了网络请求的安全性,正是因为这点,现在的Django对页面任何POST请求的数据进行跨域攻击保护。当你升级到1.2.5或更高版本后,你原创 2011-08-19 14:14:26 · 3438 阅读 · 0 评论 -
django 使用urllib2碰到的csrf問題的解決
import urllibimport urllib2import contextlibdef login(login_url, username, password): """ Login to site """ cookies = u原创 2011-08-19 13:15:10 · 1873 阅读 · 0 评论 -
django comments
view代碼: user = request.user initial={} if user.is_authenticated(): initial={'name': user.username, 'email': user.e原创 2011-08-18 13:18:18 · 964 阅读 · 0 评论 -
How to use Django with Apache and mod_python
os: ubuntu 10.04django: version 2.5apache: 2python: 2.61. install python, django, apache, mod_pythonapt-get install 2.edit h原创 2011-08-10 13:33:52 · 510 阅读 · 0 评论 -
How to use Django with Apache and mod_wsgi
edit httpd.confWSGIScriptAlias / /home/liuke/www/django/hello/apache/django.wsgiadd filedjango.wsgiimport osimport syspath原创 2011-08-10 21:53:20 · 778 阅读 · 0 评论 -
djangouser.is_authenticated
<br />from django.template import RequestContext<br /> <br />def entry_detail(request, year, month, day, slug):<br /> import datetime, time<br /> date_stamp = time.strptime(year+month+day, "%Y%b%d")<br /> pub_date = datetime.date(*date_stamp原创 2011-04-27 16:06:00 · 3298 阅读 · 0 评论 -
django oracle數據庫設置
<br />DATABASES = {<br /> 'default': {<br /> #'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.<br /> 'ENGINE': 'django.db.backends.oracle', # Add 'postgresql_psycopg2'原创 2011-04-19 15:03:00 · 1325 阅读 · 0 评论 -
django projects
<br />http://code.google.com/p/django-jqchat/原创 2011-05-27 16:49:00 · 489 阅读 · 0 评论 -
django session
<br />django session 是按用戶的瀏覽器來保存的,不同的瀏覽器對應的session不一樣,<br />一個瀏覽器一個用戶一筆資料,如果有多個session值也是保存在一筆資料<br />session.get_decoded()出來的結果是<br />{'favo_color':'red', 'favo_color2':'white', '_sessin_expiry':600}<br />session的expire默認是2個星期,2個星期後過期<br />重新調用request.ses原创 2011-05-26 10:12:00 · 987 阅读 · 0 评论 -
django change a widget attribute的兩種方法
<br />change a widget attribute的兩種方法,一種是在__init__方法裡,<br />一種是在class Meta裡<br /> <br /> <br />class PaymentForm(ModelForm):<br /> #def __init__(self, *args, **kwargs):<br /> # super(PaymentForm, self).__init__(*args, **kwargs)<br /> #<br原创 2011-05-17 09:58:00 · 568 阅读 · 0 评论 -
django中使用tagging
no such table: tagging_tag 處理 Once you've installed Django Tagging and want to use it in your Django applications, do the following: 1. Put 'tagging' in your INSTALLED_APPS setting. 2. Run the command manage.py syncdb .from tagging.models import Tagf原创 2011-03-17 16:13:00 · 1867 阅读 · 0 评论 -
django south做数据库迁移
1. setting.py INSTALLED_APPS add south2. python manage.py schemamigration mysite --initial3. python manage.py convert_to_south mysite4. change model.py5. python manage.py schemamigration mysit原创 2013-05-15 22:49:12 · 950 阅读 · 0 评论