Re: Can't explain this ImportError

2010-02-25 Thread Daniel Roseman
On Feb 25, 6:27 am, Adam Yee wrote: > Just started using haystack.  I've created an extended search form of > SearchForm and have it located at /mysite/search/search_forms.py > > The import error happens in haystack.urls > > Traceback: > File "/home/adam/stldata-djangosvn-2.6/lib/python2.6/site-pa

Re: Set language on per page basis

2010-02-25 Thread Ian Lewis
In process_request you have access to the request object which knows the current path (request.path). You can use that to determine which language to show the page in. Or if you are determining the language based on a url parameter you can look at request.GET Ian On Thu, Feb 25, 2010 at 8:24 AM,

Re: Set language on per page basis

2010-02-25 Thread Ian Lewis
BTW: django-cms does something similar to what you are trying to do. You can check out it's implementation here: http://github.com/digi604/django-cms-2.0/blob/master/cms/middleware/multilingual.py 2010/2/25 Ian Lewis : > In process_request you have access to the request object which knows > the c

Re: Redirecting to a different view after posting a form

2010-02-25 Thread bruno desthuilliers
On Feb 25, 1:15 am, Timothy Kinney wrote: > I have two views: > samurai_detail > add_item_to_samurai > > There is a button in samurai_detail that links to add_item_to_samurai. > The templates are the same except that add_item_to_samurai includes a > form to add an item. > > After posting the form,

Re: managers or classmethods?

2010-02-25 Thread bruno desthuilliers
On Feb 25, 5:51 am, HARRY POTTRER wrote: > Why not something like this: > > class Person(models.Model): >     @classmethod >     def male(cls): >         return cls.objects.filter(gender='M') > >     @classmethod >     def female(cls): >         return cls.objects.filter(gender='F') > >     name =

Re: Set language on per page basis

2010-02-25 Thread Tom Evans
On Wed, Feb 24, 2010 at 8:59 PM, Tor Nordam wrote: > Thank you for your reply, > > Using the {% trans %} method is indeed what I intend to do. But the > problem is how to set the language on a page basis, rather than as an > installation-wide setting, or a user-selectable setting. > Just do what

Re: displaying validation errors

