django choice字段模板展示


class UserInfo(AbstractUserInfo):
"""
用戶表
"""
gender_choice = (
(1,"男"),
(2,"女"),
)
depart = models.ForeignKey(verbose_name='部門', to='Department')
gender = models.IntegerField(verbose_name="性別",choices=gender_choice,default=1)
email = models.EmailField(verbose_name='郵箱')
phone = models.CharField(verbose_name='手機', max_length=32)


前端展示
{% for row in queryset %}
<tr>
<td>{{ row.username }}</td>
<td>{{ row.get_gender_display }}</td>
<td>{{ row.password }}</td>
<td>{{ row.roles.title }}</td>
<td>{{ row.depart.title }}</td>
<td>{{ row.email }}</td>
<td>{{ row.phone }}</td>


<td>


python manage.py migrate --fake   不去數據庫創建表


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM