I'm trying to create a django database that records all my comic purchases, and I've hit a few problems. I'm trying to model the relationship between a comic issue and the artists that work on it.
A comic issue has one or more artists working on the issue, and an artist will work on more than a single issue. In addition, the artist has ...
I have something like:
MEDIA_ROOT = '/home/httpd/foo/media/'
MEDIA_URL = 'http://www.example.org/media/'
(...)
file = models.FileField(upload_to='test')
When I create an object with that field in the admin page Django stores in the DB the full file path, like: "/home/httpd/foo/media/test/myfile.pdf". This is contrary to what says i...
I'm just beginning to learn Django and I would like to use different queryset in a ModelChoiceField.
I have 3 models like that :
class Politic(models.Model):
name = models.CharField(max_length=100)
class Economic(models.Model):
name = models.CharField(max_length=100)
class Category(models.Model):
politic = models.ForeignKey(Politic,...
Hi
This can't be hard, but... I just need to get the most recent three objects added to my database field.
So, query with reverse ID ordering, maximum three objects.
Been fiddling round with
Records.objects.order_by(-id)[:3]
Records.objects.all[:3]
and including an if clause to check whether there are actually three objects:
n...
For example, lets say you want to create a ModelForm for Supervisor that also allows you to create or update 3 or more Underlings in the same form.
from django.db import models
class Supervisor(models.Model):
name = models.CharField(max_length=100)
class Underling(models.Model):
supervisor = models.ForeignKey(Superisor, related...
I'm using Django (specifically django-admin) to be the admin panel for a site that uses PHP for client-facing features. I've been messing around making the admin look exactly the way I want and so far so good. However, I've run into a few problems that I need solving.
Here's the models that I'm working with:
class Permissions(models.Mo...
Can't pickle <class 'authorize.models.User_Deferred_'>: attribute lookup authorize.models.User_Deferred_ failed
I get this if use session with db. What this mean?
...
I'm implementing a basic forum app. I would like to sort the questions by their last reply time.
I have the following line:
questions = Question.objects.filter(deleted=False).order_by("last_comment__created_at")
However, this query ignores the new questions with no answers. What would be the best way to fix this without creating a...
I have two models, EqTD (EquivalentTextDescription) and location. EqTD has a manytomany relation to location. I need to produce a list of all EqTDs ordered by location name ('name' is a field in the location model). I'm getting the queryset of EqTDs thus:
tEqTDs = EqTD.objects.order_by('location__name')
which I'm hoping will produce d...
Does anyone know how to get Django and Subversion to work together on Dreamhost?
I've been following this tutorial to install Django (which uses Passenger WSGI):
http://wiki.dreamhost.com/Django
After I got Django to work, Subversion stopped working. Has anyone ran into this problem?
...
Hi,
I am trying to save a modelform that represents a bank account but I keep getting a ValueError even though the form appears to validate. The models I have to use are:
class Person(models.Model):
name = models.CharField()
class Bank(models.Model):
bsb = models.CharField()
bank_name = models.CharField()
def __uni...
I'm making a game link site, where users can post links to their
favorite web game.
When people post games they are supposed to check what category the
game falls into.
I decided to allow many categories for each game since some games can
fall into many categories.
So the question is, how do I handle this in my view?
And how can I...
What's the correct way to do an ajax request, I've seen people using a returning render_to_string so that they can do all their formatting within python using the template language. eg~
return render_to_string('calendar.html', {
'self' : self,
'month' : self.today.month,})
with this as the javascript:
$('#django_calendar_response').h...
Hello,
I am running Django with mod_python on a Red Hat Linux box in production. A little while ago, for a reason unknown to me, the admin stopped working, throwing a 500 error. The error is as follows:
ValueError at /admin/
Empty module name
Request Method: GET
Exception Type: ValueError
Exception Value:
Empty module name
Exception L...
I'm teaching myself some Django tonight using the local dev package at instantdjango.com
I made it through half the tutorial, building a basic map with points on it, then closed out of the console for a bit. I just fired it back up and now when I try to use notepad++ to edit files, console tells me it doesn't recognize the command. Wh...
I'm working on a Django project. Let's call it myproject. Now my code is littered with myproject.folder.file.function. Is there anyway I can remove the need to prefix all my imports and such with myproject.? What if I want to rename my project later? It kind of annoys me that I need to prefix stuff like that when the very file I'm import...
I have a set of forms (lets say formA,formB,formC) on a page that collects data and exposes different fields depending on which form is used. These forms have different underlying processing logic (and client-side logic) but have the same model
If formA is submitted,I noticed that a form.validationerror raised in formA's clean method th...
I have the following Django models: -
class Company(models.Model):
name = models.CharField(max_length=50)
is_active = models.BooleanField(db_index=True)
class Phase(models.Model):
company = models.ForeignKey(Company)
name = models.CharField(max_length=50)
is_active = models.BooleanField(db_index=True)
class Proces...
Not sure how to phrase question, but here goes.
Say i have a table of events, and each event links to a object using a generic foreign key.
I dont want to show two events that link to the same foreign object, only the most recent event out of those which link to the same object.
Can anyone give any hints?
...
Say we have a dvd table where we want to search for price=14.99 and rating=18. We could do:
#Making some dictionary
dict1 = {}
#Adding some stuff
dict1['price']=14.99
dict1['rating']18
#Use dict as filter
dvd.objects.filter(**dict1)
Is there a way to add on extra parameters like:
dvd.objects.filter(title__icontains='the')
I'd jus...