Re: text in translation strings?

2010-01-11 Thread Michael P. Jung
> I'm having a template, where a link shall be inside a translation- > marked text. (...) I've recently run across a similar problem and solved it using some nasty with-tag trickery. In your case the following code should do the trick: {% url login as login_url %} {% with "" as link_begin %} {%

Re: JOINs with Django ORM

2009-10-20 Thread Michael P. Jung
mp> I'd go for a denormalized database: mp> (...) tz> I'm aware of this solution, in fact I was using it. Unfortunately I tz> had problems with deleting objects with this circular dependency, but tz> maybe I was overlooking something (db we're using is MySQL 5). You're right. You have to make su

Re: "...where field is NULL" in Django ORM

2009-10-20 Thread Michael P. Jung
Михаил Лукин wrote: > For some reason, __exact and __isnull are described in documentation > [1], while =None is not. So which of them are historical? Django pre 1.0 generated bogus SQL, when doing nullable_field=None. These days __isnull can be replaced by the expressions: filter(foo__isnul

Re: JOINs with Django ORM

2009-10-19 Thread Michael P. Jung
> I was unclear, but SQL should explain what I want to do - select > all ObjectRevision-s that are latest in Object-s that they belong to. > Moreover, I want to do this in with one ORM query, without resorting > to SQL or splitting the query too much. I'd go for a denormalized database: class Fo

Re: form problem

2009-10-18 Thread Michael P. Jung
> I made the change but now the following error appears: > 'QueryDict' object is not callable Whops. request.GET is a query dict, so it's of course not callable. I ment to call get('user_text', '') on the request.GET: request.GET.get('user_text', '') --mp --~--~-~--~~-

Re: form problem

2009-10-18 Thread Michael P. Jung
First of all may I recommend you to use Django forms: http://docs.djangoproject.com/en/dev/topics/forms/ > With this method i have the following error: > Key 'user_text' not found in >> def view(request): >> user_text = request.GET['user_text'] >> return render_to_reponse("html",

Re: create Index: non-unique, multiple column

2009-10-16 Thread Michael P. Jung
> Given the following model, I want to index the fields (sequence,stock) There is a ticket for it, but it hasn't made it into Django, yet. http://code.djangoproject.com/ticket/373 > create index ndx_1 on model_quotemodel(sequence,stock); > Is there any "cleaner" way of doing it? If you ask me,

Re: Question about template

2009-10-16 Thread Michael P. Jung
> I would like to use if clause to check if a number is nagative or not > with template in my html file. I read related part in Django template > online document however I did not find what I need. > > Is it possilbe to do this with built-in Django filter functions? Or do > I have to install a thi

Re: check if user has already saved link

2009-10-14 Thread Michael P. Jung
> return user.savelink_set.objects.filter(link=object).count() (...) > The error i get now is : Caught an exception while rendering: > 'RelatedManager' object has no attribute 'objects' user.savelink_set is already a Manager and does not have an attribute "objects". Just write "user.savelink_s

Re: Showing unescaped HTML in Admin pages

2009-10-12 Thread Michael P. Jung
> Is is possible to render unescaped HTML in admin pages? > > (say) A model has a field "text" which contains HTML markup. Is this > something that can be changed on the model (ie __unicode__ method) or > do I have to change the admin templates? If you're only going to render html for lists it's

Re: sorl thumbnail error

2009-10-11 Thread Michael P. Jung
> I'm getting error messages with sorl thumbnail. [...] All works fine, > until I use the following template thumbnail tag: > > You must not put braces around variables passed to a template tag. Just write: {% thumbnail obj 80x80 %} That also explains why your {% thumbnail '/path/to/image' 80