Turn abstract base class into non-abstract
Hi all, I am using an abstract base class called "profile" for the extension of my user models. I implemented several profiles like "standard, premium, staff" and so on. Now I realised that I would like to check the permission of a certain user on a certain project without having to know about his specific profile, like this user.profile.has_permission(project) but this of course does not work because "profile" is an abstract base class, so I can only check "user.premium.has_permission(project)" for example. This is pretty bad, because adding profiles would result in a change of every piece of code where I check for permissions. The problem is, that simply removing "abstract = True" does not work, because the tables "account_premium" "account_standard" have conflicting primary keys. Is there a way to circumvent this problem? Thanks in advance, Daniel -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Translation problem
Hi all, I have a problem getting the correct translation using gettext in the following situation: I have a view which calls a custom function to send an email. This functions takes three arguments - subject of the email (string) - the language of the email - the template to render the content of the email: e.g: my_mail(ugettext_lazy('This is the subject'), 'es', 'invitation') Now, my_mail looks basically like this: def my_mail(subject, lang, tpl): translation.activate(lang) content = render_to_string() email = EmailMessage(subject, content, from_addr, to_addr) email.send() Now my problem is, that the content of the email is always sent in the desired language given by the "lang" variable. While the subject of the email is always sent in the language of the user calling the view. What am I doing wrong? And how can I tell my function to translate the subject correctly? I thought that is exactly what ugettext_lazy is for, but obviously I misunderstood the concept. Thanks, Daniel -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Internationalization
Hi all, I have two questions regarding i18n to which I find very little or even no information. I hope someone can help. The first question is whether django supports the declaration of a message context (msgctxt) in the .po-files in order to have different translations for the same string in different positions of the application. I tried the following #: templates/client/base_project.html:21 msgctxt "templates/client/base_project.html:21" msgid "Public" msgstr "My translation" and a couple of deviations but the string is never translated if the "msgctxt" declaration is present. The second question is whether it is possible to remove options (in my special case I use the "choices" parameter in my model) depending on the language. The background is the following: I have a field containing the salutation. In english this would contain "Mr, Mrs and Ms" while in most other languages this only contains a string for males and a string for females - thus only two options. Is it possible to get rid of the third option if no equivalent for that is available in a certain langauge? Thanks in advance! Regards, Daniel -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.
Forcing a specific language
Hi all, is it possible to force a specific language (I am talking about real languages, i18n) while rendering a template? I have an application which allows the user to choose a language and I set a default language in the settings. But now I want to render only one single page forcing a specific language which is NOT the default language (but is part of my LANGUAGES settings, although it may not be the users language). I can not simple turn off translation because in this template I am using language sensitive filters and model names which would than return strings according to the default language. So I would like to force a language setting. Thanks in advance, Daniel -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.