TypeError: can't subtract offset-naive and offset-aware datetimes

2013-11-03 Thread NHT
In poll app, I set Time_Zone='Asia/Kolkata' and USE_TZ=True in settings.py file. In models.py file, import datetime from django.utils import timezone from django.db import models class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date p

Custom User model admin log always adds Changed password record

2013-11-03 Thread John Zimmerman
Hey everyone, I created a custom User model and admin.py. I'm having as issue in the admin console where if I click save on a user, even without modifying any fields, the user history always adds a 'Changed password.' record. It looks like this used to be a problem ( https://github.com/django/dj

Re:

2013-11-03 Thread Lee Hinde
You want there to be only one BackgroundImage record marked as 'using_image' for a given user. I'm saying you should add a field to your User table that tracks their BackgroundImage. On Nov 3, 2013, at 2:43 PM, Aamu Padi wrote: > Thank you for the reply Lee. But could please elaborate a little

Re:

2013-11-03 Thread Aamu Padi
Thank you for the reply Lee. But could please elaborate a little more. :) On Mon, Nov 4, 2013 at 2:48 AM, Lee Hinde wrote: > > On Nov 3, 2013, at 12:23 PM, Aamu Padi wrote: > > > How to make a model with a yes/no field, if yes that particular object > (image) will be used as the background, an

Re:

2013-11-03 Thread Lee Hinde
On Nov 3, 2013, at 12:23 PM, Aamu Padi wrote: > How to make a model with a yes/no field, if yes that particular object > (image) will be used as the background, and no other image will be selected. > > I have come with this model: > > class BackgroundImage(models.Model): > user =

Model to select only 1 object from multiple objects

2013-11-03 Thread Aamu Padi
How to make a model with a yes/no field, if yes that particular object (image) will be used as the background, and no other image will be selected. I have come with this model: class BackgroundImage(models.Model): user = models.ForeignKey(user) caption = models.CharField(max_l

[no subject]

2013-11-03 Thread Aamu Padi
How to make a model with a yes/no field, if yes that particular object (image) will be used as the background, and no other image will be selected. I have come with this model: class BackgroundImage(models.Model): user = models.ForeignKey(user) caption = models.CharField(max_l

Re: Why serializer only works for QuerySet

2013-11-03 Thread Daniel Roseman
On Sunday, 3 November 2013 18:09:49 UTC, Leon Sasson wrote: > Django serializer works really well when you need to serialize a QuerySet, > but often times I need to serialize a JSON object with more than just a > QuerySet. > This leads me to serialize the QuerySet, and then load it again to a >

Re: Logging warnings inside settings.py

2013-11-03 Thread Arnold Krille
On Fri, 1 Nov 2013 10:11:05 -0700 Jon Dufresne wrote: > I am trying to log warnings inside settings.py. I want to log warnings > when settings (from an outside source) are not provided, but the > application can continue. Is this possible? It seems like this might > not work as logging requires se

Re: Django - How to combine queries in to one and display it in the template?

2013-11-03 Thread Arnold Krille
On Sun, 3 Nov 2013 18:31:42 +0530 Robin Lery wrote: > Suppose this is a model for an app Blog: > class Blog(models.Model): > And this is another model for an app Status: > class Status(models.Model): > How do I come up with something like this: > What I wan't is that, in the home page, I would

Re: Custom Admin Form for listing all url

2013-11-03 Thread Vanni Brutto
solved! Here the code: class NameURLForm(forms.ModelForm): class Meta: model = NameURL def __init__(self, *args, **kwargs): super(NameURLForm, self).__init__(*args, **kwargs) listURL = [] for name, L in get_resolver(None).reverse_dict.items(): i

Why serializer only works for QuerySet

2013-11-03 Thread Leon Sasson
Django serializer works really well when you need to serialize a QuerySet, but often times I need to serialize a JSON object with more than just a QuerySet. This leads me to serialize the QuerySet, and then load it again to a python dict and then serialize it again. Like this: peopleJSON = seri

Re: User names not support Unicode in 1.5

2013-11-03 Thread tim
I haven't looked into what would be required to allow unicode in usernames. If someone would like to dive in and write some documentation on how to do so that seems likely to be accepted as this has come up a couple times. On Thursday, October 31, 2013 2:46:43 AM UTC-4, Alex Strickland wrote: >

Poll app: Drop-down list is empty i.e not showing value even though I inserted values in Poll table

2013-11-03 Thread NHT
Hi, In poll app website, Select poll to change page my drop-down list is empty.While in Mysql command prompt when I do select * command it shows the tuples. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and

Re: Django - How to combine queries in to one and display it in the template?

2013-11-03 Thread pa xapy
> > write custom method on User model or custom template tag first one allow you to do something like: {% for item in user.get_what_you_need %} ... {% endfor %} and second one: {% get_what_you_need user %} -- You received this message because you are subscribed to the Google Groups "Django

Re: Django - How to combine queries in to one and display it in the template?

2013-11-03 Thread Johannes
what about deriving the Blog class from the Status class? | class Status(models.Model): content = BleachField() pub_date = models.DateTimeField(default=datetime.now) creator = models.ForeignKey(User)| |class Blog(Status): title= models.CharField(max_length=200)

Django - How to combine queries in to one and display it in the template?

2013-11-03 Thread Robin Lery
Suppose this is a model for an app Blog: class Blog(models.Model): title = models.CharField(max_length=200) pub_date = models.DateTimeField(default=datetime.now) creator = models.ForeignKey(User) content = BleachField() And this is another model for an app Status: class Status(mo

RE: Complex query reduction

2013-11-03 Thread Robin St . Clair
Hi You are running into typical production Django problems - works fine in testing, terrible in production. Firstly If you use attributed many-to-manys, create the table outside of Django and use raw SQL.Create a primary key on the two things being related (usually larger table first). Multi-colu

Re: Complex query reduction

2013-11-03 Thread akaariai
You should rewrite the query into a form that doesn't require distinct. In general, when you see a query that has joins and DISTINCT, that should be an alarm bell that something isn't written correctly in the query. Unfortunately Django's ORM generates such queries, and that isn't easy to fix a