django

django "manage.py index" does not execute as a cron job

I am trying to develop a site using pinax. To index the models using djapian I've been trying to run "manage.py index" as a cron job but keep getting a pinax error. "Error: No module named notification". However the task executes correctly when i run it from the shell. My crontab definition is as follows: SHELL=/bin/sh PATH=/usr/local/...

redirecting to a page

I am facing a problem .I want to give a link in my change form that will redirect to a page which may be simple php page also or any page ,in that page i want to perform some db queries and display them.I also wan to pass id on click.Is it posssible. in my view.py i wrote: from django.shortcuts import render_to_response from django....

Should I use Celery or Carrot for a Django project?

I'm a little confused as to which one I should use. I think either will work, but is one better or more appropriate than the other? http://github.com/ask/carrot/tree/master http://github.com/ask/celery/tree/master ...

python - Problem storing Unicode character to MySQL with Django

I have the string u"Played Mirror's Edge\u2122" Which should be shown as Played Mirror's Edge™ But that is another issue. My problem at hand is that I'm putting it in a model and then trying to save it to a database. AKA: a = models.Achievement(name=u"Played Mirror's Edge\u2122") a.save() And I'm getting : 'ascii' codec can...

Making Django.contrib.auth store plain-text password

I have a Django-based site (not yet launched, so there are no real users) using plain django.contrib.auth, and want to store passwords as plain-text, not salted SHA-1 hashes. The question is what's the best approach to do this, hopefully, without patching (or monkey-patching) Django source code? NOTE: I perfectly know this is certainly...

Can I detect if my code is running on cPython or Jython?

I'm working on a small django project that will be deployed in a servlet container later. But development is much faster if I work with cPython instead of Jython. So what I want to do is test if my code is running on cPython or Jython in my settiings.py so I can tell it to use the appropriate db driver (postgresql_psycopg2 or doj.backend...

Problem with custom Authentication Backend for Django

I'm having a problem with a custom Authentication Backend I've built for an Active Directory via LDAP authentication. The problem is that from the admin login page, after it properly authenticates and creates the new user in the database (or updates their info from the LDAP server), but then returns me to the admin login page indicating...

Make a foreign key field in a django form read-only, and still enable the form to be submitted

How do I make a foreign key field in a form read only but still allow this field to be recognized as valid once the form is submitted? According to W3C, disabled fields are left out once the form is submitted....using the code below, I can set the field as disabled, thus readonly, but my form doesn't go through def __init__(self, ...

Django templates: verbose version of a choice

I have a model: from django.db import models CHOICES = ( ('s', 'Glorious spam'), ('e', 'Fabulous eggs'), ) class MealOrder(models.Model): meal = models.CharField(max_length=8, choices=CHOICES) I have a form: from django.forms import ModelForm class MealOrderForm(ModelForm): class Meta: model = MealOrder A...

How can I persist a single value in Django?

My Django application retrieves an RSS feed every day. I would like to persist the time the feed was last updated somewhere in the app. I'm only retrieving one feed, it will never grow to be multiple feeds. How can I persist the last updated time? My ideas so far Create a model and add a datetime field to it. This seems like overk...

Multi-Tenant Django Application

Are there common patterns people use for creating multi-tenanted applications using Django. The built in "sites" framework seems like an option. Are there other approaches people have had success with? ...

Django: Access model as dictionary

I have data in a python dictionary that I'd like to store in a model instance. For example, my dictionary might look like data = { 'date': '6/17/09', 'name': 'something', 'action': 'something' } And my model might look like: class Something(models.Model): date = models.DateField() name = models.CharField() action = models...

Is 'if element in aList' possible with Django templates?

Does something like the python if "a" in ["a", "b", "c"]: pass exist in Django templates? If not, is there an easy way to implement it? ...

Changing data in a django modelform

I get data in from POST and validate it via this standard snippet: entry_formset = EntryFormSet(request.POST, request.FILES, prefix='entries') if entry_formset.is_valid(): .... The EntryFormSet modelform overrides a foreign key field widget to present a text field. That way, the user can enter an existing key (suggested via an Aja...

How to model an object with references to arbitrary number of arbitrary field types? (django orm)

I'd like to define a set of model/objects which allow for one to represent the relationship: field_set has many fields where fields are django.db.model field objects (IPAddressField, FilePathField etc). My goals is to have a ORM model which supports the following type of 'api'. From a controller view lets say: # Desired api below def...

Multiple processes accessing Django db backend; records not showing up until manually calling _commit

I have a Django project in which multiple processes are accessing the backend mysql db. One process is creating records, while a second process is trying to read those records. I am having an issue where the second process that is trying to read the records can't actually find the records until I manually call connection._commit(). Th...

What is the best way to post to Twitter from a django app?

What I want to do is pretty straightforward. I have a site powered by django. I want to have the site automatically post to twitter any time a new object is created and saved in the database. What is the absolute best way to do this? ...

Paginated + Ajax table in Django

I simply want to show off a model in a table that is paginated and sortable on the various fields. Bonus points if the pagination and sorting doesn't cause a page reload. Double bonus points if the pagination is done with infinite scrolling. I'm sure everyone here has written and rewritten this functionality. Is there a simple middlew...

lighttpd mod_rewrite vs. apache mod_rewrite with Django and FastCGI

I am in the process of migrating from a Django FastCgi setup in Apache to one in lighttpd. On Apache, I was using the fcgi config described in the Django docs. The core part being rewriting all my non-static URLs to be /mysite.fcgi/$1: RewriteRule ^/(.*)$ /mysite.fcgi/$1 [QSA,L] and then forwarding all requests for /mysite.fcgi for F...

Best way to make a model search form?

I have this model: class Aircraft(models.Model): model = models.CharField(max_length=64, blank=True) type = models.CharField(max_length=32) extra = models.CharField(max_length=32, blank=True) manufacturer = models.CharField(max_length=32) engine_type = models.IntegerField("Engine Type", choices=ENGINE_TYPE, default=0) cat_class...