Consider the following skeleton of a models.py for a space conquest game:
class Fleet(models.Model):
game = models.ForeignKey(Game, related_name='planet_set')
owner = models.ForeignKey(User, related_name='planet_set', null=True, blank=True)
home = models.ForeignKey(Planet, related_name='departing_fleet_set')
dest = model...
I'm certain I'm doing something really obviously stupid, but I've been trying to figure it out for a few hours now and nothing is jumping out at me.
I'm using a ModelForm so I can expose a few fields from a model for editing. 2x ImageField, 1x TextField. The Form is processed and the TextField works. The two ImageFields do not work and ...
I need to make a simple knowledge-base type application to use in company internal network. To make it simple and fast to use for end-users I would like to skip all the login in part (as it will be only visible to internal network users who we trust anyway) and automaticly pull the domain user name from the user and put it into the datab...
I have a ForeignKey which can be null in my model to model a loose coupling between the models. It looks somewhat like that:
class Message(models.Model):
sender = models.ForeignKey(User, null=True, blank=True)
sender_name = models.CharField(max_length=255)
On save the senders name is written to the sender_name attribute. Now, I wa...
I'm working on a web application using isapi_wsgi and django-pyodbc. I'd like to have a way to install all dependencies and push the files out to the webserver. Unfortunately, some of these are easier said than done. In particular, handling dependencies is a pain as some of them won't install correctly even under setuptools (pywin32 i...
I have a Django project with multiple applications (say, two), and both need different versions of *MEDIA_ROOT* and *MEDIA_URL*.
The documentation does specify how to modify a specific setting, but here is what I did.
I created a project1/settings.py,
# project1/settings.py,
from django.conf import settings
settings.MEDIA_URL = 'f...
I'm looking to implement data synchronization between servers and distributed clients. The data source on the server is mysql with django on top. The client can vary. Updates can take place on either client or server, and the connection between server and client is not reliable (eg. changes can be made on a disconnected cell phone, shoul...
I have a strange issue specific to my Django deployment under Python 2.6 + Ubuntu + Apache 2.2 + FastCGI.
If I have a template as such:
{% with True as something %}
{%if something%}
It Worked!!!
{%endif%}
{%endwith%}
it should output the string "It Worked!!!". It does not on my production server with mod_fastcgi.
This w...
I often hear about Flex being combined with web frameworks on the backend. The idea being that Flex serves as the presentation framework while the web framework (Django/Rails) does the database lookups and sends the data to Flex to present in the form of XML.
However, is there ever a situation where Flex and Python/Ruby would be combine...
In django model querysets, I see that there is a __gt and __lt for comparitive values, but is there a __ne/!=/<> (not equals?)
I want to filter out using a not equals:
Example:
Model:
bool a;
int x;
I want
results = Model.objects.exclude(a=true, x!=5)
The "!=" is not correct syntax. I tried __ne, <>.
I ended up using:
re...
I've tried various methods to achieve this.
I decided against overriding formfield_for_dbfield as it's doesn't get a copy of the request object and I was hoping to avoid the thread_locals hack.
I settled on overriding get_form in my ModelAdmin class and tried the following:
class PageOptions(admin.ModelAdmin):
def get_form(self, r...
I'm having a problem in displaying images in my CSS file.
I have a css file with the following class:
.header
{
margin-left: auto;
bla bla
bla bla
...
background: url(/site_media/header_background.gif) no-repeat top left;
}
When I execute the template with this css, no image is displayed, but when I directly inject the backgroun...
Like an idiot, I completely overlooked the timezone setting when I first built an application that collects datetime data.
It wasn't an issue then because all I was doing was "time-since" style comparisons and ordering. Now I need to do full reports that show the actual datetime and of course, they're all stored at America/Chicago (the ...
I have a model Category which has a FK reference to itself.
How can i send the data to a template and make it look like this
Category 1
List item
List item
Category 2
List item
List item
...
With django 1.0.2 and Python 2.5, when I use the keyword DateField.input_formats, I get the error that __init__() got an unexpected keyword argument 'input_formats'. When I look in the __init__ file, I don't see input_formats as one of the acceptable keyword arguments.
I thought that input_formats had been around long enough that it sho...
One of my favorite features about python is that you can write configuration files in python that are very simple to read and understand. If you put a few boundaries on yourself, you can be pretty confident that non-pythonistas will know exactly what you mean and will be perfectly capable of reconfiguring your program.
My question is, ...
I know the link template to reach an object is like following:
"{{ domain }}/{{ admin_dir }}/{{ appname }}/{{ modelname }}/{{ pk }}"
Is there a way built-in to get a permalink for an object?
from django.contrib import admin
def get_admin_permalink(instance, admin_site=admin.site):
# returns admin URL for instance change page
...
How can I get Django 1.0 to write all errors to the console or a log file when running runserver in debug mode?
I've tried using a middleware class with process_exception function as described in the accepted answer to this question:
http://stackoverflow.com/questions/238081/how-do-you-log-server-errors-on-django-sites
The process_e...
Hi all,
I was wondering what you guys think about these two frameworks.
I'm going to build a turn-key solution for a vertical market and would like to offer both options: software as a service and give them the opportunity to host the app on their own. In other words I'd aim at having similar deployment options as Joel's FogBugz.
I'm ...
Upgraded my laptop to Ubuntu 9.04 and runing latest trunk of django and my test suite has tripled in time to run.
Python2.6
Mysql
Django 1.1 beta 1 SVN-10137
...