[Django] #27519: Issue in Django 1.8.5 model class

6 views
Skip to first unread message

Django

unread,
Nov 21, 2016, 9:58:04 AM11/21/16
to django-...@googlegroups.com
#27519: Issue in Django 1.8.5 model class
-------------------------------------+-------------------------------------
Reporter: Nitish | Owner: nobody
Nandanan |
Type: Bug | Status: new
Component: Database | Version: 1.8
layer (models, ORM) |
Severity: Normal | Keywords: model class bug
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Hi Team,

I am a Django developer. Here I am using Django 1.8.5 version to develop
the application. I am facing one issue with Django model class.

Below is one sample model class which I am using in my application,

class Subgroup(models.Model):
subgroupname = models.TextField(max_length=50,null=True,blank=True)
description = models.TextField(null = True,blank = True)
workgroup = models.ForeignKey(Workgroup)
rowstamp = models.IntegerField(null=True, blank=True)
active = models.BooleanField(default=True)
group_leader = models.ForeignKey(UserProfile, null=True, blank=True)

def __str__(self):
return self.subgroupname

class Meta:
verbose_name_plural = "Subgroups"


The above model class is returning "Subgroup Name" as a value of that
object. We have a our own admin interface area to enter this subgroup
name and values for the above model class. If any invalid characters (eg:-
'→' ) included in the subgroup name, Django will throw below error, while
rendering this subgroup object in Django templates.

==
==
Error message getting:
==
==

** encoding, errors)\nUnicodeEncodeError: 'ascii' codec can't encode
character u'\\u2013' in position 11: ordinal not in range(128)**

I think Django doesn't have any in-built error handling if any invalid
characters included in the model value.

I am requesting you to check this issue on priority and suggest us a
solution for this

Please let me know if you need any additional information

Thanks & Regards
Nitish Nandanan

--
Ticket URL: <https://code.djangoproject.com/ticket/27519>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 21, 2016, 10:32:30 AM11/21/16
to django-...@googlegroups.com
#27519: Issue in Django 1.8.5 model class
-------------------------------------+-------------------------------------
Reporter: Nitish Nandanan | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution: needsinfo

Keywords: model class bug | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => needsinfo


Old description:

New description:

Hi Team,

I am a Django developer. Here I am using Django 1.8.5 version to develop
the application. I am facing one issue with Django model class.

Below is one sample model class which I am using in my application,
{{{
class Subgroup(models.Model):
subgroupname = models.TextField(max_length=50,null=True,blank=True)
description = models.TextField(null = True,blank = True)
workgroup = models.ForeignKey(Workgroup)
rowstamp = models.IntegerField(null=True, blank=True)
active = models.BooleanField(default=True)
group_leader = models.ForeignKey(UserProfile, null=True, blank=True)

def __str__(self):
return self.subgroupname

class Meta:
verbose_name_plural = "Subgroups"
}}}

The above model class is returning "Subgroup Name" as a value of that
object. We have a our own admin interface area to enter this subgroup
name and values for the above model class. If any invalid characters (eg:-
'→' ) included in the subgroup name, Django will throw below error, while
rendering this subgroup object in Django templates.

Error message:

`** encoding, errors)\nUnicodeEncodeError: 'ascii' codec can't encode


character u'\\u2013' in position 11: ordinal not in range(128)**`

I think Django doesn't have any in-built error handling if any invalid
characters included in the model value.

I am requesting you to check this issue on priority and suggest us a
solution for this

Please let me know if you need any additional information

Thanks & Regards
Nitish Nandanan

--

Comment:

Hi, there's aren't sufficient details here to point to a bug in Django. It
seems more likely that you've made a mistake in your application. Please
[wiki:TicketClosingReasons/UseSupportChannels use our support channels] to
get help and reopen the ticket with more details if that investigation
reveals that Django is at fault.

--
Ticket URL: <https://code.djangoproject.com/ticket/27519#comment:1>

Django

unread,
Nov 22, 2016, 12:49:06 AM11/22/16
to django-...@googlegroups.com
#27519: Issue in Django 1.8.5 model class
-------------------------------------+-------------------------------------
Reporter: Nitish Nandanan | Owner: nobody
Type: Bug | Status: new

Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution:
Keywords: model class bug | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Nitish Nandanan):

