Hi Guys,
I am currently working on an app that uses custom annotate querysets. Currently i have 2 urls setup, but i would need one for each field that the users would like to summarize data for. This could be configured manually, but it would violate DRY! I would basically have +-8 urls that basically do the same thing.
So here is wha...
One of my models has attributes that are not stored in the database. Everything is fine at the view and model level but I cannot seem to display these 'non-database' attributes in my template.
Here's some example code, an artificial example that mirrors the actual problem domain, to demonstrate the undesired behavior.
The view:
def o...
Hi there!
I have the following models, Art and ArtScore:
class Art(models.Model):
title = models.CharField()
class ArtScore(models.Model):
art = models.ForeignKey(Art)
date = models.DateField(auto_now_add = True)
amount = models.IntegerField()
Certain user actions results in an ArtScore entry, for instance whenever y...
Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like the following:
On model load: SELECT AES_DECRYPT(fieldname, password) FROM tablename
On model save: INSERT INTO tablename VALUES (AES_EN...
How do I get two distinct random records using Django? I've seen questions about how to get one but I need to get two random records and they must differ.
...
As soon as I add "from django.contrib.gis.db import models" instead of "from django.db import models", Django stops recognizing the app and gives this error:
Error: App with label location could not be found. Are you sure your INSTALLED_APPS setting is correct?
The error goes away as soon as I comment out "from django.contrib.gis.db i...
For Django 1.1.
I have this in my models.py:
class User(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
When updating a row I get :
[Sun Nov 15 02:18:12 2009] [error] /home/ptarjan/projects/twitter-meme/django/db/backends/mysql/base.py:84: Warning: Column 'crea...
I have multiple abstract models similar to this
Class Article(models.Model):
title = models.CharField()
body = models.TextField()
created_date = models.DateTimeField()
author_name = models.CharField()
class Video(models.Model):
title = models.CharField()
body = models.TextField()
created_date = models.DateTi...
Application:
This is a workshop proposal system for a conference. A user can create presenters and workshops, and link them together. Each user should only have access to the presenters and workshops that s/he created/owns.
# Models:
class Workshop(models.Model):
name = models.CharField(max_length=140, db_index=True)
presenter...
I'd like to create a feature for my Django app similar to Django admin's 'Recent Actions', in order to store history information on my other models.
For example say I have two models called Book and Author. I want to have a third model that stores information such as what action was performed on a given object in a model (add, modify, d...
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...
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...
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 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...
This is my form on models.py
class ItemForm(forms.Form):
itemname = forms.CharField(max_length=100)
itemwording = forms.CharField(max_length=100)
notes = forms.CharField()
abundance = forms.IntegerField(max_value=10)
collunit = forms.CharField(max_length=50)
litref = forms.CharField(max_length=100)
litkey = ...
I'm trying to accomplish something like this:
userSelectionIDs = [pref.selectionID for pref in UserColumnSelectionPreference.objects.filter(user=reqUser).all()]
selections = ColumnSelections.objects.filter(id.in_(userSelectionIDs)).filter(type=2).all()
Or, is there a better way for me to get that set of objects?
...
If a django model is made abstract, like below, is there a way to inspect the class to determine that it is abstract?
class MyModel(models.Model):
class Meta:
abstract = True
I would expect that I could examine MyModel.Meta.abstract, but according to Django docs:
Django does make one adjustment to the Meta class of an abstra...
Hi!
I have a simple model with news and categories:
class Category(models.Model):
name = models.CharField()
slug = models.SlugField()
class News(models.Model):
category = models.ManyToManyField(Category)
title = models.CharField()
slug = models.SlugField()
text = models.TextField()
date = models.DateTimeFie...
I'm working on a Django app that interacts with an existing database (think ERP/transaction type data) to perform analysis. There will be minimal/no updating of the existing database mainly reading data in. Its just a simple small setup so no replication etc. issues to think about re. updating.
The analysis would result in new records c...