Posts

Showing posts with the label django

The Story from Proteus's Productivity seeker

Proper install guide I try to install psycopg2 (2.4.1 bcoz 2.4.2 does not work with django 1.3) on Ubuntu Natty today and got ImportError: can't import mx.DateTime module . Hmm... weird. I googled around and found a sequence of command to do a proper installation of psycopg2. $ sudo apt-get build-dep python-psycopg2 $ virtualenv ENV $ source ENV/bin/activate $ easy_install psycopg2 $ easy_install egenix-mx-base ref: http://www.saltycrane.com/blog/2009/07/using-psycopg2-virtualenv-ubuntu-jaunty/ Damn mx and psycopg2==2.4.1 The sequence of commands above did not fix my ImportError: can't import mx.DateTime module . I wasted a day searching until i found its defect on psycopg2 issue tracker . In sum, if you try $ ls /usr/include/python2.6/ | grep mx and you found that you have mx folder there, you're screwed. Psycopg2 will try to use this damn mx instead of default datetime package and that will prevent you from installing psycop...

Django : create migration script

Django : create migration script >>> python manage.py schemamigration --initial # for first create migration >>> python manage.py schemamigration --auto # for second and more *** folder migration will be created in Thank, Pam 

Setup Python/DJango Environment with Virtualenv

for Linux environment.( general purpose ) - sudo apt-get install python-setuptools - sudo easy_install pip - pip install virtualenv (additional pip install virtualenvwrapper) - virtualenv --no-site-packages - source /bin/activate - pip install yolk - pip install ipython ( additional for other module please do - sudo apt-get install python-dev build-essential )

Django Authentication Information

function is_authenticated() -> doesn't imply any permission, group or user active. It's just indicate user has provide valid name and user. --- function authenticate() -> authenticate a given username and password (or something) and return user object if password is valid for the given username, return None if not. --- function login() -> to log user to view. It takes an HttpRequest object and user object and save user's id in the session, using django's session framework and session middleware. --- more issues you can use custom authentication module with modified authenticate function, which can authenticate with other credential (not just username, password)

List for news group chat

freenode#django-lfs -> for information from django-lfs freenode#django-cms

Issue about django latest()

If u need to use latest() function when get something from db. First use need to aware of latest( field_name ) of model._meta = 'field_name' in your model to make it clear what your latest out from your db.

Django combine 2 Queryset

Do you know that we can combine 2 Querysets by >> q1 = q1 | q2 # get another queryset so you can use .order_by() or something behind note: don't know about side effect.

Think I have to do....

- learn about django signal - multiprocessing module - mocking and patching with import mock

Pagination in Django is COOL :)

http://docs.djangoproject.com/en/dev/topics/pagination/ before to to other module , try is before

Django model

1.when u create 'sample_field' field in model with field attribute 'related_name'. 2.u can backward retrieve data with 'sample_fields' will check later

Tips for django, python

python function argument for example : def func(input1, *input2, **input3) *input2 > tuple **input3 > dict for concrete example: def bucha(name, *things_have,**dudu): print name print things_have print dudu yh get result by call bucha('sirs','duma','dugu',damn='kin') sirs ('duma','dugu') {'damn':'kim'} django models Q > LIKE keyword F > for compare model field with another field in that model -> one to one -> models.OneToOneField() -> many to many -> models.ManyToManyField()

Idea for php, python in one server

P'Pai guide In 1 server we should use... 1.mod_fastcgi for php 2.mod_wsgi for python/django (apache server)

Installation tip for django nose

easy_install nose easy_install nosedjango (very thank PPam)

Django modify request.POST

I found an error about trying to change request.POST['xxxx']. After googling i get an answer... # copy queryset to q for mutatable purpose q = request.POST.copy() q.update({'xxxx': you value}) # then use q instead request.POST :) i'm not sure but it should give a correct result 99% (thk wrong (demigod))

Django's Contenttype

from django.contrib.contenttypes.models import ContentType from mission.objects import Mission -> cmission = ContentType.objects.get(model='mission',app_label='mission') and -> cmission = ContentType.objects.get_for_model(Mission) You will get same object.

tip's daily

about firebug: if use console.log BUT when u start test without ACTIVATE firebug , Will cause a very damn bug in javascript thank wrong(proteusian) for help

stuff for web dev#2

http://www.saltycrane.com/blog/2009/05/notes-using-pip-and-virtualenv-django/ http://mojodna.net/2009/05/20/an-idiots-guide-to-oauth-10a.html http://hueniverse.com/oauth/ http://oauth.net/documentation/getting-started/ http://bitbucket.org/jespern/django-piston/wiki/Documentation http://www.thedigitalself.com/exposing-rest-services-with-python-and-django http://beautifulisbetterthanugly.com/posts/2009/jul/23/restful-web-service-using-django-piston/ http://blog.carduner.net/2010/01/26/django-piston-and-oauth/ http://hedgehoglab.com/blog/2008/03/03/django-debug-techniques-and-ipython/ THANK FOR ALL MANKINDS

Somethings should Notice

The canonical way to begin a python script is ! /usr/bin/env python This will work on any posix system, while /usr/bin/python won’t. (thank TRauMa) On September 26, 2007, James Bennett said : Fredrik, I’m not sure what you mean; there are examples in the code snippets of setting DJANGO_SETTINGS_MODULE , but it’s not “relative to” anything — it’s a dotted Python path to a Django settings module, and I’m hoping that folks who are reading this have at least gotten far enough along to understand that (and to understand what a Django settings module is) :) (thank James Bennett)

Great Stuff of Django

->install django on ubuntu server http://jeffbaier.com/articles/installing-django-on-an-ubuntu-linux-server/ ->many way to setup django environment http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/ thanks all ref