django

Model Formset saving with form.save(commit=False) and multiple field names

Hello, I understand that Django won't let you save a incomplete fields in a single form created from a Model unless you do this: tmpform = form.save(commit=False) tmpform.foo = form.cleaned_data['foo'] tmpform.save() So I want to do this kind of thing with forms in a formset - I am trying to to iterate through all the fields for eac...

Django & Nginx deeplinking domains (re-write rules or django urls?)

I'm running Django behind Nginx (as FASTCGI) and I need to "deeplink" to a page in one domain from the root of another without redirecting or forwarding e.g. Given that I have a domain general-stuff.com and a matching URL http://general-stuff.com/books/ and that I have a second domain books-stuff.com I need a way to get the page served ...

User in Form-Class

I have a form like this: class MyForm(forms.Form): [...] which is rendered in my view: if request.method == 'GET': form = MyForm(request.GET) Now, i want to add a form field which contains a set of values in a select-field, and the queryset must be filtered by the currently logged in user. So I changed the method signature so t...

Django select multiple date from calendar

Hi, Im new in using Django, and i want to know if there is some way to have a multiple date selection from a calendar, i have multiple days : for example a day is : [ 28 july 2009 8:30 - 28 july 17h00 ] Is there any way to do this with Django Forms Thanks a lot kimo ...

GeoDjango - How to present points on a map?

Simple 'Example' - have millions of points within specific geography. Have everything loaded and able to see in GeoAdmin the whole 9 yards. So. How do I show all points on a map - and base it on zoom level? Are there any simple examples out there? ...

Django formsets, filtering foreignkeys

Hey there, I've been looking through the site and trying to find something to help me, but I can't find anything. I'll begin with showing the models that relate to this: class Game(models.Model): home_team = models.ForeignKey(Team, related_name='home_team') away_team = models.ForeignKey(Team, related_name='away_team') round ...

Forward declaration - no admin page in django?

Hi SO, This is probably a db design issue, but I couldn't figure out any better. Among several others, I have these models: class User(models.Model): name = models.CharField( max_length=40 ) # some fields omitted bands = models.ManyToManyField( Band ) and class Band(models.Model): creator = models.ForeignKey( User ) # some...

How to update manytomany field in Django?

Here'a an example: If I have these classses class Author(models.Model): name = models.CharField(max_length=45) class Book(models.Model): name = models.CharField(max_length=45) authors = models.ManyToManyField(Author) In the database I have one Author with the name "George" and another one with the name "Georfe". The last...

[Python/Django] How do I change the directory of InMemoryUploadedFile?

It seems that if I do not create a ModelForm from a model, and create a new object and save it, it will not respect the field's upload directory. How do I change the directory of a InMemoryUploadedFile so I can manually implement the upload dir? Because the InMemoryUploadedFile obj is just the filename, and I would like to add the uploa...

Installing Django with mod_wsgi

I wrote an application using Django 1.0. It works fine with the django test server. But when I tried to get it into a more likely production enviroment the Apache server fails to run the app. The server I use is WAMP2.0. I've been a PHP programmer for years now and I've been using WAMPServer since long ago. I installed the mod_wsgi.so an...

django @login_required decorator error

I'm running django 1.1rc. All of my code works correctly using django's built in development server; however, when I move it into production using Apache's mod_python, I get the following error on all of my views: Caught an exception while rendering: Reverse for '<django.contrib.auth.decorators._CheckLogin What might I look for that'...

How to manage many to one relationship in Django

Hello, I am trying to make a many to one relationship and want to be able to control it (add -remove etc) via the admin panel. So this is my model.py: from django.db import models class Office(models.Model): name = models.CharField(max_length=30) class Province(models.Model): numberPlate = models.IntegerField(primary_key=True...

Doing it right in Django - subclassing instead of hacking

I am using the threadedcomments module and need two changes: - an additional field on the ThreadedComment model - different fields on the form I know the answer is to subclass but I'm not sure how to go about doing this - where does the code go? ...

Apache Django Mod_Wsgi Sessions Development Enviroment

I'd like to know how I can maintain sessions while developing on my local machine (django, apache, mod-wsgi). Each time I make updates to python code I need to restart Apache for the changes to take effect. ...

Passing a Django model attribute name to a function

I'd like to build a function in Django that iterates over a set of objects in a queryset and does something based on the value of an arbitrary attribute. The type of the objects is fixed; let's say they're guaranteed to be from the Comment model, which looks like this: class Comment(models.Model): name = models.CharField(max_length=...

CopyBlock tag for Django

How can write tag "copyblock" for Django templates? For such a functional:: <title> {% block title %} some title... {% endblock %} </title> <h1>{% copyblock title %}</h1> Thx! ...

Actions triggered by field change in Django

How do I have actions occur when a field gets changed in one of my models? In this particular case, I have this model: class Game(models.Model): STATE_CHOICES = ( ('S', 'Setup'), ('A', 'Active'), ('P', 'Paused'), ('F', 'Finished') ) name = models.CharField(max_length=100) owner = mode...

How to set the encoding for the tables' char columns in django?

I have a project written in Django. All fields that are supposed to store some strings are supposed to be in UTF-8, however, when I run manage.py syncdb all respective columns are created with cp1252 character set (where did it get that -- I have no idea) and I have to manually update every column... Is there a way to tell Django to ...

django one to many issue at the admin panel

Greetings, I have these 2 models: from django.db import models class Office(models.Model): name = models.CharField(max_length=30) person = models.CharField(max_length=30) phone = models.CharField(max_length=20) fax = models.CharField(max_length=20) address = models.CharField(max_length=100) def __unicode__(self)...

authenticate from Flex in Django with pyAMF

Maybe somebody can show an example of such a task, or specify where to look. ...