I'm triying to build a custom admin site. I'm using the newforms library in 0.97-pre.
DEFAULT_CHARSET='utf-8', the database is Mysql and the tables are too utf-8 and the html templates are <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />. All the other things work fine using old-forms, including the admin site. Also,I can load python manage.py shell and work fine with the models and calling the newforms. The code is: def restaurantadmin(request,queryset,slug,slug_field): DataForm = forms.form_for_model(Restaurant) data = {} if request.method == 'POST': form = DataForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect("/") else: form = DataForm(data) return render_to_response('restaurant/restaurant_admin.html', {'form': form}) But I'm getting this error in this view: UnicodeDecodeError at /restaurantes/delirrico/admin/ 'ascii' codec can't decode byte 0xc3 in position 73: ordinal not in range(128) 1 <form action="." method="post"> 2 <table> 3 {{ form }} 4 </table> 5 <input type="submit" value=" Submit " /> 6 </form> Traceback (innermost last) Switch to copy-and-paste view * D:\Programacion\Python\Python24\lib\site-packages\django\template \__init__.py in render_node 716. 717. def render_node(self, node, context): 718. return(node.render(context)) 719. 720. class DebugNodeList(NodeList): 721. def render_node(self, node, context): 722. try: 723. result = node.render(context) ... 724. except TemplateSyntaxError, e: 725. if not hasattr(e, 'source'): 726. e.source = node.source 727. raise 728. except Exception, e: 729. from sys import exc_info ▶ Local vars Variable Value context [{'form': <django.newforms.models.RestaurantForm object at 0x01768B10>}] e <exceptions.UnicodeDecodeError instance at 0x018227B0> exc_info <built-in function exc_info> node <Variable Node: form> self [<Text Node: '<form action="." method="'>, <Variable Node: form>, <Text Node: ' </table> <input ty'>] wrapped <django.template.TemplateSyntaxError instance at 0x01822850> * D:\Programacion\Python\Python24\lib\site-packages\django\template \__init__.py in render 771. def render(self, context): 772. try: 773. output = self.filter_expression.resolve(context) 774. except TemplateSyntaxError, e: 775. if not hasattr(e, 'source'): 776. e.source = self.source 777. raise 778. return self.encode_output(output) ... 779. 780. def generic_tag_compiler(params, defaults, name, node_class, parser, token): 781. "Returns a template.Node subclass." 782. bits = token.split_contents()[1:] 783. bmax = len(params) 784. def_len = defaults and len(defaults) or 0 ▶ Local vars Variable Value context [{'form': <django.newforms.models.RestaurantForm object at 0x01768B10>}] output <django.newforms.models.RestaurantForm object at 0x01768B10> self <Variable Node: form> * D:\Programacion\Python\Python24\lib\site-packages\django\template \__init__.py in encode_output 750. def __repr__(self): 751. return "<Variable Node: %s>" % self.filter_expression 752. 753. def encode_output(self, output): 754. # Check type so that we don't run str() on a Unicode object 755. if not isinstance(output, basestring): 756. try: 757. return str(output) ... 758. except UnicodeEncodeError: 759. # If __str__() returns a Unicode object, convert it to bytestring. 760. return unicode(output).encode(settings.DEFAULT_CHARSET) 761. elif isinstance(output, unicode): 762. return output.encode(settings.DEFAULT_CHARSET) 763. else: ▶ Local vars Variable Value output <django.newforms.models.RestaurantForm object at 0x01768B10> self <Variable Node: form> * D:\Programacion\Python\Python24\lib\site-packages\django\utils \encoding.py in __str__ 24. """ 25. A class whose __str__ returns its __unicode__ as a bytestring 26. according to settings.DEFAULT_CHARSET. 27. 28. Useful as a mix-in. 29. """ 30. def __str__(self): 31. return self.__unicode__().encode(settings.DEFAULT_CHARSET) ... 32. ▶ Local vars Variable Value self <django.newforms.models.RestaurantForm object at 0x01768B10> * D:\Programacion\Python\Python24\lib\site-packages\django\newforms \forms.py in __unicode__ 67. # fields. Because a particular *instance* of the class might want to 68. # alter self.fields, we create self.fields here by copying base_fields. 69. # Instances should always modify self.fields; they should not modify 70. # self.base_fields. 71. self.fields = self.base_fields.copy() 72. 73. def __unicode__(self): 74. return self.as_table() ... 75. 76. def __iter__(self): 77. for name, field in self.fields.items(): 78. yield BoundField(self, field, name) 79. 80. def __getitem__(self, name): ▶ Local vars Variable Value self <django.newforms.models.RestaurantForm object at 0x01768B10> * D:\Programacion\Python\Python24\lib\site-packages\django\newforms \forms.py in as_table 138. output[-1] = last_row[:-len(row_ender)] + str_hidden + row_ender 139. else: # If there aren't any rows in the output, just append the hidden fields. 140. output.append(str_hidden) 141. return u'\n'.join(output) 142. 143. def as_table(self): 144. "Returns this form rendered as HTML <tr>s -- excluding the <table></table>." 145. return self._html_output(u'<tr><th>%(label)s</th><td>% (errors)s%(field)s%(help_text)s</td></tr>', u'<tr><td colspan="2">%s</ td></tr>', '</td></tr>', u'<br />%s', False) ... 146. 147. def as_ul(self): 148. "Returns this form rendered as HTML <li>s -- excluding the <ul></ul>." 149. return self._html_output(u'<li>%(errors)s%(label)s % (field)s%(help_text)s</li>', u'<li>%s</li>', '</li>', u' %s', False) 150. 151. def as_p(self): ▶ Local vars Variable Value self <django.newforms.models.RestaurantForm object at 0x01768B10> * D:\Programacion\Python\Python24\lib\site-packages\django\newforms \forms.py in _html_output 120. top_errors.extend(['(Hidden field %s) %s' % (name, e) for e in bf_errors]) 121. hidden_fields.append(unicode(bf)) 122. else: 123. if errors_on_separate_row and bf_errors: 124. output.append(error_row % bf_errors) 125. label = bf.label and bf.label_tag(escape(bf.label + ':')) or '' 126. if field.help_text: 127. help_text = help_text_html % field.help_text ... 128. else: 129. help_text = u'' 130. output.append(normal_row % {'errors': bf_errors, 'label': label, 'field': unicode(bf), 'help_text': help_text}) 131. if top_errors: 132. output.insert(0, error_row % top_errors) 133. if hidden_fields: # Insert any hidden fields in the last row. ▶ Local vars --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---