django

Alternate forms libraries on django eg sprox, formalchemy

Has anyone had any joy/pain with using other form libraries in django projects (with SQLAlchemy models initially, but perhaps to use with django models in future)? Initial impressions are that sprox is more flexible and decoupled but that formalchemy might be quicker to get up and running with, but I'd be really interested in hearing fr...

Inline editing of ManyToMany relation in Django

After working through the Django tutorial I'm now trying to build a very simple invoicing application. I want to add several Products to an Invoice, and to specify the quantity of each product in the Invoice form in the Django admin. Now I've to create a new Product object if I've got different quantites of the same Product. Right now ...

Optional ImageField (Django)

Hi all, I'm having a problem with an ImageField in one of my models. It is set to blank=True, null=True (it is optional.) When I loop through a list of objects and use object.thumbnail.url, I get "Caught an exception while rendering: The 'thumbnail' attribute has no file associated with it." This only happens if no thumbnail has bee...

Django Form Wizard and Preview with ModelForm

I have a large Django model (73 fields) that will will be connected to a ModelForm. I'd like to use a combination of the functionality found the Form Wizard and Form Preview contrib apps. I.e., the form fields would be split over multiple pages, and the user would have a chance to review/preview the data before the model instance is cr...

Strange decorator result on related object comparison

On views that allow updating/deleting objects, I need a decorator that verifies that the object to be edited belongs to a group(model "loja). Both defined in the url: /[slug model loja--s_loja]/[viewname-ex:addmenu]/[object id--obj_id] Because the model of the object can vary, the decorator the model of the object as an argument. Every...

Customize HTML Output of Django ModelForm

I am trying to add multiple inline form items to a page using Djangos ModelForms. I need Select boxes bound to database models. The forms are formatted and placed in a tabular format so I need to display only the ModelForm without ANY surrounding HTML. class LeagueForm(ModelForm): league = forms.ModelChoiceField(queryset=League.objects....

"CSRF verification failed" when attempting to upload a file or create a folder with filebrowser for Django

I have installed filebrowser for Django (not filebrowser3) and when I try to upload a file I recieve the following error: 403 Forbidden CSRF verification failed. Request aborted. More information is available with DEBUG=True. The same error occurs when I try to create a new folder which shows that the problem is that ...

File does not upload from web form in Django

Howdy - I've written a very simple app to accept job applications including a resume upload. Running the bundled server for development locally, I can successfully upload files via the web form on the front end and the admin interface. Running it on the remote server (Apache with mod_python) I can successfully upload files via the admin...

Custom save method giving invalid tuple size error

I've been stuck on this likely very simple problem, but haven't gotten anywhere with it (newbie to Python and Django). I'm taking some user submitted data and using weights to calculate a score. Despite my best efforts, I'm getting the following when I submit the data via a form: "global name 'appearance' is not defined". I'm pretty s...

Django: use custom class for request.user?

I've extended Django's default user class like this: class CustomUser(User): friends = models.ManyToManyField('self', symmetrical=False) But now I want to use that everywhere instead of the default User class. In my view methods, I have access to request.user but that's an instance of the User class. What's the easiest way to make it...

Haystack Whoosh Spelling Suggestion too greedy

This questions is about Django Haystack, with Whoosh backend. I would like to use spelling suggestion in my search. The problem is that it is suggesting TOO much. Say I have two models: Apples and Oranges. If I have somethine like this: result = SearchQuerySet().models(Apples).filter( content=escaped_value).spelling_suggestion(esc...

Render page initially and update via AJAX using the same template HTML

Let's say you have a view called "View Story" which is just a web page rendered on the backend via Python/Django. On that page there's a list of comments at the bottom rendered as part of the "View Story" template using Django's templating system (in a loop). This page also allows you to add a comment to the list. This is done through...

How to downgrade Django from dev to 1.1

I am running the development version of Django and it appears that the filebrowser app is not compatible with trunk because of changes made to CSRF. How do I downgrade to the official release (1.1)? I am working on a shared host and the way that I am curently running Django is as follows: ~/local/lib/python2.6/site-packages/ contains /...

Django annotate to show aggregate sums and counts pre-slicing of the QuerySet

I have a fairly complex QuerySet which users a good deal of annotated values to get some counts and sums across the entire record set. The resulting rows are grouped and for each group I show the sum of this column, or the count of that column etc. The problem is that when I slice the query set in order to paginate the data, the query i...

Django unit testing - Why can't I just run ./tests.py on myApp?

So I'm very familiar with manage.py test myapp. But I can't figure out how to make my tests.py work as an stand-alone executable. You may be wondering why I would want to do this.. Well I'm working (now) in Eclipse and I can't seem to figure out how to set up the tool to simply run this command. Regardless it would be very nice to sim...

Diference between appengine_django BaseModel and db.Model

I'm using the Google App Engine helper for Django. This helper includes the following lines in its template: from appengine_django.models import BaseModel from google.appengine.ext import db # Create your models here. Should I derive my models from db.Model or from BaseModel? I've tried both and I don't see any difference. Both seem ...

Django Filtering Problem

I'm trying to set up a filter query in one of my views...basically my code looks as below: def inventory(request): vehicle = Vehicle.objects.all().exclude(status__status='Incoming').order_by('common_vehicle__series__model__manufacturer__manufacturer', 'common_vehicle__series__model__model', 'common_vehicle__year') year_count =...

Remove "add another" in Django admin screen

Whenever I'm editing object A with a foreign key to object B, a plus option "add another" is available next to the choices of object B. How do I remove that option? I configured a user without rights to add object B. The plus sign is still available, but when I click on it, it says "Permission denied". It's ugly. I'm using Django 1.0.2...

django datefield filter

I'd like to use an object filter similar to the following Shipment.objects.filter(date__gte=datetime.date(2005,1,1)) However there doesn't seem to be support for comparison operators on datetime objects. Is there a method I'm unaware of or should I look into writing a custom filter. ...

Which CAS implementation to use in django?

Which CAS implementation should i use to enable CAS single sign on to my django app (trusing a specified CAS server, I'm not interested in creating a CAS provider) ? What I can find are the following: http://code.google.com/p/django-cas/ http://github.com/Nitron/django-cas-consumer I've used django-cas before, and it seems to work b...