django

Django / Python, how to check if user is logged in (how to properly use: user.is_authenticated )?

I am looking over: http://docs.djangoproject.com/en/1.2/topics/auth/#django.contrib.auth.models.User but just can't seem to figure out how to do this as its not working. I need to check if the current site user is logged in (authenticated), and am trying: request.user.is_authenticated despite being sure that the user is logged in, it ...

Simple RESTFUL client/server example in Python?

Is there an online resource that shows how to write a simple (but robust) RESTFUL server/client (preferably with authentication), written in Python? The objective is to be able to write my own lightweight RESTFUL services without being encumbered by an entire web framework. Having said that, if there is a way to do this (i.e. write RESF...

Django on Jython with Oracle: Too many open cursors

Hi. I am running Django on Jython with Oracle and I often get the famous "Too many open cursors" error. It never happens with the same code with Python and the cx_Oracle driver. Is there something wrong with the zxJDBC driver or perhaps there is a way to ask Django to close the cursors when I am done with the querysets? Thank...

Django, Turbo Gears, Web2Py, which is better for what?

I got a project in mind that makes it worth to finally take the plunge into programming. After reading a lot of stuff, here and elsewhere, I'm set on making Python the one I learn for now, over C# or java. What convinced me the most was actually Paul Graham's excursions on programming languages and Lisp, though Arc is in the experiment...

Using django-paging extension with Django and Jinja2/Coffin

Recently I switched my templating engine from default to Jinja2/Coffin. Everything works just fine but I'm having troubles trying to use Django/Jinja2 django-paging (http://linux.softpedia.com/get/Internet/HTTP-WWW-/django-paging-58496.shtml) extension in my project. There is an example how to use this extension with Jinja: {% with pag...

Abstract Django Application from "Project"

Hi All, I'm struggling to work out how best to do what I think I want to do - now it may be I don't have a correct understanding of what's best practice, so if not, feel free to howl at me etc. Basically, my question is, how do I abstract application functionality correctly, said functionality being found in an application that is part...

Using Django Pipes , Bing Image Search API and Template !

Hello , I am using Django-pipes to parse Bing Image Search API , everything is going very smooth thu i can't render Thumbnail data Json : http://api.search.live.net/json.aspx?Web.Count=10&query=linux&sources=image&Appid=APPID Model.py class BingImageSearch(pipes.Pipe): uri = "http://api.search.live.net/json.aspx" @st...

How to make required field error message don't show up for first time in Django

First time I render a form I don't want the required error message to show up. Although if the field is left empty, it should prompt when submitting. I know I can set an specific message and set it empty. But this way it never shows up: error_messages = {'required':''} I'm using a decorator to change label_tag behavior in BoundField,...

How to have a Dajaxice ajax.py file for common ajax calls across a Django project

Hi, Is it possible to have a Dajaxice ajax.py file in the root directory of a Django project that handles ajax calls common to more than one app. In other words, an ajax.py file outside of a particular app. Thanks ...

django: How to hook save button for Model admin?

I have a Model with a "status" field. When the user users the Admin app to modify an instance, how to I hook onto the "Save" button click so that I could update "status" to a value that's dependent on the logged in user's username? ...

django: How to customize display of ModelAdmin form based on user?

I have a Model that's managed by Django Admin. How to I customize the display of its edit form based on the currently logged in user? For example if someone other than the superuser is modifying the model, I want to hide certain fields. It'd be great if I could set fields based on request.user ...

virtualenv and additional libraries for django

Hi I've setup a virtualenv for my existing Django project. So far it only uses django, but now I've tried to install Pisa package. It was installed successfully with pip in virtualenv, but when I try to import its package in django shell I get No module named ho.pisa So far I've not found a solution to this problem, moreover ther...

Preserving values in model fields when they no longer meet limit_choices_to criteria

I have an Article model that has a foreign key relationship with Author that needs to use a limit_choices_to because I have over 2,000 possible authors in the database. The problem is that when these authors no longer meet the limit_choices_to criteria (e.g. they become inactive), they disappear from the author field when I edit old arti...

django: How to render CharField as a label in Model Admin page?

My Model has a CharField called "comments". I want to display this as just a regular paragraph of text, instead of the default html textarea on the Model admin page. How would I go about implementing this change? ...

Django test runner runs 0 tests...

Hi all, I have a problem similar to what's described here, but the problem's not related to not having installed sites or apps (all other management commands work fine anyway). I've used the standard tests.py that comes under my app's directory just to check everything, and I get the complete "creating table..." and "Installing index....

django: Hide Model Types with no instances on Admin page

Say I have an app with ModelA, ModelB, and ModelC For my app's admin page (/admin/app), how do I hook into the display of the "App administration" page so I may hide Model types that are empty (have no instances)? ...

Django get a model's fields

Hi All, Given a Django model, I'm trying to list all of it's fields. I've seen some examples of doing this using the _meta model attribute, but doesn't the underscore in front of meta indicate that the _meta attribute is a private attribute and shouldn't be accessed directly? ... Because, for example, the layout of _meta could change...

Can i use an other langage instead of english for default django translation

Hi, Can i use an other langage instead of english(say, frensh) for default django translation. For example, instead for doing this: messages.error(request, _('My message in english')) I do this: messages.error(request, _('Mon message en francais')) ...

Only accept a certain file type in FileField

Hi, How can i resistrect FileField to only accept a certain type of file(video, audio, pdf ...) in an elegant way? ...

Sortable tables in Django

I read some of the other posts about this and some recommendations involved javascript and using other libraries. I did something quick by hand, but I'm new to Django and Python for that matter so I'm curious if this isn't a good way to do it. HTML <table> <tr> <td><a href="?sort=to">To</a></td> <td><a...