Due to performance reasons I can't use the ORM query methods of Django and I have to use raw SQL for some complex questions. I want to find a way to map the results of a SQL query to several models.
I know I can use the following statement to map the query results to one model, but I can't figure how to use it to be able to map to relat...
I'm keeping track of a user status on a model. For the model 'Lesson' I have the status 'Finished', 'Learning', 'Viewed'. In a view for a list of models I want to add the user status. What is the best way to do this?
One idea: Adding the request to a models method would do the trick. Is that possible?
Edit: I meant in templatecode: {{ ...
Hey guys,
I'm a really tight schedule to code up a prototype for a website. I'm working with Django and am just starting out. Can you suggest open source Django snippets for the following:
1) A User Registration system (Registration/Authentication/Sessions)
2) A Rating System (Preferably a x/10 or 5 stars rating system)
3) A tags bas...
Hi, I am new to both django and python but I am beginning to get a grasp on things. I think.
I have this problem and I can not seem to find an answer to it. (Though I assume it is really simple and the limiting factors are my google skills and lack of python/django knowledge)
The scenario:
a user can opt in to recieve temporary job op...
Can I get the value of an object field some other way than "obj.field". Does something like "obj.get('field')" exist? Same thing for setting the value of the field.
...
I have a Django website in which I want site administrators to be able to edit rich content.
Suppose we're talking about an organizational info page, which might include some pictures, and some links, where the page is not as structured as a news page (which updates with news pieces every few days), but still needs the ability to be easi...
The default django 1.0.2 ManyToManyField widget (a multi-select) is difficult to use when there are a lot of things in the select box. Is there another widget available that gives a comma separated list of id's in a textarea? If this is not available what do I need to do to write one, and have it show up on ModelForm.as_p() and in the...
I am using appengine and appenginepatch for django
I have a class defined in my models that was inheriting from db.Model. I've now changed it to polymodel.PolyModel. Since making the change, my existing entities are no longer retrievable. Is there a way to access them or convert them?
Whats the recommended procedure for changing an ent...
Hey all,
Got a question. Say I have two models in a many-to-many relationship (Article, Publication). Article A is in Publication One, Two, and Three. I want to remove it from those publications and put it into Publication X. The django documentation covers deleting objects and adding objects, but I don't want to delete nor add objects,...
I'm trying to prepopulate a ModelForm and an inlineformset_factory with an instance of a Model, BUT when the user submits the form, I need to create a new instance of the Model and it's related child records.
Example Model:
class Artist(models.Model):
artist = models.CharField(max_length=100)
class Song(models.Model):
artist =...
I have model for example like this:
class Meeting(models.Model):
date = models.DateTimeField(default=datetime.datetime.now)
team = models.CharField(max_length=100)
class Meta:
verbose_name_plural = u'Meetings'
ordering = ['-date', 'team']
def __unicode__(self):
return u'%s %s' % (self.date, self...
I have something like this in models.py
class ZipCode(models.Model):
zip = models.CharField(max_length=20)
cities = City.objects.filter(zip=self).distinct()
class City(models.Model):
name = models.CharField(max_length=50)
slug = models.CharField(max_length=50)
state = models.ForeignKey(State)
zip = models.ManyToManyField(ZipCode)
Whe...
Now I have this code:
class Mymodel(models.Model):
xxxx_count = ForeignCountField(filter={'foreign_table__xxxx': True})
yyyy_count = ForeignCountField(filter={'foreign_table__yyyy': True})
zzzz_count = ForeignCountField(filter={'foreign_table__zzzz': True})
qqqq_count = ForeignCountField(filter={'foreign_table__qqqq': Tr...
Hello. I have what I'd thought would be a simple query, but it takes 'forever'. I'm not great with SQL optimizations, so I thought I could ask you guys.
Here's the query, with EXPLAIN:
EXPLAIN SELECT *
FROM `firms_firmphonenumber`
INNER JOIN `firms_location` ON (
`firms_firmphonenumber`.`location_id` = `firms_location`....
Is this the only way to create custom model validation? To do it using the forms? What if I want to send data to the database through means other than forms?
...
I am designing a fairly complex database, and know that some of my queries will be far outside the scope of Django's ORM. Has anyone integrated SP's with Django's ORM successfully? If so, what RDBMS and how did you do it?
...
I have three models, simplified for the example:
class Customer(models.Model):
email = models.CharField(max_length=128)
class Order(models.Model):
customer = models.ForeignKey(Customer)
order_status = models.CharField(blank=True, max_length=256)
class Lineitem(models.Model):
order = models.ForeignKey(Order)
quantit...
I was wondering if it was possible (and, if so, how) to chain together multiple managers to produce a query set that is affected by both of the individual managers. I'll explain the specific example that I'm working on:
I have multiple abstract model classes that I use to provide small, specific functionality to other models. Two of t...
I have a model that has an ImageField. How can I manually assign an imagefile to it? I want it to treat it like any other uploaded file...
...
Say for example I have a Blog app that I want to be able to drop into different projects, but I always want the Blog to be associated with some other model. For example, in one case I may want it to be associated with a user:
site.com/someuser/blog
But on another site I want it to be associated with, say, a school:
site.com/someschool...