IntegrityError Handling

2007-05-01 Thread sandro.dentella
hi all, I noticed that recently has been added InterityError as a common exception for all db (django.db.IntegrityError), so I wanted to make my view aware of that, but I'm uncertain on how to accomplish this. I added a snippet like this one, in a sort of generic view: if form.is_vali

getting _meta of a related field from a ForeignKey

2007-04-14 Thread sandro.dentella
Hi all, I have a loop over fields (f = self._meta.get_field(name)) of a model. If a field is a ForeignKey, I need to follow the ForeignKey and get the model and application referenced by the fk. Eg: class Address: city = ForeignKey(City,...) ... f = Address._meta.get_field

Re: gettext & UnicodeDecodeError

2007-04-12 Thread sandro.dentella
Thanks! that was it. Now I can reproduce the error. Which is the "correct" solution? An easy and not really nice one is to encode title into DEFAULT_CHARSET, but I'd rather have _() return an unicode object. How should I do to obtain this? sandro *:-) --~--~-~--~~~

can I use other names beside django.po?

2007-03-22 Thread sandro.dentella
Hi, I'm starting with internationalization. All is good with django.po & mo. but tere are words that are not found by make-messages.py as are in variables so I add the by hand. I'd prefere to keep them in a separate file my_file.po. Compile-messages finds it and creates my_file.mo but d

Re: user, signal & _thread_locals

2007-03-18 Thread sandro.dentella
> I mean that I find the user in _thread_locals wen I work with > managers, but python complains > the user is not in _thread_locals when the 'receiver' is run, so I > desumed it's becouse is not > run in the same thread. You thing this is wrong? My fault here, I was reinstantiating locals() ra

Re: user, signal & _thread_locals

2007-03-16 Thread sandro.dentella
> > I realize now that signal do not preserve it (I guess that are run in a > > different thread, correct?) > > What do you mean by "preserve it"? A signal dispatch is just a series of > function calls. They happen in the same thread as whatever does the > dispatch. I mean that I find the u

can I mimic authenticated user from shell?

2007-03-06 Thread sandro.dentella
Hi all, How can I authenticate in a shell? I'm playing with Managers to meke them behave different according to the permission of the user, but I don't know how to play with the shell as authenticated user. Really what happens is that if I test a user that results authenticated and I dont' und

Re: form_for_model and hidden foreign key?

2007-02-24 Thread sandro.dentella
I'm not sure is you're talking about UPDATE or INSERT. Clearly when INSERTing new record it's easy to just setdefaults. The problem arises when UPDATEing. If my tests are correct (I'm pretty convinced tey are...) in fact you need to put all fields you don't want to update as hidden fields, and tha

Re: Newforms, form_for_model, help_text and unicode.

2007-02-19 Thread sandro.dentella
Hi, I had similar problems this night. It comes out help_text is the source of problems. I fixed it adding smart_unicode in Field class (newforms.fields): class Field(object): ... def __init__(...): self.help_text = smart_unicode(help_text) sandro *:-) PS: should I open a ticket

oldforms, file upload, rename & save

2007-02-09 Thread sandro.dentella
Hi all, I spent the last 2 hours fighting with a model.FileField that I wanted to save the file with a custom name (job number of a hylafax server). I found a related thread here: http://groups.google.com/group/django- users/browse_frm/thread/f337faf5ef5d8f9a/3c183363b21b496d? lnk=gst&q=file

Re: help with queryset and ManytoMany

2007-02-02 Thread sandro.dentella
> > class Project > > ... > > staff = models.ManyToMany(User) > > > My concern is the fact that I should loop over all my projects and get > > the staff for each ot them. > > If Project has a ManyToMany field, then Users will have a field called > project_set. > > frank = User.objects.get

Re: newforms, foreignKeys & constraints

2007-01-30 Thread sandro.dentella
On 30 Gen, 19:38, "chasfs" <[EMAIL PROTECTED]> wrote: > If you don't want the foreign key (or another field) to be displayed > in the form you can define a formfield_callback: This in not really the point. I *do* want Foreignkeys to appear. Suppose the foreign key is a project. I want a selec

newforms, foreignKeys & constraints

2007-01-30 Thread sandro.dentella
Hi all, I'm trying to learn newforms. I create a form with form_for_model and now presenti it in the template. A foreign key renders as a select widget, that is ok, but how can I limit the values filtering them out? Should I pass the widget when creating the Form using formfield_callback? C

sql debug

2007-01-10 Thread sandro.dentella
I'd like to know if it is possible to print the sql statement *before* issuing it, just to play with queryset and filtering. By the way I'm sure I read about the possibility to use cursor.queries, if DEBUG == True but I cant' find where I read it. Anyhow I'd prefer the first solution. TIA sandro

using freecomments wits cheetah templates

2006-11-27 Thread sandro.dentella
Hi, has anybody a working example on how to use comments using cheetah templates? is it any possible? I guess I should wrap CommentListNode in a function that returns directly the result rather than adding it to the context, is that correct? TIA sandro *:-) --~--~-~--~~-

how to tell if django is running from apache or standalone?

2006-11-16 Thread sandro.dentella
Hi all, how can I test from within settings.py if I'm running via mod_python or in standalone way? I need to set a variable, accordingly. TIA sandro *:-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django

moving django applications

2006-11-10 Thread sandro.dentella
hi all, how should I organize my configuration so that it's easy to have several django applications in the same apache (not as virtual domains!) and to move them from one position to another. I managed to configur apache to have several different django applications but I need to change the

Re: Django & Movable Python

2006-10-25 Thread sandro.dentella
> also so in next few days I will be testing that. If you people are > interested I can pack it and drop it somewhere on the web so you can > also play with it. I' defenitely interested, can you detail a little more or point to a page on the wiki. I'm a linux user but I'd need this solution for

Re: ForeignKey in other models.py

2006-10-23 Thread sandro.dentella
> When I try to edit with the admin interfaces django raises an error: > > Exception Type: OperationalError > Exception Value: no such column: film_film.proposto_da_id Explanation: I added field "proposto_da" after creating the db so I added it by hand but I didn't realize that django

Re: ForeignKey in other models.py

2006-10-21 Thread sandro.dentella
> I tried to insert, as you have said to me, but have received this error: > line 124, in get_all_related_objects > if f.rel and self == f.rel.to._meta: > AttributeError: 'str' object has no attribute '_meta' I guess you have quotes around the name of the class, so that the Referenced class