indexError at / xadmin / users / userprofile / 1 / update /

时间:2018-01-27 17:04:58

标签: python django

这是关于xadmin的错误。我可以登录xadmin,但是当我想编辑用户配置文件时,错误如下:

this is what show me after checking users in xadmin.

enter image description here

我的错误是/xadmin / users / userprofile / 1 / update /

中的indexError

有我的个人档案的models.py

class UserProfile(AbstractUser): 
    nick_name=models.CharField(max_length=50,verbose_name="nickname",default="")
    birday=models.DateField(verbose_name="birthday",null=True,blank=True)  
    gender=models.CharField(choices=(("male","male"), ("female","female")),default="",max_length=10)
    address=models.CharField(max_length=100,default="")
    moblie=models.CharField(max_length=11,null=True,blank=True)
    image=models.ImageField(upload_to="image/%Y/%m",default="image/default.png",max_length=100) 

    class Meta:
        verbose_name="user profile"   
        verbose_name_plural=verbose_name

    def __unicode__(self):
        return self.username


class EmailVerifyRecord(models.Model):
    code=models.CharField(max_length=20, verbose_name="verifycode")
    email=models.EmailField(max_length=50, verbose_name="email")
    send_type=models.CharField(choices=(("register","register"),("forget","forget")),max_length=10)
    send_time=models.DateTimeField(default=datetime.now)

    class Meta:
        verbose_name="email verifycode"
        verbose_name_plural=verbose_name


class Banner(models.Model):
    title=models.CharField(max_length=100,verbose_name="title")
    image = models.ImageField(upload_to="banner/%Y/%m",verbose_name="banner images")
    url = models.URLField(max_length=200, verbose_name="url")
    index = models.IntegerField(default=100, verbose_name="order") #播放顺序
    add_time=models.DateTimeField(default=datetime.now,verbose_name="add_time")

    class Meta:
        verbose_name="banner"
        verbose_name_plural=verbose_name

有一些ADMIN.PY代码:

from .models import  UserProfile

 class UserProfileAdmin(admin.ModelAdmin):
    pass

 admin.site.register(UserProfile,UserProfileAdmin)

我已经注册了Userprofile,当我想编辑用户信息时,错误显示如下:

IndexError at /xadmin/users/userprofile/1/update/
list index out of range
Request Method:
GET
Request URL:
http://127.0.0.1:8000/xadmin/users/userprofile/1/update/
Django Version:
2.0.1
Exception Type:
IndexError
Exception Value:
list index out of range
Exception Location:
C:\Users\Harry\PycharmProjects\mxonline\lib\site-packages\xadmin\widgets.py in render, line 80
Python Executable:
C:\Users\Harry\PycharmProjects\mxonline\Scripts\python.exe
Python Version:
3.6.4
Python Path:
['C:\\Users\\Harry\\PycharmProjects\\untitled1\\apps',
 'C:\\Users\\Harry\\PycharmProjects\\untitled1',
 'C:\\Users\\Harry\\PycharmProjects\\untitled1',
 'C:\\Users\\Harry\\PycharmProjects\\untitled1\\apps',
 'C:\\Users\\Harry\\PycharmProjects\\untitled1\\extra_apps',
 'C:\\Users\\Harry\\PycharmProjects\\mxonline\\Scripts\\python36.zip',
 'C:\\Users\\Harry\\PycharmProjects\\mxonline\\DLLs',
 'C:\\Users\\Harry\\PycharmProjects\\mxonline\\lib',
 'C:\\Users\\Harry\\PycharmProjects\\mxonline\\Scripts',
 'c:\\users\\harry\\python36\\Lib',
 'c:\\users\\harry\\python36\\DLLs',
 'C:\\Users\\Harry\\PycharmProjects\\mxonline',
 'C:\\Users\\Harry\\PycharmProjects\\mxonline\\lib\\site-packages',
 'C:\\Program Files\\JetBrains\\PyCharm '
 '2017.3.2\\helpers\\pycharm_matplotlib_backend',
 'C:\\Users\\Harry\\PycharmProjects\\mxonline\\lib\\site-packages\\odf',
 'C:\\Users\\Harry\\PycharmProjects\\mxonline\\lib\\site-packages\\odf',
 'C:\\Users\\Harry\\PycharmProjects\\mxonline\\lib\\site-packages\\odf',
 'C:\\Users\\Harry\\PycharmProjects\\mxonline\\lib\\site-packages\\odf',
 'C:\\Users\\Harry\\PycharmProjects\\mxonline\\lib\\site-packages\\odf',
 'C:\\Users\\Harry\\PycharmProjects\\mxonline\\lib\\site-packages\\odf',
 'C:\\Users\\Harry\\PycharmProjects\\mxonline\\lib\\site-packages\\odf']
Server time:
Sun, 28 Jan 2018 17:54:12 +0000

Error during template rendering
In template C:\Users\Harry\PycharmProjects\mxonline\lib\site-packages\crispy_forms\templates\bootstrap3\field.html, error at line 28
list index out of range
18

19
        {% if field|is_checkboxselectmultiple %}
20
            {% include 'bootstrap3/layout/checkboxselectmultiple.html' %}
21
        {% endif %}
22

23
        {% if field|is_radioselect %}
24
            {% include 'bootstrap3/layout/radioselect.html' %}
25
        {% endif %}
26

27
        {% if not field|is_checkboxselectmultiple and not field|is_radioselect %}
28
            {% if field|is_checkbox and form_show_labels %}
29
                <label for="{{ field.id_for_label }}" class="{% if field.field.required %} requiredField{% endif %}">
30
                    {% crispy_field field %}
31
                    {{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
32
                </label>
33
                {% include 'bootstrap3/layout/help_text_and_errors.html' %}
34
            {% else %}
35
                <div class="controls {{ field_class }}">
36
                    {% crispy_field field %}
37
                    {% include 'bootstrap3/layout/help_text_and_errors.html' %}
38
                </div>

0 个答案:

没有答案