* status: closed => new
* resolution: needsinfo =>


Old description:

> Hi Team,
>
> I am a Django developer. Here I am using Django 1.8.5 version to develop
> the application. I am facing one issue with Django model class.
>
> Below is one sample model class which I am using in my application,
> {{{
> class Subgroup(models.Model):
> subgroupname = models.TextField(max_length=50,null=True,blank=True)
> description = models.TextField(null = True,blank = True)
> workgroup = models.ForeignKey(Workgroup)
> rowstamp = models.IntegerField(null=True, blank=True)
> active = models.BooleanField(default=True)
> group_leader = models.ForeignKey(UserProfile, null=True, blank=True)
>
> def __str__(self):
> return self.subgroupname
>
> class Meta:
> verbose_name_plural = "Subgroups"
> }}}
>
> The above model class is returning "Subgroup Name" as a value of that
> object. We have a our own admin interface area to enter this subgroup
> name and values for the above model class. If any invalid characters
> (eg:- '→' ) included in the subgroup name, Django will throw below
> error, while rendering this subgroup object in Django templates.
>

> Error message:
>
> `** encoding, errors)\nUnicodeEncodeError: 'ascii' codec can't encode


> character u'\\u2013' in position 11: ordinal not in range(128)**`
>
> I think Django doesn't have any in-built error handling if any invalid
> characters included in the model value.
>
> I am requesting you to check this issue on priority and suggest us a
> solution for this
>
> Please let me know if you need any additional information
>
> Thanks & Regards
> Nitish Nandanan

New description:

Hi Team,

I am a Django developer. I am using Django 1.8.5 version to develop my
application. I am facing one issue with Django model class. I have one
model class and it's returning a text value. If any invalid characters
(eg:- '→' ) are included in this return text value, Django will throwing
an error. Its huge impact on my application.

We have a UI interface to enter value to this model class. By mistake any
user is entering invalid charactes or copy and pasting some text value
from other sources, chances to include invalid characters into this field.
I can see that by default Django doesn't have any validation for prevent
this invalid characters. Instead of this, its directly throwing the error.

Below is one sample model class which I am using in my application,
{{{
class Subgroup(models.Model):
subgroupname = models.TextField(max_length=50,null=True,blank=True)
description = models.TextField(null = True,blank = True)
workgroup = models.ForeignKey(Workgroup)
rowstamp = models.IntegerField(null=True, blank=True)
active = models.BooleanField(default=True)
group_leader = models.ForeignKey(UserProfile, null=True, blank=True)

def __str__(self):
return self.subgroupname

class Meta:
verbose_name_plural = "Subgroups"
}}}

The above model class "Subgroup Name" is the return value. We have a our


own admin interface area to enter this subgroup name and values for the
above model class. If any invalid characters (eg:- '→' ) included in the
subgroup name, Django will throw below error

Error message:

`** encoding, errors)\nUnicodeEncodeError: 'ascii' codec can't encode


character u'\\u2013' in position 11: ordinal not in range(128)**`

I think Django doesn't have any in-built error handling if any invalid
characters included in the model value.

I am requesting you to check this issue on priority and suggest us a
solution for this

Please let me know if you need any additional information

Thanks & Regards
Nitish Nandanan

--

--
Ticket URL: <https://code.djangoproject.com/ticket/27519#comment:2>

Django

unread,
Nov 22, 2016, 2:18:27 AM11/22/16
to django-...@googlegroups.com
#27519: Issue in Django 1.8.5 model class
-------------------------------------+-------------------------------------
Reporter: Nitish Nandanan | Owner: nobody
Type: Bug | Status: closed

Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution: invalid

Keywords: model class bug | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* status: new => closed

* resolution: => invalid


Comment:

I looks like you are using Python 2 to return a `unicode` from your
`__str__` method. If you are using Python you should define a
`__unicode__` method instead.

--
Ticket URL: <https://code.djangoproject.com/ticket/27519#comment:3>

Reply all
Reply to author
Forward
0 new messages