python_2_unicode_compatible error

后端 未结 6 775
走了就别回头了
走了就别回头了 2020-12-06 10:22

I\'ve models.py as follows,

from django.contrib.auth.models import User
from django.db import models
from django.utils.encoding import python_2_         


        
相关标签:
6条回答
  • 2020-12-06 10:36

    I faced the same issue when I upgrade the Django version 2.x to 3.0. This issue, I faced due to auditlog library.

    First, execute the below command

    pip uninstall auditlog
    

    then

    pip install auditlog3
    
    0 讨论(0)
  • 2020-12-06 10:55

    try

    from django.utils.six import python_2_unicode_compatible
    

    instead of

    from django.utils.encoding import python_2_unicode_compatible
    

    this works well for me in Django 1.10.6

    0 讨论(0)
  • 2020-12-06 10:55

    I ran into this issue when I wanted to use Django for Graphite. Turns out I had Django 1.3 installed and my Graphite version was breaking with Django > 1.5, so installing the latest version of the 1.4 branch fixed the problem:

    sudo pip install --upgrade 'Django<1.5'
    
    0 讨论(0)
  • 2020-12-06 10:56

    For the latest Django 3.0.4 , and auditlog try

    from six import python_2_unicode_compatible
    

    instead of

    from django.utils.six import python_2_unicode_compatible
    

    if it is not install run the below code

    pip install six
    
    0 讨论(0)
  • 2020-12-06 11:00

    python_2_unicode_compatible feature has only been added in Django 1.5 version.

    https://docs.djangoproject.com/en/dev/ref/utils/#django.utils.encoding.python_2_unicode_compatible

    0 讨论(0)
  • 2020-12-06 11:01

    It's actually also present in the 1.4 series since 1.4.2. You should really be using the latest 1.4.X release (1.4.10 as of the time of this writing) as earlier versions have known security vulnerabilities.

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题