Translated DB

2008-05-03 Thread dimrub
Suppose, you want to have a model, the fields of which are available in multiple languages. How would you people go around doing it? The most trivial method would be to define as many variations of each text field as there are lanugages, and define a function inside the model that returns the vari

Re: get_FOO_display() and Update Messages

2008-05-03 Thread dimrub
Yay another fitness app based on django! http://code.google.com/p/fiteat/ On May 3, 9:15 am, Greg Taylor <[EMAIL PROTECTED]> wrote: > I was wondering if there's any reason why get_FOO_display() calls > aren't being evaluated when updating/adding new objects via the admin > interface. What I mean

Re: two choices questions

2008-04-29 Thread dimrub
laces the field's _choices property with the options sorted to my liking. I can provide the necessary code samples, if anyone is interested. On Apr 25, 11:57 pm, dimrub <[EMAIL PROTECTED]> wrote: > 2. Is there a way to sort the order of the choices dynamically (e.g., > based on the

Re: Choosing database settings based on request?

2008-04-29 Thread dimrub
What you can try out is the following approach (a variation of which I use in order to customize the data being presented based on the identity of the currently logged in user). 1. Create a middleware that pushes the relevant info from the request into a thread local storage. 2. Create a custom m

Re: SUM on a model

2008-04-27 Thread dimrub
In addition to the above, you can have a field in your model, that will contain that sum, and update it in your save(). It may not be as beneficial with sum() as it is with some other functions that work on multiple rows. 陈亮 wrote: > Hi there, > I've googled a lot on how to get the sum of a i

Re: two choices questions

2008-04-25 Thread dimrub
_field.options[i].text == 'Other') { other_index = i; } } if (type_field.addEventListener) { type_field.addEventListener("change", change_handler, false); } else if (type_field.attachEvent) { type_field.attachEvent("onchange", change_handler

Re: two choices questions

2008-04-25 Thread dimrub
On Apr 25, 11:57 pm, dimrub <[EMAIL PROTECTED]> wrote: > Greetings, all! > Oh, forgot to mention: I'm trying to use admin views. I do realize question #2 has a trivial solution if a non-admin view is used (and, come to think of it

two choices questions

2008-04-25 Thread dimrub
Greetings, all! Two (possibly - trivial) questions regarding a field that has 'choices' defined for it. 1. Is there a way to specify a special choice, upon which another field becomes active? A typical use case is to have a certain set of predefined values (out of which the user will USUALLY cho

is_valid() name change?

2008-04-24 Thread dimrub
I don't think having a function with such a profound side effect (such as making clean_data available) is a good idea. Very counter- intuitive, IMHO. Why not split it into two: - validate() - that performs the validation and makes clean_data available - is_valid() - that calls the above validate(

Re: Changing admin index

2008-04-22 Thread dimrub
The most obvious way would be to override the corresponding template to include only a specific list of apps. On Apr 22, 8:22 pm, "Monica Leko" <[EMAIL PROTECTED]> wrote: > Hi > > Can I somehow exclude sites and auth from admin index page, and left > only django apps? --~--~-~--~~

Re: Per user settings and records in the admin views

2008-04-14 Thread dimrub
(I will continue talking to myself here for a while) So, I've located the key passage in the django book: == quote == Another implication is that the permission system, while powerful, has no support for limiting access on a per-object basis as of this writing. If you trust someone to edit his o

Re: Per user settings and records in the admin views

2008-04-14 Thread dimrub
OK, I seem to have found a way to achieve the first task, even though it doesn't seem to be a rather elegant one. Here's the code that I wrote for it: from django.contrib.admin.views.main import change_list def index(request): # Copy the GET dict in order to modify it g = request.GET.cop

Per user settings and records in the admin views

2008-04-14 Thread dimrub
Hi, all! I am fairly new to Django, but I think I've looked rather thoroughly at the available documentation, and couldn't come up with an answer, so I'll ask here, and please forgive me if it's a FAQ. I would like to do basically two things, both are related to the admin views and to users. The