I have the following 2 models:
class Job(models.Model):
title = models.CharField(_('title'), max_length=50)
description = models.TextField(_('description'))
category = models.ForeignKey(JobCategory, related_name='jobs')
created_date = models.DateTimeField(auto_now_add=True)
class JobCategory(models.Model):
title = m...
If there are models as below:
class Donation(models.Model):
user = FKey(User)
project = FKey(Project)
...
class Campaign(models.Model):
user = Fkey(User)
project = FKey(Project)
...
class Project(models.Model)
...
What is the simplest django ORM query to find a list of all projects that a give...
I'm attempting to take 4-5 fields from a large django form and display them on the thanks page.
I want to disply the values with a good degree of control, as i'll be building an iFrame with parameterd querystrings based on the form inputs.
Currently I have:
forms.py ----
-*- encoding: utf-8 -*-
from django import forms
from django.fo...
I have an unusual problem: I have to convince my superiors to use Django for our new project. Alternative is some PHP framework. I've programmed in PHP for 2 years and then switched to Python and have about 3 years of experience in it. However I'm not too good in business speech.
I know all the technical pros and cons but when it comes...
I love how Django performs form validation. However, I want to override the way the errors get displayed. I want to send form validation errors to the top of my web page (to a specific div tag) instead of letting Django display errors next to the form fields that are invalid. Any suggestions?
...
I would like to be able to reorder lists of Models via a jQuery script.
I already have reordering within inLines on the Model update page, but I'd like to add it to the change_list page aswell?
Is this possible? I'm using Django 1.1 so have access to action sheets, if that makes things easier...
Any information would be appreciated.
...
I have ipython installed, I want to run a plain python interpreter instead with manage.py shell.
So I try,
python2.5 manage.py shell --plain
Which gave me an error, and text which suggest that --plain was passed to ipython
So I read, http://docs.djangoproject.com/en/dev/ref/django-admin/
which suggets
django-admin.py shell --plai...
From AuditTrail, I have this model definition:
from django.db import models
import audit
import random
def some_callback(instance):
return `random.randrange(1, 99)` + 'trackable_val'
class Person(models.Model):
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
salary = models....
I'm trying to use the django-voting tutorial from this blog:
http://new.justinlilly.com/blog/2008/nov/04/django-voting-a-brief-tutorial/
to get a simple up/down voting system working on an app of mine. But just like the first commenter from that post, this code in urls.py:
urlpatterns = patterns('',
url(r'^(?P[-\w]+)/(?Pup|down|clear...
I have an urls.py with this line:
url(r'^logout/$', 'django.contrib.auth.views.logout', name="auth_logout"),
In my template tag i have this line:
<a href="{% url auth_logout %}">Logout</a>
Now, I would like to add the next_page param to the url templatetag, but I can't get it to work. I have tried this:
{% url auth_logout request....
I am filling my form with initial data using the normail:
form = somethingForm(initial = {
'title' : something.title,
'category' : something.category_id,
})
The title works fine, but if the category is a ModelChoiceField and a ForeignKey in the model, the init...
Hey all,
I have an issue where a particular modelform whose object is a many-to-many field pulls up the first entry there by default when passed to a modelformset_factory. An example follows:
Say I have an Order object that has a many-to-many relationship with a Group. I have a form whose only editable field is a single input box with ...
I'm working on a blogging application, and trying to made just a simple RSS feed system function. However, I'm running into an odd bug that doesn't make a lot of sense to me. I understand what's likely going on, but I don't understand why. My RSS Feed class is below:
class RSSFeed(Feed):
title = settings.BLOG_NAME
description = ...
I want to write a very small Django application in a single file, requiring all the appropriate modules and stuff, and then be able to run that as a normal Python script, like this:
$ python myapp.py
You can assume I won't render HTML, so I don't need templates (I'll return JSON or some other auto-generated string).
...
I am trying configure a Django application to use mysql.
I want to use the mysql server available in my network and don't want to install a local copy.
But when I am trying to install mysqldb it needs mysql_config from Mysql!
What should I do if I want to use the mysql server in another machine?
sh: mysql_config: command not found
Tr...
I have a list of db columns that are in a particular order. Those columns are passed to a queryset and will be made into an aggregate:
for field in columns.as_list():
if field in AGG_FIELDS:
args.append(Sum(field))
overall_totals = MyModel.objects.filter(user=request.user).aggregate(*args)
This works fine, except that the...
I'm trying to build out a Google News Sitemap in addition to a normal sitemap.xml to avoid having to put additional numerical characters in my URLs.
I've build out the sitemap.xml using Django's contrib system and it works great, but I'm having trouble passing the context to the (unverified) patch updating the framework to gererate a ne...
I'd like to get the values in class variables like list_display and list_filter from a view. Something like:
def some_view():
print Order.list_display
...
...
A colleague got this error message when trying to use MySQLdb from Django:
[...]
ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured:
Error loading MySQLdb module: dlopen(/Users/roy/.python-eggs/MySQL_python-1.2.3c1-py2.5-macosx-10.5-i386.egg-tmp/_mysql.so, 2):
Symbol not found: _my...
I need to create a cross-site template object which will check the current time and return either one string if it's within a time range specified in a model or another or blank in all other cases.
Seems simple, but I wonder what is the best approach here? Also, there are a few other considerations:
the string should be editable
the d...