Re: Templates in models and i18n.

2009-04-12 Thread Poromenos
It's not an entire template, I'm just using the template system as an  
alternative to string formatting because of its name resolution  
capabilities. I found out how to do it, actually, I used ugettext  
instead of lazy an it works well!

Poromenos

On 12 Απρ 2009, at 19:52, Karen Tracey <kmtra...@gmail.com> wrote:

> On Sun, Apr 12, 2009 at 11:29 AM, Poromenos <porome...@gmail.com>  
> wrote:
>
> Hello,
> I am trying to render a template in my models (to get the model
> details in a printable format), but I want the template string to be
> internationalised. ugettext_lazy does not return a string object, and
> the template returns nothing. My code is:
>
> template = Template(_("{{ self.name }}"))
> context = Context({"self": self}).render
> return template.render(context)
>
> This fails. Is there something I can do , or do I have to forget about
> internationalisation? Can I just use ugettext() instead?
>
> Have you read: http://docs.djangoproject.com/en/dev/topics/i18n/
>
> particularly: 
> http://docs.djangoproject.com/en/dev/topics/i18n/#in-template-code
>
> ?
>
> You don't want to be translating an entire template, you want to  
> translate individual bits within the template.  Consider that in  
> general a template will be filled with html tags, template  
> constructs (such as the {{ }} you have in yours), and such that it  
> makes no sense to translate.
>
> Karen
>
> >

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Templates in models and i18n.

2009-04-12 Thread Poromenos

Hello,
I am trying to render a template in my models (to get the model
details in a printable format), but I want the template string to be
internationalised. ugettext_lazy does not return a string object, and
the template returns nothing. My code is:

template = Template(_("{{ self.name }}"))
context = Context({"self": self}).render
return template.render(context)

This fails. Is there something I can do , or do I have to forget about
internationalisation? Can I just use ugettext() instead?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Generic relations and unit tests.

2009-04-10 Thread Poromenos

Hello,
I created a model that has a ForeignKey to ContentType, but now I
can't use my test fixtures, since the IDs they point to are random
every time the test database is created. I can't dump the contenttypes
data because then I get many duplicate inserts, since Django rebuilds
them every time it sets up the test DB. Is there any way for me to use
both ContentType and unit tests?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: i18n/setlang no longer support GET

2007-12-19 Thread Poromenos

I mistakenly replied to James instead of everyone, so I will rewrite
my reply.

My application's UI depends on the set_language view being a link, and
I don't think it should be up to the framework to force this on the
developer. It would be better if the view supported both ways and the
developer could choose whether they wanted functionality or spec
compliance. This isn't a simple change, and it shouldn't be decided
just like that...

On Oct 27, 1:32 am, Marc Garcia <[EMAIL PROTECTED]> wrote:
> That's not a big problem, you can just do something like that:
>
> #language {
>   background-color: transparent;
>   border-style: none;
>   cursor: pointer;
>
> }
>
> 
>   
> 
> 
>   
> 
>
> That have too few lines than a link, but follows standards, is
> probably clearer, ans looks exactly the same way.
>
> See you!
>   Marc Garcia
>  http://vaig.be/category/it/applications/django/
>
> On Sep 26, 7:39 pm, "Antoni Aloy" <[EMAIL PROTECTED]> wrote:
>
>
>
> > 2007/9/21, James Bennett <[EMAIL PROTECTED]>:
>
> > > The HTTP specification says that GET requests should not take any
> > > action other than retrieving a resource; in other words, a GET request
> > > which modifies state on the server or has other side effects should
> > > not be allowed.
>
> > That's true, but this makes i18n/setlangunworth for usual
> > applications, so I would prefer to have the option to be a bad boy and
> > use the GET request.
> > --
> > Antoni Aloy López
> > Binissalem - Mallorcahttp://www.trespams.com
> > Soci de Bulma -http://www.bulma.cat
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: auth system - check if user already exists

2007-08-05 Thread Poromenos

That's what I do (well, I just check the username, since I can't think
why you'd want to check the email). I don't think there's a better
way, it's pretty straightforward...

Poromenos

On Aug 6, 12:42 am, Aljosa Mohorovic <[EMAIL PROTECTED]>
wrote:
> i'm currently looking at django.contrib.auth and wondering what is the
> correct way to check if user already exists?
> before i call User.objects.create_user() i want to know that user with
> submitted username and email doesn't exist.
> my current situation is that i call
> User.objects.get(username__exact=user) and
> User.objects.get(email__exact=email) and if i get exception
> "DoesNotExist: User matching query does not exist." and i assume that
> it's ok to create new user.
>
> i'm sure there is a better way to check if user with submitted
> username or email already exists, please share your ways...
>
> Aljosa


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Internationalization and HTTP headers.

2006-08-05 Thread Poromenos

Never mind, I hadn't installed the Locale middleware, apparently it's
used for HTTP header detection as well as manual language override.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Internationalization and HTTP headers.

2006-08-05 Thread Poromenos

I have translated my site from English to Greek (el) and I have left
english as the fallback language (I haven't created an english .po
file), but the HTTP-header language selection doesn't work for me. If I
set the installation language it works fine, but I can't get it to
select content via the HTTP header.

Is there anything I should do/anything I'm doing wrong?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Overriding template blocks in code

2006-06-28 Thread Poromenos

Is there a way for me to specify template blocks in code? I want,
instead of overriding the "content" template from a file, to do it in
code. Is this possible?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Global template tags

2006-06-28 Thread Poromenos

Ah, that's what I needed, thanks a lot :)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Global template tags

2006-06-28 Thread Poromenos

Is there a way for me to pass a variable in every template context
without writing custom template tags? I just want to pass the app name
because I'm not comfortable with hardcoding it, but template tags seem
too much work for something as simple as this.

Isn't there something like a globals section, which get passed in every
template, where I could declare my variable and just do {{ company_name
}} and have it returned?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---