2010-02-25 Thread bruno desthuilliers
On Feb 25, 6:10 am, jimgardener wrote: > hello guys, > I wanted to display validation errors in the form .I tried this > > class BookForm(ModelForm): >     class Meta: >         model=Book >     def clean_bookname(self): >         bkname=self.cleaned_data['bookname'] >         bkname=bkname.strip(

Django + Varnish. Keepalive?

2010-02-25 Thread Alessandro Ronchi
I am using Varnish as a frontend proxy for my django apps. I usually disable keepalive on apache, but in this case I've only one client (the proxy on localhost) for apache, isn't it good to avoid closing and opening connections? Thanks in advance, best regards. -- Alessandro Ronchi http://www.s

schema migration

2010-02-25 Thread vishal d
Hi to all Am new to django...plz suggest me which is the better one for the schema migration for django apps Thanks in advance vishal 2009vis...@gmail.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send ema

Noob: Can you use the ORM to do a self join with an aggregate?

2010-02-25 Thread Peter Phillips
Just started in the last few days with django and am having a little trouble with the orm. Is it possible to do a self join with an aggregate? My query looks like the following (apologies for the generic names): SELECT t.field1, c.field2, c.field3, t.field4, t.field5, (t.field4/ t.field5) as "fie

Do fixtures in tests overwrite default model field values?

2010-02-25 Thread filias
Hi, I am running several tests and created a fixture with the test data. I have one model with a custom field which has a default value. I thought my test fixture should overwrite this field for some of the objects but when run the test the value for the field is always the default value. Is thi

Re: schema migration

2010-02-25 Thread Shawn Milochik
The way to go is South: http://south.aeracode.org/ Shawn On Feb 24, 2010, at 11:51 PM, vishal d wrote: > Hi to all > > Am new to django...plz suggest me which is the better one for the > schema migration for django apps > > Thanks in advance > > vishal > 2009vis...@gmail.com > > -- > Yo

Re: how to capture the exception

2010-02-25 Thread Karen Tracey
On Wed, Feb 24, 2010 at 5:13 PM, bruno desthuilliers < bruno.desthuilli...@gmail.com> wrote: > But anyway: you already specified the unique constraint in the 'name' > field definition, so adding this code in your model save() method is > just useless - the uniqueness constraint WILL be applied at

Re: Passing RequestContext as dict vs. context_instance=RequestContext

2010-02-25 Thread Alex Robbins
If you get tired of forgetting to add the RequestContext you can use direct_to_template[1] instead. (I almost always forget it the first time) It is almost exactly like render_to_response, you'd use it like this: def index(request): return direct_to_template(request, 'index.html', { '

Re: transaction in django app desktop

2010-02-25 Thread rebus_
On 24 February 2010 20:51, ktemo wrote: > hi > i working in a desktop app with django mysql,  and wxpython, and i > need to make transaction >  i read the doc online, but i dont know if is possible work with a > desktop app > > -- > You received this message because you are subscribed to the Googl

Re: preventing template from converting html entities

2010-02-25 Thread Alex Robbins
I think you can do that with title={% filter force_escape %}"{{ villa.name }}"{% endfilter %}. Haven't tried it though. Alex On Feb 24, 8:36 am, Federico Capoano wrote: > Hello to all, > > simple question: > > I have the following HTML in a template: > > > But it gets rendered this way: > > >

Re: preventing template from converting html entities

2010-02-25 Thread Alex Robbins
Oops, it would actually be title={% filter force_escape %}"{{ villa.name }}"{% endfilter %} Sorry. -- Alex Robbins 5Q Communications, Inc. http://www.5Qcommunications.com/ alex.robb...@5qcommunications.com 800-747-4214 ext 913 (p) http://www.ask5q.com/twitter/ On Thu, Feb 25, 2010 at 8:33 AM, A

Re: Custom button for imagefield form

2010-02-25 Thread rebus_
On 22 February 2010 14:06, CrabbyPete wrote: > I have form with where users can upload an image. All works well but I > want a graphic instead of the default browse button that shows up. Can > I change it and if so how do you change it in the form field or > template? > > > class ProfileForm(SignU

Re: Custom button for imagefield form

2010-02-25 Thread Tom Evans
On Mon, Feb 22, 2010 at 1:06 PM, CrabbyPete wrote: > I have form with where users can upload an image. All works well but I > want a graphic instead of the default browse button that shows up. Can > I change it and if so how do you change it in the form field or > template? > > > class ProfileForm

Dev environnement, Eclipse, pydev, Windows, remote developement

2010-02-25 Thread Eric Brockmann
Hi all ! Just begining to set up my work environnement... Is there a way to develop using Eclipse/Pydev from my workstation on Windows (i know, i know...can't choose ) to create a Linux Django site. ? The remote Linux machine is very basic and i can't install any dev environnement on it. Is

Dev environnement, Eclipse, pydev, Windows, remote developement

2010-02-25 Thread Eric Brockmann
Hi all ! Just begining to set up my work environnement... Is there a way to develop using Eclipse/Pydev from my workstation on Windows (i know, i know...can't choose ) to create a Linux Django site. ? The remote Linux machine is very basic and i can't install any dev environnement on it. Is Remo

Re: Dev environnement, Eclipse, pydev, Windows, remote developement

2010-02-25 Thread thanos
How about running your linux in vmware or virtualbox on your windows machine. Its the right way to go. You can then develop in you production environment. BTW do you use virtualenv. It can save you a lot of pain! Thanos On Feb 25, 9:59 am, Eric Brockmann wrote: > Hi all ! > > Just begining to

Re: debugging server code problems in server code that is invoked via ajax request

2010-02-25 Thread Margie Roginski
Hi - thanks for your responses. Was on vacation and forgot to check back on this thread. The idea of middleware is good. I'm not sure, however, if the views.py code generates an exception, that it can be caught by the middleware? I guess the question is how to catch exceptions. The views.py co

HttpResponseRedirect waiting for something

2010-02-25 Thread adrian
I have a view that takes a form submission with a file, loads orders from the XML file by parsing it and saving records. After it is all done it redirects to another view, but the redirect hangs for about 30+ seconds then I get this message and it continues normally: Traceback (most recent call

Re: debugging server code problems in server code that is invoked via ajax request

2010-02-25 Thread David De La Harpe Golden
Possibly useful tip: Note that if you use request.is_ajax() in your django views, you can also use e.g. the "Modify Headers" firefox plugin to simply pretend to django that an ordinary request you've e.g. typed into your browser address bar is an "ajax" request, with a rule e.g. Action Nam

Re: Lazy model load problem (0.96 -> 1.1 difference)

2010-02-25 Thread Eric Floehr
For posterity, I discovered the difference between 0.96 and 1.1.1. Django 0.96 doesn't cache related objects passed in via the constructor of a model, whereas 1.1.1 does. Here is the setup. I create a model instance, just populating the primary key: >>> s = Station(station_index=1846) In 0.96 I

Multiple DB in django 1.2

2010-02-25 Thread Roach, Marshall (MROACH)
Hi, I was at pycon last week and heard about the db routers in django 1.2 and I have the alpha version of django running for a project I¹m running and trying to figure out how to do the following. I have 2 databases on different machines and if its one of the models I want the database to write ev

Re: Redirecting to a different view after posting a form

2010-02-25 Thread Timothy Kinney
Thanks for the reply, Bruno. For some reason, that still doesn't work for me. I can't figure out how to get reverse to work at all. But I took your advice about HttpResponseRedirect and this worked fine: return HttpResponseRedirect('../') Since my path structure is: myProject/myApp/samurai/samura

Re: transaction in django app desktop

2010-02-25 Thread ktemo
thanks, trying one more time On 25 feb, 08:30, rebus_ wrote: > On 24 February 2010 20:51, ktemo wrote: > > > hi > > i working in a desktop app withdjangomysql,  and wxpython, and i > > need to make transaction > >  i read the doc online, but i dont know if is possible work with a > > deskto

Re: Django REST and FILEFIELD field

2010-02-25 Thread manu.polline
Hi everyone, anyone help me?? On 22 Feb, 19:19, "manu.polline" wrote: > Hi everyone, > my name is Manuel. I'm tryng to upload a file directly in a filefield > of Django model exposed by django-rest-interface. > It'is possible? > this is my model : > > class File(models.Model): >     file = models

Re: form.has_changed always true?

2010-02-25 Thread ducu
Btw, has_changed() doesn't seem to work on non-model forms, does it? On Jan 12, 12:43 am, Alastair Campbell wrote: > On Fri, Jan 8, 2010 at 1:09 AM, Karen Tracey wrote: > > Using the instance parameter is the POST leg also allows you to simply > > save() the form to get the changes to the instan

Re: transaction in django app desktop

2010-02-25 Thread Peter Herndon
On Feb 24, 2010, at 2:51 PM, ktemo wrote: > hi > i working in a desktop app with django mysql, and wxpython, and i > need to make transaction > i read the doc online, but i dont know if is possible work with a > desktop app If you could provide more detail on what you want to accomplish, we cou

Re: form.has_changed always true?

2010-02-25 Thread Karen Tracey
On Thu, Feb 25, 2010 at 3:03 PM, ducu wrote: > Btw, has_changed() doesn't seem to work on non-model forms, does it? > > Yes, it does: >>> from django import forms >>> class AForm(forms.Form): ... x = forms.IntegerField() ... >>> af = AForm({'x': u'1'}, initial={'x': 1}) >>> af.has_changed()

Re: Can I use request.user, in the limit_choices_to filter in Model class?

2010-02-25 Thread zinckiwi
> I need to filter a field by a UserProfile function, i.e. how can I do > something like this? > > class Paquet(models.Model): >     ... >     profiles = models.ManyToManyField(UserProfile, limit_choices_to = > {'country': request.user.userprofile.country}) I'd put that restriction inside the Mode

Subclassing Comments model

2010-02-25 Thread CrabbyPete
I subclassed the django comment app model, because I wanted to add photos. class PictureComment( Comment ): photos = models.ManyToManyField(Photos) In my template I use {% get_comment_list for message as comment_list %} {% for comment in comment_list %} {% endfor %} and the lis

Re: Subclassing Comments model

2010-02-25 Thread CrabbyPete
Sorry I did not finish. How do I get the subclass PictureComment, not Comment. On Feb 25, 4:13 pm, CrabbyPete wrote: > I subclassed the django comment app model, because I wanted to add > photos. > > class PictureComment( Comment ): >     photos          = models.ManyToManyField(Photos) > > In

Re: Redirecting to a different view after posting a form

2010-02-25 Thread bruno desthuilliers
On 25 fév, 20:49, Timothy Kinney wrote: > Thanks for the reply, Bruno. For some reason, that still doesn't work for > me. I can't figure out how to get reverse to work at all. But I took your > advice about HttpResponseRedirect and this worked fine: > > return HttpResponseRedirect('../') > > I was

Re: debugging server code problems in server code that is invoked via ajax request

2010-02-25 Thread bruno desthuilliers
On 25 fév, 17:06, Margie Roginski wrote: > Hi - thanks for your responses.  Was on vacation and forgot to check > back on this thread.  The idea of middleware is good.  I'm not sure, > however, if the views.py code generates an exception, that it can be > caught by the middleware?   How do you

Re: Subclassing Comments model

2010-02-25 Thread Xavier Ordoquy
Hi, You should read Django's esp how to use custom comment class. You should have a line in your setting file for overriding the default class. Xavier -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to djan

Re: Redirecting to a different view after posting a form

2010-02-25 Thread Karen Tracey
On Thu, Feb 25, 2010 at 4:25 PM, bruno desthuilliers < bruno.desthuilli...@gmail.com> wrote: > On 25 fév, 20:49, Timothy Kinney wrote: > > I think I'll just > > stick with urls. > > Mmmm... Fine for you if it works, but as far as I'm concerned I don't > like it. I do use HttpResponseRedirect, but

Re: Redirecting to a different view after posting a form

2010-02-25 Thread Timothy Kinney
I have taken a, perhaps, unorthodox tact for my admin views. I use myproject/urls.py to grab the url and redirect to myapp.admin_views.samurai_detail urls.py catches url patterns such as: r'^admin/myapp/samurai/(?P.*)/add_item/$' r'^admin/myapp/samurai/(?P.*)/$ I am keeping all of my admin_views

Dynamic list of checkboxes from database info

2010-02-25 Thread Timothy Kinney
** Background ** In the admin view, I want to generate a form which grabs a list of items from the database and displays a checkbox next to each item. The goal is simply to check multiple boxes and hit Submit and they are deleted. Because of the way my models are setup, there is no default admin

Re: How can I add the Openid session data to the Django test client Client.post() ?

2010-02-25 Thread br...@instantdirectmarketing.com
I looked at how the Django test client class method, Client.login() stored sessions and attempt to copy the important sections into the test so the session data could be stored. When I broke into the test immediately before Client.post() was called and the session looked OK. ipdb> request.session.

Re: what is up with InternalError current transaction is aborted, commands ignored until end of transaction block

2010-02-25 Thread Carl Zmola
I ran into the same problem, but have avoided the "commit manually" and used try: #do my normal stuff except psycopg2.InternalError, e: #transaction.rollback_unless_managed() django.db.connection._rollback() Again, I am not sure whether it is a signal handler

Re: Hierarchical data containing different models

2010-02-25 Thread Marco Rogers
Couple of things. bruno, your save example should maybe look call the superclass save first. Otherwise parent may not have been set yet.     def save(self, *args, **kw):         super(Node, self).save(*args, **kw)         if self.parent and type(self.parent) != Group:             raise Value

Admin Site Performance Problem

2010-02-25 Thread sixpackistan
Anybody have any ideas on this? I am running django 1.1.1 using mod_python on apache 2.2. We have a large database of items (defined in the model as "item") that are searchable by serial number (which is indexed in the database). On the public site, one can enter in a serial number and the appropr

Re: Admin Site Performance Problem

2010-02-25 Thread Timothy Kinney
If it takes 60 seconds for a single item to come up on the admin site, something is seriously wrong. You configure which items show up on the admin site and if you configure it a certain way it may have many, many queries to make. If you only have one table, your query should be pretty fast. How

Weird transaction problem with postgresql

2010-02-25 Thread Julien Phalip
Hi, After looking through this mailing list I've seen many threads discussing issues relating to transaction issues with postgresql, but none like the one I'm facing. If I've missed any relevant thread, please let me know. I've got a Profile model which is instantiated each time a new user is cre

RV: photos

2010-02-25 Thread Gisela Cartaya
De: Raven Riley [mailto:ravenriley2...@yahoo.fr] Enviado el: Thursday, February 25, 2010 4:11 PM Para: gcart...@infomed.sld.cu Asunto: Re : photos Imagen quitada por el remitente. HUY Imagen quitada por el remitente. POUIT Imagen quitada por el remitente. GYH Imagen quitada

RV: photos

2010-02-25 Thread Gisela Cartaya
De: Raven Riley [mailto:ravenriley2...@yahoo.fr] Enviado el: Thursday, February 25, 2010 4:11 PM Para: gcart...@infomed.sld.cu Asunto: Re : photos HUY POUIT

Re: RV: photos sexy

2010-02-25 Thread Nicolas Couture
This is probably the funniest post I've seen on a technical mailing list this year. 2010/2/26 Gisela Cartaya > > > > > *De:* Raven Riley [mailto:ravenriley2...@yahoo.fr] > *Enviado el:* Thursday, February 25, 2010 4:17 PM > *Para:* gcart...@infomed.sld.cu > *Asunto:* Re : photos sexy > > > > sa

Re: Admin Site Performance Problem

2010-02-25 Thread Matt Schinckel
On Feb 26, 11:45 am, sixpackistan wrote: > Anybody have any ideas on this? > I am running django 1.1.1 using mod_python on apache 2.2. > We have a large database of items (defined in the model as "item") > that are searchable by serial number (which is indexed in the > database).  On the public si

Re: Multiple DB in django 1.2

2010-02-25 Thread Russell Keith-Magee
On Fri, Feb 26, 2010 at 2:08 AM, Roach, Marshall (MROACH) wrote: > Hi, I was at pycon last week and heard about the db routers in django 1.2 > and I have the alpha version of django running for a project I’m running and > trying to figure out how to do the following. > > I have 2 databases on diff

Re: Do fixtures in tests overwrite default model field values?

2010-02-25 Thread Russell Keith-Magee
On Thu, Feb 25, 2010 at 8:43 PM, filias wrote: > Hi, > > I am running several tests and created a fixture with the test data. > I have one model with a custom field which has a default value. > > I thought my test fixture should overwrite this field for some of the > objects but when run the test