SOLVED: (sort of)
I am not sure if this is the only or best way to solve the problem. But, since I needed to use get_context_data() in the view anyway. I am now doing this to get ct_id into the view template:
def get_context_data(self,**kwargs):
context = super(DvStringUpdateView, self).get_context_data(**kwargs)
semlinks = []
obj = get_object_or_404(DvString,pk=context['object'].id)
if obj.resource_uri:
urilist = obj.resource_uri.splitlines()
attrlist = obj.sem_attr.splitlines()
for n in range(0,len(urilist)):
semlinks.append(attrlist[n] + ' = ' + unquote(urilist[n]))
context['semlinks'] = semlinks
context['ct_id'] = obj.ct_id
return context
Is there a bug in the way the UUIDField is defined causing it to not be available in CBVs? This is at least a workaround.
Cheers,
Tim
On Mon, Jan 20, 2014 at 7:55 PM, Timothy W. Cook <tim@mlhim.org> wrote:
BTW:In the actual code the ct_id field is quaoted correctly. It was just an error in my post here.fields =['published','prj_name','data_name','ct_id',]On Mon, Jan 20, 2014 at 7:03 PM, Timothy W. Cook <tim@mlhim.org> wrote:
I have a web application where I use a couple of UUIDFields. In the Admin UI, in function based views and other Python code, these fields work as expected. However, when trying to list them in the 'fields' in a CBV, I get the error:
FieldError(message) django.core.exceptions.FieldError: Unknown field(s) (ct_id)The subject field here is ct_id. But another one does the same.
From models.py:
ct_id = UUIDField(_("UUID"), version=4, help_text=_('A unique identifier for this PCT.'))As mentioned above, they work in Admin lists:
list_display = ('data_name','prj_name','published','ct_id') admin.site.register(DvBoolean, DvBooleanAdmin)In function based views to create JSON for DynaTree:
pct_json['tooltip'] = 'ct-'+pct.ct_id + " : " +pct.descriptionBut in a CBV, this raises the error:
fields =['published','prj_name','data_name',ct_id,]Any ideas on how to make this work? I only want to render them for display, not for editing.
Thanks,
Tim
PS. This question is also on StackOverflow at: http://goo.gl/mA7I6V
--
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
--
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3XsgqO%2BPCWtd6-XXRzov43vnxbShNk_J3eAaiFViM9oLA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment