Launching test project.
In url /new/ I got:
Comment #1
Posted on Dec 11, 2008 by Grumpy OxPlease, paste it again. It expired before anyone could look into it.
If possible, paste all the information right here, so that it stays and is easily searchable.
Comment #2
Posted on Dec 12, 2008 by Helpful BearEnvironment:
Request Method: GET Request URL: http://127.0.0.1:8000/new/ Django Version: 1.1 pre-alpha Python Version: 2.5.2 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'multilingual', 'multilingual.flatpages', 'testproject.articles', 'testproject.issue_15', 'testproject.issue_16', 'testproject.issue_29', 'testproject.issue_37', 'testproject.issue_61'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware', 'multilingual.flatpages.middleware.FlatpageFallbackMiddleware')
Template error: In template c:\documents and settings\nazar leush\workspace\django-multilingual\testproject\templates\articles\category_form.html, error at line 25 Caught an exception while rendering: Failed lookup for key [categorytranslation] in u'Created by:\n---------\nadmin\n\nParent category:\n---------\nFixture category\n' 15 : 1. form with all translations
16 : 2. form with default translation ({{ DEFAULT_LANGUAGE_CODE }})
17 :
18 :
19 :
20 :
21 :
22 :
Creator: {{ form.creator }}
23 :
Parent: {{ form.parent }}
24 :
25 :
Name EN: {% edit_translation form name "en" %}
26 :
Description EN: {% edit_translation form description "en" %}
27 :
28 :
Name PL: {% edit_translation form name "pl" %}
29 :
Description PL: {% edit_translation form description "pl" %}
30 :
31 :
, Cancel
32 :
33 :
34 :
35 :
Traceback: File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "c:\Python25\lib\site-packages\django\views\generic\create_update.py" in create_object 127. return HttpResponse(t.render(c)) File "C:\Python25\lib\site-packages\django\template__init__.py" in render 176. return self.nodelist.render(context) File "C:\Python25\lib\site-packages\django\template__init__.py" in render 768. bits.append(self.render_node(node, context)) File "C:\Python25\lib\site-packages\django\template\debug.py" in render_node 71. result = node.render(context) File "C:\Python25\lib\site-packages\django\template\loader_tags.py" in render 97. return compiled_parent.render(context) File "C:\Python25\lib\site-packages\django\template__init__.py" in render 176. return self.nodelist.render(context) File "C:\Python25\lib\site-packages\django\template__init__.py" in render 768. bits.append(self.render_node(node, context)) File "C:\Python25\lib\site-packages\django\template\debug.py" in render_node 71. result = node.render(context) File "C:\Python25\lib\site-packages\django\template\loader_tags.py" in render 24. result = self.nodelist.render(context) File "C:\Python25\lib\site-packages\django\template__init__.py" in render 768. bits.append(self.render_node(node, context)) File "C:\Python25\lib\site-packages\django\template\debug.py" in render_node 81. raise wrapped
Exception Type: TemplateSyntaxError at /new/ Exception Value: Caught an exception while rendering: Failed lookup for key [categorytranslation] in u'Created by:\n---------\nadmin\n\nParent category:\n---------\nFixture category\n'
Original Traceback (most recent call last): File "C:\Python25\lib\site-packages\django\template\debug.py", line 71, in render_node result = node.render(context) File "c:\Documents and Settings\Nazar Leush\workspace\django-multilingual\multilingual\templatetags\multilingual_tags.py", line 58, in render return str(resolve_variable(real_name, context)) File "C:\Python25\lib\site-packages\django\template__init__.py", line 610, in resolve_variable return Variable(path).resolve(context) File "C:\Python25\lib\site-packages\django\template__init__.py", line 676, in resolve value = self._resolve_lookup(context) File "C:\Python25\lib\site-packages\django\template__init__.py", line 729, in _resolve_lookup raise VariableDoesNotExist("Failed lookup for key [%s] in %r", (bit, current)) # missing attribute VariableDoesNotExist: Failed lookup for key [categorytranslation] in u'Created by:\n---------\nadmin\n\nParent category:\n---------\nFixture category\n'
Comment #3
Posted on Jan 9, 2009 by Happy BearI get the same error both in my own project and by running the included test project. Is this a bug or an error on my part?
Comment #4
Posted on Jun 12, 2009 by Quick RhinoI couldn't make this work either. I'm using latest django and multilingual.
I traced the error to multilingual_tags.
In EditTranslationNode.render
real_name = "%s.%s.%s.%s" % (self.form_name, trans_model._meta.object_name.lower(), get_language_idx(language_id), self.field_name)
where trans_model._meta.object_name.lower() is returning categorytranslation which is not present in the current context. So when the next line tries to do
return str(resolve_variable(real_name, context))
It can't be resolved. I'm not sure where is the problem.
Comment #5
Posted on Jun 18, 2009 by Quick Rhinoor is there something missing?
Comment #6
Posted on Oct 2, 2009 by Happy BearI've got same error when try multilingual Is there any solutions?
Caught an exception while rendering: Failed lookup for key [categorytranslation] in u'Parent:\n---------\n\u0444\u044b\u0432\u0430\u044b\u0444\u0432\u0430\n'
Comment #7
Posted on Nov 6, 2009 by Happy CamelO.K. I've spent two or three days with this. It looks like one will have to create a MultilingualModelForm class, which will know how to handle multilingual models. Am I right Marcin?
I'm not very experienced python/django developer, but I will try it. My idea is as follows:
the django-multilingual will overload/extend the original djanogo's
ModelForm class. it will be able to identify a 'Translation' class
in bound model.
the overloaded form class will contain attribute [modelname]translation,
which will contain a list of dictionaries. each dictionary will hold
form fields for given language.
this should make the edit_translation tag working again.
But still I'm afraid there are another pitfalls behind corners. These comes to my mind: How to modify MultilingualForm instance constructor to be able to use initial values/data?
how to deal with MultilingualForm.clean() method?
...
thanks for any comments/hints on this.
Comment #8
Posted on Nov 7, 2009 by Happy CamelIf anyone is still interested I have a patch with proof of concept. The idea will be demonstrated on example:
let be the model Gallery
#coding=utf-8
from django.utils.translation import ugettext as _
from django.contrib.auth.models import User
from django.db import models
from django.template.loader import render_to_string
import multilingual as multilingual
from multilingual.forms import MultilingualModelForm
# Create your models here.
class Gallery(models.Model):
article = models.ManyToManyField(
'news.Article',
verbose_name = _('Článek'),
blank = True,
null = True
)
class Translation(multilingual.Translation):
title = models.CharField(
verbose_name = _('Název'),
max_length = 256
)
class Meta:
verbose_name = _('Galerie')
verbose_name_plural = _('Galerie')
def __unicode__(self):
return self.title
the Form will be defined as follows: class GalleryForm(MultilingualModelForm): class Meta: model = Gallery
""" The GalleryForm instance will get an extra class - Translation, which is a Form with translatable fields.
The same thing can be achieved manually: class GalleryFormPOC(ModelForm): class Meta: model = Gallery class GalleryFormTranslation(ModelForm): class Meta: model = Gallery.Translation
"""
The edit translation tag, receives one extra parameter: format - which can be 'as_p', 'as_ul', 'as_table', it defaults to as_p
to use GalleryForm in template one might do something like that: {% load multilingual_tags %}
{% block content %}
{% edit_translation form "as_ul" "en" %}{% endblock %}
please see attached patch...
- issue-71-poc.patch 5.31KB
Comment #9
Posted on Dec 17, 2009 by Grumpy GiraffeLooking into it, thanks for the info and the patch.
Status: Accepted