django

Working with Django LocalFlavor Zip as a Model Field

What's the best way to implement the following: ### models.py >>> from django.db import models >>> from django.contrib.auth.models import User # Create the client class. >>> class Client(models.Model): ... user = models.OntToOneField(User) ... zip = ***???***() ### forms.py >>> from django.forms import ModelForm # Create the fo...

Customizing modelformset fields in Django

I'd like to use the following form class in a modelformset. It takes a maps parameter and customizes the form fields accordingly. class MyModelForm(forms.ModelForm): def __init__(self, maps, *args, **kwargs): super(MyModelForm, self).__init__(*args, **kwargs) #customize fields here class Meta: model = My...

jQuery getJSON callback does not work - even with valid JSON - and seems to be using "OPTION" request not "GET"

Hello, The background is that I've got a celery distributed job server configured with a Django view that returns the status of a running job in JSON. The job server is located at celeryserver.mydomain.com and the page I'm executing the jQuery from is www.mydomain.com so I shouldn't need to consider JSONP for this should I, as the req...

Google app engine tutorial problem - new datastore model

So i've just finished the google app engine greetings tutorial. All well so far. I then decided to try and add a new datastore model and then set it in the existing handler. I added a 2nd content field called "content2" and then tried to set it in the handler Guestbook(), but it keeps borking out. I'm sure it will be the silliest error, ...

django.contrib.auth: how to keep site and admin sessions separate?

I'm using a user profile model with a ForeignKey to the User, authenticated by django.contrib.auth. The same auth module is of course used for the admin interface, so if a superuser/staff member is logged in to the admin interface, and enters the main site, the site will accept session cookie and authenticate him. This creates a proble...

admin/appname/modelname urls does not work with mod_wsgi in Django 1.1rc1

I'm using Django 1.1 rc1 and Apache 2.2.8 on Ubuntu with mod_wsgi 1.3.1 + Python 2.5.2. Everything worked fine with Django's internal testing web server, but after migrating to Apache mod_wsgi, all urls like /admin/appname/modelname/ began not to work. They shows 404 not found errors with the following log: ... ^admin/ ^$ ^admin/ ^logo...

excel in django

Hi,How can i make user to downlaoad a excel from the django app.i HAVE A MODEL WHICH gives the report.Now i want a option from user can download the file in excel form.ANy Solution ...

Reusing a Django app within a single project

In trying to save as much time as possible in my development and make as many of my apps as reusable as possible, I have run into a bit of a roadblock. In one site I have a blog app and a news app, which are largely identical, and obviously it would be easier if I could make a single app and extend it where necessary, and then have it fu...

How to specify which eth interface Django test server should listen on?

As the title says, in a multiple ethernet interfaces with multiple IP environment, the default Django test server is not attached to the network that I can access from my PC. Is there any way to specify the interface which Django test server should use? -- Added -- The network configuration is here. I'm connecting to the machine via 14...

How to give an "included" template additional context?

Is there possibility to narrow context for include. For example, I have "for" tag that gets from posts array - one post. Than I wonna put this post inside "include" tag to render in more detail context. Is there custom tags for this? ...

Django runserver permanent

How can I make the development server from django running permanent? So that it does't stop when i quit the shell. Thanks ...

Django: Easily add extra manager for child class, still use default manager from AbstractBase

Hi, this question is about the last example on Custom managers and model inheritance. I want to be able to do something similar to the following: class ExtraManagerModel(models.Model): # OtherManager class supplied by argument shall be set as manager here class Meta: abstract = True class ChildC(AbstractBase, ExtraManage...

Django : How can I see what custom tags have been defined?

I'm having trouble with a custom tag in Django. Is there any way I can see a list of what custom tags have been defined and are currently registered? ...

Dynamic templates in Django

I'm about to make a dynamic website in Django so that user can change the template the website is based upon....for new users, they'll have to choose a template they like from a menu, after which this is stored in a cookie for future reference. I however don't know how to do this....any ideas. ...

Django cache.set() causing duplicate key error

My Django site recently started throwing errors from my caching code and I can't figure out why... I call: from django.core.cache import cache cache.set('blogentry', some_value) And the error thrown by Django is: TransactionManagementError: This code isn't under transaction management But looking at the PostgreSQL database logs, i...

Django FileField with upload_to determined at runtime

I'm trying to set up my uploads so that if user joe uploads a file it goes to MEDIA_ROOT/joe as opposed to having everyone's files go to MEDIA_ROOT. The problem is I don't know how to define this in the model. Here is how it currently looks: class Content(models.Model): name = models.CharField(max_length=200) user = models.Forei...

What's the best way to optimize this MySQL query?

This is a query that totals up every players game results from a game and displays the players who match the conditions. select *, (kills / deaths) as killdeathratio, (totgames - wins) as losses from (select gp.name as name, gp.gameid as gameid, ...

Sorting and indexing into a list in a Django template?

How can you perform complex sorting on an object before passing it to the template? For example, here is my view: @login_required def overview(request): physicians = PhysicianGroup.objects.get(pk=physician_group).physicians for physician in physicians.all(): physician.service_patients.order_by('bed__room__unit', 'bed__room__orde...

imagefield won't validate

I moved a site to a mediatemple server using python 2.3, now imageField won't work in the admin. Upon saving, validation gives the "not valid image" error. checked: -media_root and media_url are correct -pil contains jpg support -upload folders set to 775 -image is not corrupted Ideas? Thanks. ...

Using a static Index page with Django and Nginx

I'm building a website using Django + Apache and Nginx to serve my static content. My site's index does not require any backend Django coding, so what would I need to change in nginx.conf to send requests for location / { } to some index.html in my static-content, while still allowing my urls.py to handle patterns appropriately? upstrea...