Setting tzinfo for DateTimeFields with Postgresql - workaround

2009-05-16 Thread Glenn Maynard
This is just a quick hack for anyone else bit by this: tzinfo is never set when reading DateTimeFields out of the database, at least with Postgresql. Now, I have no idea why anyone would want to set TIME_ZONE to anything but UTC (and the default of an arbitrary US timezone is rather bizarre), but

Re: displaying image in a template

2009-05-16 Thread newbie
according to the link http://docs.djangoproject.com/en/dev/howto/static-files/ site_media is the URL where your media will be rooted and The file / path/to/media/foo.jpg will be made available at the URL /site_media/ foo.jpg. so i thought the file which is at

check_constraints module error

2009-05-16 Thread lokeshmaremalla
Hi All, I am trying to add check constraints to my table and i was ended with the below error. I got this statement "from check_constraints import check" from django doc site. (http://code.google.com/p/django-check-constraints/wiki/Features) Please guide me if I am missing any thing while

Re: quickest way to print template names

2009-05-16 Thread Alex Gaynor
On Sat, May 16, 2009 at 11:14 PM, mickey wrote: > > Ok this doesn't sound too intuitive. If anyone else have a better > solution please do post. > > Thanks. > > On May 16, 8:01 pm, Alex Gaynor wrote: > > On Sat, May 16, 2009 at 9:57 PM, mickey

Re: quickest way to print template names

2009-05-16 Thread mickey
Ok this doesn't sound too intuitive. If anyone else have a better solution please do post. Thanks. On May 16, 8:01 pm, Alex Gaynor wrote: > On Sat, May 16, 2009 at 9:57 PM, mickey wrote: > > > So are you telling me to pass the template name for

Implementing A/B Testing in Django

2009-05-16 Thread John Boxall
I've got a new home page and I'd like to test it's performance in getting users to sign up compared to my existing home page. In Django terms I have two templates that I would like my existing view to alternate between - I want to make whatever template the viewer sees "sticky" - they see the

django twisted model

2009-05-16 Thread Timboy
I am looking to make a webmail client proof of concept in django. I ran across twisted mail and this post: http://clemesha.org/blog/2009/apr/23/Django-on-Twisted-using-latest-twisted-web-wsgi/ showing how to use django on twisted. Can anyone point me in the right direction for actually getting

Re: please help me

2009-05-16 Thread Eric Abrahamsen
On May 17, 2009, at 1:26 AM, Apple wrote: > > I write some code like following: > > #coding=utf8 > from django.shortcuts import render_to_response > from django.http import *

Re: quickest way to print template names

2009-05-16 Thread Alex Gaynor
On Sat, May 16, 2009 at 9:57 PM, mickey wrote: > > So are you telling me to pass the template name for each and every > functions i define in views.py? > > > > Yes, the best way would probably be to write a wrapper function around render_to_response that took the template

Re: quickest way to print template names

2009-05-16 Thread mickey
So are you telling me to pass the template name for each and every functions i define in views.py? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: django.contrib.auth tests fail

2009-05-16 Thread Luc Saffre
On 13.05.2009 18:55, Michael wrote: > Auth leans on some templates in django.contrib.admin for the tests. This > is known, though not ideal. If you added django.contrib.admin to your > installed apps, the failures should go away. > > I hope that helps, > Michael Thanks! That helped. And I

Re: Formatting a Foreign key combo box in admin change form

2009-05-16 Thread Sam Chuparkoff
On Fri, 2009-05-15 at 15:12 -0700, nih wrote: > in the admin change form the select box only shows name.username (eg > nih) > is it possible to show the full name in the select box You are looking to override label_from_instance(). See here

Re: Integer Max/Min Values

2009-05-16 Thread Sam Kuper
2009/5/17 sampablokuper > I've been encountering the same problem. It's especially frustrating > because it seems model validation used to be much easier in Django > (see > http://www.cotellese.net/2007/12/11/adding-model-field-validation-to-the-django-admin-page/ >

Re: Filtering contrib.comments on related object property?

2009-05-16 Thread Alex Gaynor
On Sat, May 16, 2009 at 8:26 PM, ringemup wrote: > > > For the reference of anyone who comes across this in the future, you > have to fetch the related model IDs as a list, like so: > > Entry.objects.filter(category="some category").values_list('id', > flat=True) > > > On May

Re: Integer Max/Min Values

2009-05-16 Thread sampablokuper
On May 17, 12:07 am, Daniel Roseman wrote: > On May 16, 11:32 pm, ajohnsen wrote: > > I am trying to assign max_value and min_value to a > > PositiveIntegerField in my model but am getting the error: > > > year_built =

Re: Filtering contrib.comments on related object property?

2009-05-16 Thread ringemup
For the reference of anyone who comes across this in the future, you have to fetch the related model IDs as a list, like so: Entry.objects.filter(category="some category").values_list('id', flat=True) On May 16, 7:24 pm, ringemup wrote: > Thanks -- that was exactly the

Re: Filtering contrib.comments on related object property?

2009-05-16 Thread ringemup
Thanks -- that was exactly the sort of thing I was looking for! Just couldn't figure out how to do it. > > Comment.objects.filter(content_type=ContentType.objects.get_for_model(Entry), > object_pk__in=Entry.objects.filter(category="some category")). >

Re: What data structure to use, and how?

2009-05-16 Thread jon michaels
Works like a charm. Thanks a lot Alex, it saves me a lot of searching and trying. On Sun, May 17, 2009 at 2:37 AM, Alex Gaynor wrote: > > > On Sat, May 16, 2009 at 4:52 PM, Jon wrote: > >> >> >> Hi all. >> >> I think django really rocks, but i have

Re: displaying image in a template

2009-05-16 Thread Daniel Roseman
On May 16, 9:19 pm, newbie wrote: > Hi, > >          Thanks for your immediate  reply. I've seen the document and > followed the steps in it already. But was not able achieve any > progress. In > > (r'^site_media/(?P.*)$', 'django.views.static.serve', > {'document_root':

Re: Integer Max/Min Values

2009-05-16 Thread Daniel Roseman
On May 16, 11:32 pm, ajohnsen wrote: > Hello, > > I am trying to assign max_value and min_value to a > PositiveIntegerField in my model but am getting the error: > > year_built = models.PositiveIntegerField(min_value=1800, > max_value=2100) > TypeError: __init__() got an

Re: Form trouble

2009-05-16 Thread Daniel Roseman
On May 16, 10:51 pm, Alex Gaynor wrote: > On Sat, May 16, 2009 at 4:49 PM, zayatzz wrote: > > > Hello > > > Been trying to figure out where the problem is, but its almost 1am and > > im out of ideas. > > > i have this model: > > class tuser

Re: What data structure to use, and how?

2009-05-16 Thread Alex Gaynor
On Sat, May 16, 2009 at 4:52 PM, Jon wrote: > > > Hi all. > > I think django really rocks, but i have a question: > > I wrote a script in python that will get some values from servers and > puts in them in a dictionary. > > The data is in the following format > {'somehost':

What data structure to use, and how?

2009-05-16 Thread Jon
Hi all. I think django really rocks, but i have a question: I wrote a script in python that will get some values from servers and puts in them in a dictionary. The data is in the following format {'somehost': ['yes', '2'], 'remotehost': ['yes', '1'], 'localhost': ['yes', '1']} In python, i

Integer Max/Min Values

2009-05-16 Thread ajohnsen
Hello, I am trying to assign max_value and min_value to a PositiveIntegerField in my model but am getting the error: year_built = models.PositiveIntegerField(min_value=1800, max_value=2100) TypeError: __init__() got an unexpected keyword argument 'max_value' Here is the model: from django.db

Re: Filtering contrib.comments on related object property?

2009-05-16 Thread Alex Gaynor
On Sat, May 16, 2009 at 5:28 PM, ringemup wrote: > > Contrib.comments references related object primary keys instead of the > objects themselves, so is there any easy way to filter comments on a > property of the related model? For instance, if I have a blog and > want to

Filtering contrib.comments on related object property?

2009-05-16 Thread ringemup
Contrib.comments references related object primary keys instead of the objects themselves, so is there any easy way to filter comments on a property of the related model? For instance, if I have a blog and want to retrieve all comments for entries in Category X, is that possible through the

Re: Form trouble

2009-05-16 Thread Alex Gaynor
On Sat, May 16, 2009 at 4:49 PM, zayatzz wrote: > > Hello > > Been trying to figure out where the problem is, but its almost 1am and > im out of ideas. > > i have this model: > class tuser (models.Model): >username = models.CharField(max_length=20,

Form trouble

2009-05-16 Thread zayatzz
Hello Been trying to figure out where the problem is, but its almost 1am and im out of ideas. i have this model: class tuser (models.Model): username = models.CharField(max_length=20, help_text="Enter Username of your account") email = models.EmailField(max_length=100,

Re: how to refer a foreign key to a non primary column from other model

2009-05-16 Thread Antoni Aloy
2009/5/16 : > > Hi All, > > Need help in creating foreign key column in a table. > > In the below model I would like to create a foreign key for the field > 'new_foreign_col' which should refer to 'username' column (non primary > column) from auth_user table. > > class

Re: Problem debugging with pdb

2009-05-16 Thread sadach
On May 16, 9:07 am, Joshua Russo wrote: > Does anyone know what the constraints > are to using the break command within pdb? Autoreload spawns a new python interpreter. Nothing survives. So don't use autoreload. Another caveat: if you try to set a breakpoint and pdb

Re: referencing the object id from clean validation methods

2009-05-16 Thread Ramiro Morales
On Sat, May 16, 2009 at 5:18 PM, Alex Gaynor wrote: > > > On Sat, May 16, 2009 at 3:03 PM, simon101 wrote: >> >> Hi >> >> I am using ModelForms to create forms from the models [...] >> but  it doesn't contain the id >> for the object id for the object

Re: displaying image in a template

2009-05-16 Thread newbie
Hi, Thanks for your immediate reply. I've seen the document and followed the steps in it already. But was not able achieve any progress. In (r'^site_media/(?P.*)$', 'django.views.static.serve', {'document_root': '/path/to/media'}), does site_media mean the directory in which the

Re: referencing the object id from clean validation methods

2009-05-16 Thread Alex Gaynor
On Sat, May 16, 2009 at 3:03 PM, simon101 wrote: > > Hi > > I am using ModelForms to create forms from the models, and using the > clean_field and clean methods to validate the fields and form data as > a whole. I get the self.cleaned_data[] dictionary which contains all >

referencing the object id from clean validation methods

2009-05-16 Thread simon101
Hi I am using ModelForms to create forms from the models, and using the clean_field and clean methods to validate the fields and form data as a whole. I get the self.cleaned_data[] dictionary which contains all the cleaned up data from the html form, but it doesn't contain the id for the

Re: displaying image in a template

2009-05-16 Thread Daniel Roseman
On May 16, 7:37 pm, newbie wrote: > Hi, > >          I want to display an image from static files directory in a > template. The name of the image is stored in a variable(say image). > When i try to display it in the template using img tag( src = > {{ image }} ), its not

displaying image in a template

2009-05-16 Thread newbie
Hi, I want to display an image from static files directory in a template. The name of the image is stored in a variable(say image). When i try to display it in the template using img tag( src = {{ image }} ), its not displayed. Can someone help me in this regard. Thanks, nazgi.

please help me

2009-05-16 Thread Apple
I write some code like following: #coding=utf8 from django.shortcuts import render_to_response from django.http import * from django.contrib.auth.models import User from

Re: ManyToMany field and limit_choices_to

2009-05-16 Thread adrian
pilot error, no need to reply On May 16, 10:41 am, adrian wrote: > I am creating a view to edit a model that has a ManyToMany field. > The field is defined as: > > performer = models.ManyToManyField(Entity, limit_choices_to= > {'role__exact':'PER'}) > > Entity is a table of

Re: how to refer a foreign key to a non primary column from other model

2009-05-16 Thread Joshua Russo
"I apologize" that is On May 16, 3:04 pm, Joshua Russo wrote: > Ok, apologize. I just tried it myself and MySQL did accept the alter > table. It is certainly not an operation that I have been able to > perform in MS SQL Server or Oracle, though I wonder if it's

Re: quickest way to print template names

2009-05-16 Thread Alex Gaynor
On Sat, May 16, 2009 at 11:39 AM, mickey wrote: > > Hi > > Does anyone know the fastest way I can print the template name on a > template? > > Perhaps something like {% template_name %} > > Thanks. > > > The current template name isn't in the templates context unless you

quickest way to print template names

2009-05-16 Thread mickey
Hi Does anyone know the fastest way I can print the template name on a template? Perhaps something like {% template_name %} Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to

Re: Why getting message object not iterable?

2009-05-16 Thread Karen Tracey
On Sat, May 16, 2009 at 12:07 PM, pradyumna wrote: > > I am a newbie to Django.. I am wondering why I am getting 'Caught an > exception while rendering: 'Car' object is not iterable? > > As per my understanding, in the template, if statement should not be > true and

Re: Why getting message object not iterable?

2009-05-16 Thread Alex Gaynor
On Sat, May 16, 2009 at 11:07 AM, pradyumna wrote: > > I am a newbie to Django.. I am wondering why I am getting 'Caught an > exception while rendering: 'Car' object is not iterable? > > As per my understanding, in the template, if statement should not be > true and

Re: apache/mod_python set up

2009-05-16 Thread wmstudio
I found the answer mysel. Besides having: SetHandler None I also needed the same for /edia which was symlinked from: /usr/local/ lib/python2.5/site-packages/django/contrib/ So now the complete (and working) file reads: # wms.conf Listen 192.168.1.62:80 ServerAdmin

Why getting message object not iterable?

2009-05-16 Thread pradyumna
I am a newbie to Django.. I am wondering why I am getting 'Caught an exception while rendering: 'Car' object is not iterable? As per my understanding, in the template, if statement should not be true and else portion should be executed. Can anybody help me on this? View: def

Re: djangotiny and filebrowser question

2009-05-16 Thread patrickk
using the filebrowser outside the admin is easy: just change the templates/stylesheets and remove the staff member decorator. besides that, you may want to add/remove some functionality. we used the filebrowser for a public blog-system about 2 years ago. unfortunately, that site doesn´t exist

Re: how to refer a foreign key to a non primary column from other model

2009-05-16 Thread Joshua Russo
Ok, apologize. I just tried it myself and MySQL did accept the alter table. It is certainly not an operation that I have been able to perform in MS SQL Server or Oracle, though I wonder if it's something that is changing industry wide. MySQL seems to allow a foreign key to any unique index. >

ManyToMany field and limit_choices_to

2009-05-16 Thread adrian
I am creating a view to edit a model that has a ManyToMany field. The field is defined as: performer = models.ManyToManyField(Entity, limit_choices_to= {'role__exact':'PER'}) Entity is a table of persons or organizations. Some of them are performers and some are not (distinguished by

Re: escape problem in django templates

2009-05-16 Thread Karen Tracey
On Sat, May 16, 2009 at 12:23 AM, ozgurisil wrote: > > Hello all, > > Let's say that I have this string: > > s = 'Hello!' > > When I pass this variable to a template, I want it to be rendered as > raw html. Looking at the docs I see that I can either use the safe > filter: >

Re: how to refer a foreign key to a non primary column from other model

2009-05-16 Thread Alex Gaynor
On Sat, May 16, 2009 at 10:03 AM, Joshua Russo wrote: > > I should probably explain that better. Inside the DB foreign keys can > only be made between a field in a child/related table to a primary key > field. Generally the primary key fields don't change as often,

Re: User profile get_profile() error

2009-05-16 Thread Karlw
Thanks! Works great now. On May 15, 8:07 pm, Sam Chuparkoff wrote: > On Fri, 2009-05-15 at 19:53 -0400, Joshua Williams wrote: > > When trying to access a user defined profile, using get_profile, I > > am   > > getting an error when accessing the profile for a user.  Just so I

Re: how to refer a foreign key to a non primary column from other model

2009-05-16 Thread Joshua Russo
I should probably explain that better. Inside the DB foreign keys can only be made between a field in a child/related table to a primary key field. Generally the primary key fields don't change as often, though you can change them just like any other field it's highly unrecommended. If you try

Re: how to refer a foreign key to a non primary column from other model

2009-05-16 Thread Joshua Russo
You want to link to the id field in the auth_user table. Try the following: from django.contrib.auth.models import User class details(models.Model): user = models.ForeignKey(User) On May 16, 1:38 pm, lokeshmarema...@gmail.com wrote: > Hi joshua, > > Yes, I just want to link username to

Re: MySQL with pyodbc error

2009-05-16 Thread Karen Tracey
On Fri, May 15, 2009 at 10:07 PM, Phil wrote: > > Hi, > > I'm trying Django with MySQL and the pyodbc connector. However, it > appears that Django can only cope with the mysqldb connector. I get a > load of traceback ending with the error: > > File

Re: how to refer a foreign key to a non primary column from other model

2009-05-16 Thread lokeshmaremalla
Hi joshua, Yes, I just want to link username to details table. Regards, Lokesh On May 16, 7:30 pm, Joshua Russo wrote: > Foreign keys only point to primary key values. That's just how > relational DBs work > > It looks like you just want to link details to a user. Is

Re: how to refer a foreign key to a non primary column from other model

2009-05-16 Thread Joshua Russo
Foreign keys only point to primary key values. That's just how relational DBs work. It looks like you just want to link details to a user. Is that correct? On May 16, 12:46 pm, lokeshmarema...@gmail.com wrote: > Hi All, > > Is it possible to create a foreign key to a model referring to a non >

how to refer a foreign key to a non primary column from other model

2009-05-16 Thread lokeshmaremalla
Hi All, Need help in creating foreign key column in a table. In the below model I would like to create a foreign key for the field 'new_foreign_col' which should refer to 'username' column (non primary column) from auth_user table. class details(models.Model): new_foreign_col =

Re: Parsing the arguments in HTTP GET

2009-05-16 Thread Michael
> > On 15 May 2009, at 23:56, MohanParthasarathy wrote: > > > > > Hi, > > > > I am very new to django. I am following along the tutorial. But I want > > to be able to parse the URL which has the following form: > > > > http://example.com/data/?ui=2=1#label=/fetch > > > > From what I can tell,

Re: how to refer a foreign key to a non primary column from other model

2009-05-16 Thread Alex Gaynor
On Sat, May 16, 2009 at 8:46 AM, wrote: > > Hi All, > > Is it possible to create a foreign key to a model referring to a non > primary column from other model. > > class details(models.Model): >username = > > ?? -> how I can refer this field as a

Re: Parsing the arguments in HTTP GET

2009-05-16 Thread Vladimir Prudnikov
Do you want it to simply parse, or you want to add it into urlconf? If you want to just parse - use urlparse module http://docs.python.org/library/urlparse.html if you want to add it into the url config - simply handle 'data/' and the rest data you will get from GET data through request.GET

how to refer a foreign key to a non primary column from other model

2009-05-16 Thread lokeshmaremalla
Hi All, Is it possible to create a foreign key to a model referring to a non primary column from other model. class details(models.Model): username = ?? -> how I can refer this field as a foreign key to username column which is from auth_user table. Thanks in advance.

Re: Ordering a query by comments connected to model

2009-05-16 Thread Alex Gaynor
On Sat, May 16, 2009 at 3:59 AM, Andy Mikhailenko wrote: > > > Any aggregation over generic relations is currently unsupported, it was > > hoped this would make it into 1.1, but unfortunately some of the way SQL > > works prevented this (since it requires us to change the

Re: About forms.ChoiceField()

2009-05-16 Thread Alex
Thanks for reply, Jim. Hmm, just saved full page to disk. Almost the same time... now i think it's just cost of transferring of big select box. I'll make it a bit smaller. Gzip will help me I think) Thanks again. On May 16, 4:44 pm, Jim wrote: > > I have made a small

Re: Problem debugging with pdb

2009-05-16 Thread Joshua Russo
Ok I figured it out. I'm not exactly sure what the b or break command within pdb does but it doesn't seem to work in some instances as I described in my initial post. Does anyone know what the constraints are to using the break command within pdb? What does work is to import pdb in the file you

Re: About forms.ChoiceField()

2009-05-16 Thread Jim
> I have made a small form, only 10 fields. But now I see that page > loads more than two times slower! Is the page twice as long with string that makes up the 88-choice field? There is of course a cost to what you put on a page. Is the speed of loading changed when you save the page to your

Re: djangotiny and filebrowser question

2009-05-16 Thread Joost Cassee
On May 16, 6:17 am, Bobby Roberts wrote: > I've got an application i'm writing where I need to use django-tinymce > and filebrowser on the public side (ie not admin) of the website. > Can someone provide me with a rundown on how to make those non-admin > dependent The

Inline admin forms with dynamically defined initial data

2009-05-16 Thread foxbunny
Hi, all I have three models in many-to-many-through arrangement. Let's call them A, B, C, where B is the join model. I would like to edit B as inline from C, so that the number of inlines and their pre-filled data (if possible at all) matches the number of A objects. If I have, say three

additional data on ManyToManyField and symmetrical

2009-05-16 Thread Alex Rades
Hi, I have a model which looks like: class Person(models.Model): friends = models.ManyToManyField("self", through="Friendship") class Friendship(models.Model): person_a = models.ForeignKey(Person) person_b = models.ForeignKey(Person, related_name="_unused_") Now, as mentioned in:

Re: Counting pageviews

2009-05-16 Thread Antoni Aloy
2009/5/15 Oleg Oltar : > Hi! > > I am writing simple article manager application. Is there a way I can store > pageviews number for my articles in database (want to display them in > future, and use for rating on site) > > Thanks in advance, > Oleg > You can use google

Re: Trouble using pdb with manage.py runserver

2009-05-16 Thread Antoni Aloy
2009/5/15 Joshua Russo : > > I'm starting the debugger like so: > > (from the dir containing manage.py) python -m pdb manage.py  runserver > > it starts just fine, showing it paused at the first line. I set my > break points using "b filename: line#". This reports that

Re: Ordering a query by comments connected to model

2009-05-16 Thread Andy Mikhailenko
> Any aggregation over generic relations is currently unsupported, it was > hoped this would make it into 1.1, but unfortunately some of the way SQL > works prevented this (since it requires us to change the underlying Query to > allow support for additional conditions on a join clause). Alex,

Theory - where & how to handle common functions & views

2009-05-16 Thread zayatzz
Hello I have several views that pass same info into templates. If i want to change information that gets passed into template then i have to change several views to get system up to date and this is not good. Its common sense to replace them with one function instead. Where and how should i

About forms.ChoiceField()

2009-05-16 Thread Alex
Hello all! First of all sorry for my bad english:) I have made a small form, only 10 fields. But now I see that page loads more than two times slower! I found problem in this field: age = forms.ChoiceField(required=True, choices=AGE_CHOICES, initial='18') without this field page loads much

multiple sites using one CMS

2009-05-16 Thread Milan Andric
So we are building a CMS that should allow multiple sites to be supported based on the sites framework or a sites key on various models we want to be multisite. This is how I imagine it working: Each publication site will be a separate django project using the same database as the CMS. And