I'm working in a bilingual project (es/en); for this project I've chosen to use django's i18n internationalization system (and I'm starting to regret it...)
Today's problem is the following:
for some models, my database stores information like description and es_description, or english_common_name and spanish_common_name (these are att...
Hi
I have a complex django object, which has properties of other class types. This gets like this:
class Order:
contractor - type Person
some other fields....
In my form I'd like to be able to either choose existing Person object from the dropdown or add a new one with a form. I've managed to create forms and appropriate workfl...
Utterly stuck trying to update a ManyToManyField field on POST and save.
Models.py
class Location(models.Model):
place = models.CharField(max_length=100)
inuse = models.BooleanField()
class Booking(models.Model):
name = models.CharField(max_length=100, verbose_name="Your name")
place = models.ManyToManyField(Location, ...
I use the following code to select popular news entries (by date) from the database:
popular = Entry.objects.filter(type='A', is_public=True).extra(select = {'dpub': 'date(dt_published)'}).order_by('-dpub', '-views', '-dt_written', 'headline')[0:5]
To compare the execution speeds of a normal query and this one I ran the following mysq...
Hey,
I am working with Django for a while and now that my "tree" and whole DB is filled with data (note: existing database), I was wondering if the "one model per table" is really better at this point than "one model per select".
I have got one table - objtree. This is the place where I have all nodes (brands, categories, tags, etc.) ...
I think this is easiest to understand as an example:
I have models Image and ImageType, where and image has exactly one type. The parameters in ImageType would regulate image size, thumbnail size, etc., as photo gallery images might display differently from, say, profile pictures.
I want profile images and gallery images to appear as s...
Hello,
I have two Django sites: one for development and one for production. Every once in a while, the data from the development database needs to be transferred to the production database or the other way around. I use postgresql.
This works fine: I empty the tables from the database I want to copy to, I generate sql from the applicab...
Is there a way to add a custom error message to a model field without declaring it in the form as a form field? Is this possible?
I don't want to declare the field again, for example
class MyModel(models.Model):
test = models.URLField(max_length = 200)
class MyForm(forms.ModelForm):
test = forms.URLField(max_length = 200, err...
I've been searching for an elegant way to represent a multi-select weekday field (Mon, Tues, Wed...) in a Django model. I was initially thinking of going integer field using bitwise math but I am not sure if this would be the way to go.
This would be a mostly-read field. I would want the Queryset method to be something like Entry.object...
Django, What's the best ,fastest way to get only first and last element from something, Customer.objects.xxxx such filter, value_list or ...
...
Hello Guys, I've tried the following with no success:
Match.objects.filter(sendDate__gte=dateToStats).values("sendDate__day").annotate(perDay=Count("id")).order_by()
Fails with:
Cannot resolve keyword 'sendDate__day' into field.
Where sendDate is a DateTime field, and dateToStats is just a certain date I'm filtering. I'm intereste...
Hi.
I am trying to resize an image before it gets saved. I am using a custom save method on the model, but I've hit a snag.
This is the code I have now:
class UserImages(models.Model):
height = models.CharField(blank=True, max_length=100)
width = models.CharField(blank=True, max_length=100)
image = models.ImageField(upload_...
How can I ONLY the categories where there is at least one "Post" related??, hope it makes sense!?
**models.py**
class Category(models.Model):
name = models.CharField(max_length=50)
def __unicode__(self):
return self.name
class Post(models.Model):
name = models.CharField(max_length=50)
categories = models.ManyToManyFie...
So i have one model with list of all item i have.
And other model which has Foreign-Key to to my main model... How to Make query set object. Of all items from first model which contain my second model?
class Music(models.Model):
name=models.CharField()
duration=models.IntegerField()
class Playlist(models.Model):
misic=mode...
Hi, I've hit a bit of a wall when trying to add data to a UserProfile model created to hold user info beyond what is catered for in django's built in Auth component.
My question is how do I get an instance of the user just registered in order to create the the UserProfile? I thought it would be something like below:
# Registration for...
This code:
import datetime
d_tomorrow = datetime.date.today() + datetime.timedelta(days=1)
class Model(models.Model):
...
timeout = models.DateTimeField(null=True, blank=True, default=d_tomorrow)
...
resuls in this error:
'datetime.date' object has no attribute 'date'
What am I doing wrong?
...
Alright, I have a fairly simple design.
class Update(models.Model):
pub_date = models.DateField()
title = models.CharField(max_length=512)
class Post(models.Model):
update = models.ForeignKey(Update)
body = models.TextField()
order = models.PositiveIntegerField(blank=True)
class Media(models.Model):
post = mode...
I have a model in django that I want to update only, that is, when I call it and set the data, it will not create a new record, only update the existing one. How can I do this? Here is what I have:
class TemperatureData(models.Model):
date = models.DateTimeField()
value = models.PositiveIntegerField()
alert = models.Boole...
If a model exist like
class Empprofile(models.Model):
name= models.CharField(max_length=255)
group = models.CharField(max_length=255)
description = models.CharField(max_length=1024)
class Details(Empprofile):
address1=models.CharField(max_length=255)
address2=models.CharField(max_lengt...
Hello,
I would like to implement multicolumns primary keys in django.
I've tried to implement an AutoSlugField() which concatenate my columns values(foreignkey/dates) ...
models.py :
class ProductProduction(models.Model):
enterprise = models.ForeignKey('Enterprise')
product = models.ForeignKey('Product')
date = models.Dat...