django

How can I filter the items shown in change list automatically?

I have just recently started using django (and i'm a novice python user as well), so please have some patience with my ignorance. I have installed a django application on my webhost, and I intend to use its admin interface as a multi-user log system (for lab work). There are different 'project's where each 'project' has a number of 'per...

Validating ModelChoiceField in Django forms

I'm trying to validate a form containing a ModelChoiceField: forms.py: from django import forms from modelchoicetest.models import SomeObject class SomeObjectAddForm(forms.ModelForm): class Meta: model = SomeObject models.py: from django.db import models class SomeChoice(models.Model): name = models.CharField(max_...

Local sites not displaying in VirtualBox when using Django's local development server?

Hello. I develop web applications using Django on Mac OSX 10.6. I use Django's built in local development server which I run on my computer's IP (such as: http://192.168.0.11:8001/). I test my applications in Firefox, Safari and Chrome and all display fine. I use Sun's VirtualBox with 3 different instances of Windows XP that have IE6, IE...

Django comments being spammed

Hi, I am using the built in comment system with Django but it has started to be spammed. Can anyone recommend anything I can use to stop this such as captcha for django etc. I'm looking for something that I can use along with the comment system rather than replacing it. Thanks ...

Auto-arrange <li> elements into equal columns

I have several values I'm rendering as <li> elements on my template and I want to further this by having them arranged into equal (or near-equal columns) automatically in the template. How can I achieve this? So far I'm rendering all the values as <ul> {% for feature in features %} <li>{{ feature }}</li> {% endfor %} </ul>...

django: caching passwords for custom authentication

I am authenticating users in ldap, but this happens only once, when user is logging in. Afterwards I need to keep username and password, because before every ldap operation I need to make bind on ldap server before every operation. What is the safe way to cache this password (I can't store in the database or cookies) for as long as sessi...

Django server side AJAX validation

Hi, Recently I'm trying to implement a simple Django application that include one server side AJAX validation, it's a simple form input field (username). I have used a pre-built in line AJAX validation library which uses jQuery. So the code goes like this HTML snippet <form id="simpleform" method="post" action="/done/"> Username:<inp...

Node.js as a custom (streaming) upload handler for Django

I want to build an upload-centric app using Django. One way to do this is with nginx's upload module (nonblocking) but it has its problems. Node.js is supposed to be a good candidate for this type of application. But how can I make node.js act as an upload_handler() for Django? I'm not sure where to look for examples? ...

django - query - most recent entry by user

Hello guys: here is my model class gameUserTrophyInfo(models.Model): user = models.ForeignKey(userInfo) trophy = models.ForeignKey(gameTrophyInfo) date = models.DateTimeField() i want a query that returns to me: for all users, return the most recent trophy. Example: my db: date (Day - Month - Year ) | user | tro...

AES Encrypting a password field in django using a snippet from djangosnippets

I am attempting to use this snippet: http://www.djangosnippets.org/snippets/1095/ on a model I am building- I am defining things as: first = models.TextField() last = models.TextField() email = models.EmailField(default=None) screen = models.TextField() password = models.EncryptedCharField() icon = models.ImageField(upload_to='avatars...

Load custom template tag from another application?

Is this possible in any way? My project folder structure looks like this: my_project: app1: templatetags: my_tags1.py (contains simple tags and inclusion tags) app2: templatetags: my_tags2.py (contains some simple tags) templates: app1: index.html app2: index.html The...

Django deployment: PIL and virtualenv problem

Hey guys, I'm deploying a Django site on my Vserver (Debian Lenny) and I'm having problem with PIL. I'm using virtualenv as well. When I'm in the virtualenv and type pip install -U PIL everything installs fine and I get this: *** TKINTER support not available --- JPEG support available --- ZLIB (PNG/ZIP) support available *** FREETYPE...

Having a POST'able API and Django's CSRF Middleware

I have a Django webapp that has both a front-end, web-accessible component and an API that is accessed by a desktop client. However, now with the new CSRF middleware component, API requests from the desktop client that are POST'ed get a 403. I understand why this is happening, but what is the proper way to fix this without compromising...

Django FormWizard and ImageFields

I need to create a Django FormWizard asking for the user personal data in the first step and for an image in the next step(there are more steps asking for personal data later). I can store all the data in the database except the ImageFields I read this http://code.djangoproject.com/ticket/7439 , I apply the suggested patch to my django...

django - change content inside an iframe

Hello guys, I have a site running in django and want to make it available on third party sites. In these sites they make my content available through an tag. When my site is requested from within that iframe I would like to modify the content (remove header, filter data, etc.). What would be the best way to do this? Is there any wa...

Google App Engine: Users API acting oddly

I think I'm using the Users API incorrectly: class BaseHandler(webapp.RequestHandler): user = users.get_current_user() def header(self, title): if self.user: render('Views/link.html', self, {'text': 'Log out', 'href': users.create_logout_url('/')}) else: render('Views/link.html', self, {'text': 'Log in',...

Django formsets: make first required?

These formsets are exhibiting exactly the opposite behavior that I want. My view is set up like this: def post(request): # TODO: handle vehicle formset VehicleFormSetFactory = formset_factory(VehicleForm, extra=1) if request.POST: vehicles_formset = VehicleFormSetFactory(request.POST) else: vehicles_formset ...

Django: How to iterate over formsets and access cleaned data?

What if I want to do something with my formset other than immediately saving it? How can I do this? for form in vehicles_formset.forms: listing.id = None listing.vehicle_year = form.cleaned_data['year'] listing.vehicle_make = form.cleaned_data['make'] listing.vehicle_model = form....

How to run multiple versions of a Django app with mod_python?

I want to set up test and production versions of a Django app on separate apache name virtual hosts and wanted to know the best way to do this. Here's what I've done, and it seems to work ok, but I'm wondering if there's a better way. <VirtualHost *> ServerName test.foo.bar <Location "/app/"> SetHandler python-progra...

Django LFS - custom views

For all those ligthning fast shop users. I'm trying to implement my own first page view that will list all products from shop ( under '/' address). So I have a template : {% extends "lfs/shop/shop_base.html" %} {% block content %} <div id="najnowsze_produkty"> <ul> {% for obj in objects %} <li> {{ obj.name }} </li...