django

django-registration custom registration form (recaptcha field)

I try to add a recaptcha field to my registration form and followed Marcos guide: http://www.marcofucci.com/tumblelog/26/jul/2009/integrating-recaptcha-with-django/ In my registration app, I have a file "forms.py" which looks like this: from recaptcha import fields as captcha_field from registration.forms import RegistrationFormUniqu...

Pinax Django Photologue - Moderation

Hi Guys, I'm building a site for the local cub scouts using Pinax. Does anyone have any suggestions as to how we can moderate photos before they are uploaded? ...

Redirecting errors nicely without so much copy/paste?

If I have a view that handles the management of friends, meaning there is a view to handle adding, removing, blocking, unblocking, and accepting/denying invitations to become friends. The problem I have run into is when I try to provide meaningful errors to users who end up at a url they shouldn't be at. For example if User1 and User2 a...

Nested blocks in Django templates

The master template in my Django app looks like this: {% block parent %} Some text... {% block child %} Default content here... {% endblock child %} ...some more text {% endblock parent %} Now, this template should be overwritten in a way that the child block is changed: {% extends "master.html" %} {% block c...

Django template and the locals trick

The django books gives the local trick in order to avoid to type a long list of parameters as context dictionnary http://www.djangobook.com/en/2.0/chapter04/ It recommends this to lazy programmers but points out some overhead which may have an impact on performance. I would like to know if some of you are using the locals trick on real...

Solr Facet Range with Integers

My index contains peoples information, name, age, phone email etc. I am faceting on Age. I group ages kinda like Date Range functionality. My ranges are: 0 to 10 11 to 20 21 to 30 31 to 40 etc etc When I do a query: ?q=*:*&facet=true&fq=age:[21+TO+30] It returns all the ages I want in the range 21 to 30, but ...

Django Admin app: building a dynamic list of admin actions

I am trying to dynamically build a list of admin actions using the get_actions() method on a ModelAdmin. Each action relates to a particular instance of another model, and as new instances may be added or removed, I want to make sure the list of actions reflects that. Here's the ModelAdmin: class PackageAdmin(admin.ModelAdmin): lis...

How to implement time event scheduler in python?

In python how to implement a thread which runs in the background (may be when the module loads) and calls the function every minute Monday to Friday 10 AM to 3 PM. For example the function should be called at: 10:01 AM 10:02 AM 10:03 AM . . 2:59 PM Any pointers? Environment: Django Thanks ...

How to properly remove a specific ManyToMany relationship?

I have a ManyToMany relationship with one of my Models. On deleting a child, I want to remove the relationship but leave the record as it might be being used by other objects. On calling the delete view, I get an AttributeError error: Exception Value: 'QuerySet' object has no attribute 'clear' This is my models.py: class Feed(...

context within a query filter?

I have a very basic contact model. The model has the following fields: class Entry(models.Model): name = models.CharField(max_length=64, unique=False) organization = models.CharField(max_length=100, unique=False, blank=True, null=True) team = models.CharField(max_length=64, unique=False, blank=True, null=True) position ...

Running Django Tests with a Precommit Hook

Hello, I would like to run all my django tests using mercurial's precommit hook. Whenever a test fails the commit will be aborted. The goal is to block build-breaking commits as often as possible. edit: Ended up using the external script route. Here is the reletant portion of my hgrc: [hooks] precommit = python ./pinax/projects/lgr/m...

Minimal production Django server on Windows

Hi, I need to deploy a small Django app to be used in a small intranet. Concurrency and speed are non issues because there will be, at most, 10 users (and I bet that there will be almost no concurrency). There is already a MySQL server. The problem is with the Django app. What is the most lightwieght server I can install under a WinXP ...

Is there any way to make Django's get_or_create() to create an object without saving it to database?

When using Django's get_or_create(), when created=True, is there any way to make it so that it creates an object without saving it to DB? I want to take the newly created object, do some validation tests, and only save it to DB if it passes all tests. ...

Validate that atleast one modelfield has value in Django admin

Given the following model, how do I require that atleast one of the two fields has been given a value? class ZipUpload(models.Model): zip_file = models.FileField(upload_to="/tmp", blank=True, help_text='Select a file to upload.') zip_file_path = models.FilePathField(path="/tmp", blank=True, ...

Django Official Tutorial Part 1 index out of bound error

Hi, I started learning Django recently and am having a strange problem with the tutorial. Everything was going fine until I started playing with the interactive shell and then I got an error whenever I tried to call all the objects in one of the tables. I am using Django 1.1, Python 2.5 on MacOs X. For those unfamiliar with the tutori...

Django + MySQL on Mac OS 10.6.2 Snow Leopard

There were some excellent answers to this question already, however, they are now outdated. I've been able to get the module installed, but "python manage.py runserver" fails with iMac:myproject drhoden$ python manage.py runserver Validating models... Unhandled exception in thread started by <function inner_run at 0x10496f0> Traceb...

django fails, sometimes, very erratic behavior.

I have terrible problems with django responding differently to the same requests for no apparent reason. Sometimes i refresh and I see an error, then I refresh and its gone, sometimes the template complains about a missing value then its fine again, again without explanation. Sometimes it pulls the graphics from the production server, ...

How can I sort by the id of a ManyToManyField in Django?

I've got a ManyToManyField in a user object and it's used to map the users that user is following. I'm trying to show a subset list of who they have most recently followed. Is there a trick in .order_by() that will allow me to sort by the id of the ManyToManyField? The data is there, right? # (people the user is following) following = m...

Literals in django template language?

If I want some text to appear literally in a Django template, e.g. {{Image.jpg|title}} and I want that text to be output (not interpretated) in the HTML, how do I do so? ...

django user auth + gwt

I have a django server app that communicates with a gwt front-end using JSON. I want to introduce user authentication to the app and have started to incorporate the framework provided by django. At this point I have set up the server to respond with the user authentication form when necessary (using the @login_required decorator scheme d...