From Django.forms.util Import Smart_unicode Error
Contents |
Previous TicketNext Ticket → Opened 2 years ago Closed 2 years ago #23412 closed Bug (invalid) Unable to import django.forms.util.ValidationError Reported by: Nathan Osman Owned by: nobody Component: Forms Version: 1.7 Severity: Normal Keywords: Cc: Triage Stage: cannot import name smart_unicode Unreviewed Has patch: no Needs documentation: no Needs tests: no Patch needs improvement:
Cannot Import Name Smart_unicode Django
no Easy pickings: no UI/UX: no Description I ran the following commands on a completely clean installation of Ubuntu django smart_text Server 14.04.1: apt-get install python-pip pip install Django I then opened the Python interpreter and ran the following commands: Python 2.7.6 (default, Mar 22 2014, 22:59:56) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from django import forms >>> forms.util.ValidationError Traceback (most recent call last): File "
Sign in Pricing Blog Support Search GitHub This repository Watch 7 Star 49 Fork 17 ui/django-html_sanitizer Code Issues 0 Pull requests 0 Projects 0 Pulse Graphs New issue Python3 import smart_unicode #8 Closed hound672 opened this Issue Aug 20, 2015 · 3 comments Projects None yet Labels None yet https://code.djangoproject.com/ticket/23412 Milestone No milestone Assignees No one assigned 3 participants hound672 commented Aug 20, 2015 Hi, I get import error: ile "/lib/python3.4/site-packages/sanitizer/models.py", line 3, in from django.utils.encoding import smart_unicode ImportError: cannot import name 'smart_unicode' After replace in your models.py 'smart_unicode' to 'smart_text as smart_unicode' https://github.com/ui/django-html_sanitizer/issues/8 the error is gone. Collaborator selwin commented Aug 21, 2015 Could you please make a pull request for this? kckrinke commented Oct 20, 2015 @selwin - I've made a pull request for this and another issue that I found with py3.4 (basestring). Collaborator selwin commented Oct 20, 2015 Fixed in #9 . Thanks @kckrinke ! selwin closed this Oct 20, 2015 Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment Contact GitHub API Training Shop Blog About © 2016 GitHub, Inc. Terms Privacy Security Status Help You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Sign in Pricing Blog Support Search GitHub https://github.com/jschrewe/django-mongodbforms/blob/master/mongodbforms/fields.py This repository Watch 13 Star 85 Fork 80 jschrewe/django-mongodbforms Code Issues 20 Pull requests 2 Projects 0 Pulse Graphs Permalink Branch: https://searchcode.com/file/75055360/mptt/forms.py master Switch branches/tags Branches Tags master Nothing to show 0.2.2 0.2.1 0.2 0.1.3 Nothing to show Find file Copy path django-mongodbforms/mongodbforms/fields.py cannot import Fetching contributors… Cannot retrieve contributors at this time Raw Blame History 401 lines (324 sloc) 13.5 KB # -*- coding: utf-8 -*- """ Based on django mongotools (https://github.com/wpjunior/django-mongotools) by Wilson JĂșnior (wilsonpjunior@gmail.com). """ import copy from django import forms from django.core.validators import (EMPTY_VALUES, cannot import name MinLengthValidator, MaxLengthValidator) try: from django.utils.encoding import force_text as force_unicode except ImportError: from django.utils.encoding import force_unicode try: from django.utils.encoding import smart_text as smart_unicode except ImportError: try: from django.utils.encoding import smart_unicode except ImportError: from django.forms.util import smart_unicode from django.utils.translation import ugettext_lazy as _ from django.forms.util import ErrorList from django.core.exceptions import ValidationError try: # objectid was moved into bson in pymongo 1.9 from bson.errors import InvalidId except ImportError: from pymongo.errors import InvalidId from mongodbforms.widgets import ListWidget, MapWidget, HiddenMapWidget class MongoChoiceIterator(object): def __init__(self, field): self.field = field self.queryset = field.queryset def __iter__(self): if self.field.empty_label is not None: yield ("", self.field.empty_label) for obj in self.queryset.all(): yield self.choice(obj) def __len__(self): return len(self.queryset) def choice(self, obj): return (self.field.prepare_value(obj), self.field.label_from_instance(obj)) class NormalizeValueMixin(object): """ mongoengine doesn't treat fields that return an empty string as empt
Python Lines 176 MD5 Hash 7c36623ffe4e405bd011a4b984f11772 Repository https://github.com/niotech/django-mptt.git View Raw File Find Similar Files View File Tree 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175""" Form components for working with trees. """ from django import forms from django.forms.forms import NON_FIELD_ERRORS from django.forms.util import ErrorList from django.utils.encoding import smart_unicode from django.utils.html import conditional_escape, mark_safe from django.utils.translation import ugettext_lazy as _ from mptt.exceptions import InvalidMove __all__ = ('TreeNodeChoiceField', 'TreeNodeMultipleChoiceField', 'TreeNodePositionField', 'MoveNodeForm') # Fields ###################################################################### class TreeNodeChoiceField(forms.ModelChoiceField): """A ModelChoiceField for tree nodes.""" def __init__(self, queryset, *args, **kwargs): self.level_indicator = kwargs.pop('level_indicator', u'---') # if a queryset is supplied, enforce ordering if hasattr(queryset, 'model'): mptt_opts = queryset.model._mptt_meta queryset = queryset.order_by(mptt_opts.tree_id_attr, mptt_opts.left_attr) super(TreeNodeChoiceField, self).__init__(queryset, *args, **kwargs) def _get_level_indicator(self, obj): level = getattr(obj, obj._mptt_meta.level_attr) return mark_safe(conditional_escape(self.level_indicator) * level) def label_from_instance(self, obj): """ Creates labels which represent the tree level of each node when generating option labels. """ level_indicator = self._get_level_indicator(obj) return mark_safe(u'%s %s' % (level_indicator, conditional_escape(smart_unicode(obj)))) class TreeNodeMultipleChoiceField(TreeNodeChoiceField, forms.ModelMultipleChoiceField): """A ModelMultipleChoiceField for tree nodes.""" def __init__(self, queryset, *args, **kwargs): self.level_indicator = kwargs.pop('level_indicator', u'---') # if a queryset is supplied, enforce ordering if hasattr(queryset, 'model')