Hi folks,
I'm trying to find a way to filter down rows of objects within Django Admin, using a queryset.
e.g. Person.objects.filter(Q(name='John')|Q(surname='Doe'))
I'm finding quite complicated to figure out.
Any ideas?
...
Just wondering if its possible to set a default tablespace in postgres to keep indexes. Would like the databases to live on the default tablespace for postgres, however, would like to get the indexes on a different set of disks just to keep the i/o traffic separated.
It does not appear to me that it can be done without going in and doi...
let's assume that I have very basic model
class Message(models.Model):
msg = models.CharField(max_length=30)
this model is registered with admin module:
class MessageAdmin(admin.ModelAdmin):
pass
admin.site.register(Message, MessageAdmin)
Currently when I go into the admin interface, after clicking "Add message" I have on...
Hi folks,
I'm trying to spit out a django page which lists all entries by the year they were created. So, for example:
2010:
Note 4
Note 5
Note 6
2009:
Note 1
Note 2
Note 3
It's proving more difficult than I would have expected. The model from which the data comes is below:
class Note(models.Model):
business = models.Forei...
In my Django project, I have a non-abstract parent model defined as follows:
class Parent(models.Model):
classType = models.CharField(editable=False,max_length=50)
and, say, two children models defined as follows:
class ChildA(Parent):
parent = models.OneToOneField(Parent,parent_link=True)
class ChildB(Parent):
parent = ...
My models:
class Order(models.Model):
ordered_by = models.ForeignKey(User)
reasons = models.ManyToManyField(Reason)
class Reason(models.Model):
description = models.CharField()
Basically a user creates an order and gives reasons for that order. ie, john has two orders (one for pencils because he is out AND because he doesn...
I've a large number of models (120+) and I would like to let users of my application export all of the data from them in XML format.
I looked at django-piston, but I would like to do this with minimum code. Basically I'd like to have something like this:
GET /export/applabel/ModelName/
Would stream all instances of ModelName in applab...
I have the same conundrum as presented in this question, but applied to Django's auth.User.
I have this proxy model:
class OrderedUser(User):
def __unicode__(self):
return self.get_full_name()
class Meta:
proxy=True
ordering=["first_name", "last_name"]
And some of my other models use an OrderedUser i...
I have a problem with needing to provide multiple model backed forms on the same page. I understand how to do this with single forms, i.e. just create both the forms call them something different then use the appropriate names in the template.
Now how exactly do you expand that solution to work with modelformsets? The wrinkle, of cour...
Is there a better way of doing something like this:
if status == 1:
mymodel.drafted_date = date.today()
if status == 2
mymodel.registered_date = date.today()
if status == 3
mymodel.reported_date = date.today()
if status == 4
mymodel.checked_date = date.today()
if status == 5
mymodel.end_date = date.today()
I though...
hi
I have extended the user model and added extra fields to it i.e "latitude" "longitude" and status and than save it. up to here it works fine. but i want to allow the user to change his/her "latitude" "longitude" whenever he/she needs like the hotmail and yahoo allows change account feature. in my case the user only wants to chage th...
I have a database that was already being used by other applications before i began writing a web interface with django for it. The table names follow simple naming standards, so the django model Customer should map to the table "customer" in the db. At the same time I'm adding new tables/models. Since I find it cumbersome to use app_cust...
I have model, Match, with two foreign keys:
class Match(model.Model):
winner = models.ForeignKey(Player)
loser = models.ForeignKey(Player)
When I loop over Match I find that each model instance uses a unique object for the foreign key. This ends up biting me because it introduces inconsistency, here is an example:
>>> def print...
I have a model with two image fields, a source image and a thumbnail.
When I update the new source image, save it and then try to read the source image to crop/scale it to a thumbnail I get an "I/O operation on closed file" error from PIL.
If I update the source image, don't save the source image, and then try to read the source image ...
I have a problem with my accented characters. Django admin saves my data without encoding to something like "á"
Example: if im trying to use a word like "Canción", i would like it to save in this way: Canción, and not Canción.
i have in my SETTING: DEFAULT_CHARSET = 'utf-8'
i have in my mysql database: utf8_general_ci
I...
I have these 2 models:
genre = (
('D', 'Dramatic'),
('T', 'Thriller'),
('L', 'Love'),
)
class Book(models.Model):
title = models.CharField(max_length=100)
genre = models.CharField(max_length=1, choices=genre)
class Author(models.Model):
user = models.ForeignKey(User, unique=True)
born = models.DateTimeF...
The Django documentation gives en example like so:
b = Blog.objects.get(id=1)
b.entry_set.all()
Which from what I understand results in 2 queries. What if I wanted to get the blog, the blog entries and all the comments associated with that entry in a number of queries that does not depend on the number of entries? Or do I have to drop...
Is there a neat way to make the record/object count for a model appear on the main model list in the django admin module?
I have found techniques for showing counts of related objects within sets in the list_display page (and I can see the total in the pagination section at the bottom of the same), but haven't come across a neat way to ...
I saw the next two method on old question here but it is not clear for me what is the difference between:
{'date_time_field__range': (datetime.datetime.combine(date, datetime.time.min),
datetime.datetime.combine(date, datetime.time.max))}
and
YourModel.objects.filter(datetime_published__year='2008',
...
Is it possible to register a model in django-tagging not in tagging app, nor in my app?
The standard way is to edit apps/myapp/models.py this way:
from apps import tagging
tagging.register(MyModel)
I want to keep both applications without changes, for example, to be able to pull new versions and just replace them. So I tried putting ...