django

How to consume XML from RESTful web services using Django / Python?

Should I use PyXML or what's in the standard library? ...

Is Django model validation handled just through the forms API?

Is this the only way to create custom model validation? To do it using the forms? What if I want to send data to the database through means other than forms? ...

Server Side Google Markers Clustering - Python/Django

After experimenting with client side approach to clustering large numbers of Google markers I decided that it won't be possible for my project (social network with 28,000+ users). Are there any examples of clustering the coordinates on the server side - preferably in Python/Django? The way I would like this to work is to gradually inde...

What is the best way to access stored procedures in Django's ORM.

I am designing a fairly complex database, and know that some of my queries will be far outside the scope of Django's ORM. Has anyone integrated SP's with Django's ORM successfully? If so, what RDBMS and how did you do it? ...

Which permissions should I use for Django folders at my server?

My host Djangohosting puts 777 by default for my Django folders, when I use their one-click Django installer. I am not sure whether that is safe or not, since everyone can then apparently see my source code. Which permissions should I use for Django folders at my server? ...

How to get field names when running plain sql query in django

In one of my django views I query database using plain sql (not orm) and return results. sql = "select * from foo_bar" cursor = connection.cursor() cursor.execute(sql) rows = cursor.fetchall() I am getting the data fine, but not the column names. How can I get the field names of the result set that is returned? ...

ManyToManyFields in Django Admin

I'm using Photologue in my application, and I really like the ManyToManyField selector that appears in the admin app (two multi-select boxes with arrows for moving items between the selected and non-selected states, along with "Choose All" and "Clear All" options). I'm using very similar code in my own model, but my ManyToManyField sele...

Django: Redirect to previous page after login

Hey, I'm trying to build a simple website with login functionality very similar to the one here on SO. The user should be able to browse the site as an anonymous user and there will be a login link on every page. When clicking on the login link the user will be taken to the login form. After a succesfull login the user should be taken b...

about annotate django

I'd like to create the top five best seller of the products in each month. I've heard that the annotations must be used for this case but I don't know how to use it. Will anybody be kind enough to help me ?? ...

Django m2m queries, distinct Users for a m2m relationship of a Model

Hi, I have a model Model with a m2m field : user = .. fk user ... watchers = models.ManyToManyField(User, related_name="boardShot_watchers", null=True) How do i select all distinct Users involved in this watchers relationship for all my entries of type Model ? I dont think there is an ORM way to access to intermediary M2M tabl...

Annotate a sum of two fields multiplied.

I have three models, simplified for the example: class Customer(models.Model): email = models.CharField(max_length=128) class Order(models.Model): customer = models.ForeignKey(Customer) order_status = models.CharField(blank=True, max_length=256) class Lineitem(models.Model): order = models.ForeignKey(Order) quantit...

Decoding problems in Django and lxml

I have a strange problem with lxml when using the deployed version of my Django application. I use lxml to parse another HTML page which I fetch from my server. This works perfectly well on my development server on my own computer, but for some reason it gives me UnicodeDecodeError on the server. ('utf8', "\x85why hello there!", 0, 1,...

ModelMultipleChoiceField as a multi-column table

In Django, how do I render a ModelMultipleChoiceField as a multi-column <table>? fav = forms.ModelMultipleChoiceField(Show.objects.all(), widget=forms.CheckboxSelectMultiple) I want this field to render as a multi-column table. Which is the best way to do that? To clarify, I want the rendering to ...

Django Manager Chaining

I was wondering if it was possible (and, if so, how) to chain together multiple managers to produce a query set that is affected by both of the individual managers. I'll explain the specific example that I'm working on: I have multiple abstract model classes that I use to provide small, specific functionality to other models. Two of t...

Search engines and migrating a static site to a web app

We're replacing a static web-site with a Django app. All the uri's will change. The current web-site has a substantial presence on the search engine rankings and we don't want to mess that up too much. Is it simply a case of setting up 301 redirects to the new uri's, or is there something more subtle we need to do to ensure the searc...

Django form field using SelectDateWidget

I've installed the latest SVN branch from Django which includes the new forms. I'm trying to use the SelectDateWidget from django.forms.extras.widgets but the field is showing up as a normal DateInput widget. Here is the forms.py from my application: from django import forms from jacob_forms.models import Client class ClientForm(forms...

how to manually assign imagefield in Django

I have a model that has an ImageField. How can I manually assign an imagefile to it? I want it to treat it like any other uploaded file... ...

Django Managers - Retrieving objects with non-empty set of related objects

Hi, I have two classes, Portfolio, and PortfolioImage. class PortfolioImage(models.Model): portfolio = models.ForeignKey('Portfolio', related_name='images') ... class Portfolio(models.Model): def num_images(self): return self.images.count() I want to write a "non-empty portfolio" manager for Portfolio, so that I ...

Django set field value after a form is initialized

I am trying to set the field to a certain value after the form is initialized. For example, I have the following class. class CustomForm(forms.Form): Email = forms.EmailField(min_length=1, max_length=200) In the view, I want to be able to do something like this: form = CustomForm() form["Email"] = GetEmailString() return HttpR...

How to translate icontains in django to SQL statement ?

I want to get the top 5 of selling price of each month in each year. So I put in the code like this def query(request): from django.db import connection cursor = connection.cursor() cursor.execute("SELECT product_style_id ,sum(price) As total_p ,sum(cast( amount as int )) AS total_a FROM jewelry_productorder group by pr...