Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] related_name in blog.models.Post made translatable #25

Open
restless opened this issue Jun 3, 2009 · 4 comments
Open

[Bug] related_name in blog.models.Post made translatable #25

restless opened this issue Jun 3, 2009 · 4 comments

Comments

@restless
Copy link

restless commented Jun 3, 2009

Related_name set for "blog" field in "Post" in blog.models shouldn't be translatable.

The code is:
class Post(models.Model):
blog = models.ForeignKey(Blog, related_name=_("posts"))

This breaks things as soon as i18n is enabled and "posts" is translated to other language. You get an attribute error when blog.posts is called (for example in blog.views.py in privileged_post_queryset.

The solution is to change the above code to:
class Post(models.Model):
blog = models.ForeignKey(Blog, related_name="posts")

@scotu
Copy link

scotu commented Jun 3, 2009

this should be fixed in scotu/mightylemon@37a087f

Other (little) work has been done in my locale-it branch on translatable strings apart from italian translations if you are interested

@restless
Copy link
Author

restless commented Jun 9, 2009

Thanks for the answer. I've got one more question to you. How do you deal with locale settings? After I set LANGUAGE_CODE='pl' I have to do some hacks to have archive working. Here is what happens:

  1. template filter some_date|date:"b" returns for example "czerw" as month name (it is "jun" in Polish) and it is no longer compatibile with urls resolver expecting (?P[a-z]{3})
  2. Post model's get_absolute_url is not affected by locale and it always returns 'jun'. The method get_absolute_url uses strftime and not django.utils.format. The latter returns 'czerw'. Strange but this is how it works for me.
  3. I can't just add month_format to generic view because the format is also hardcoded in get_absolute_url, so I also have to modify this method.

I wonder what is your solution for the above issues.

@scotu
Copy link

scotu commented Jun 11, 2009

I've noticed that too, but I haven't dugg into the problem right now... I'm glad you've done so :) thanks

The best long term solution I see is avoid using the three-letters formatting for the month but go with the number. Doing so the url does not need to be translated and we can have one url for one resource instead of lots of urls for one resource (web crawlers...)

I'm looking forward other proposals...

@restless
Copy link
Author

Yup. This is what I did. I replaced %b with %m (number of month) in blog.models.Post's get_absulute_url and changed blog.models.urls adding a month_format:'%m' to date_based_dict as well as modfied regexes to expect a number: (?P\d{2}).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants