django CharField 定义

标签 django model

在我经常看到的一些django模型中

myfield = models.CharField(_('myfield'))
class_name = models.CharField(_('Type'), max_length=128)

_ 和 tuple 究竟是做什么用的?我从来没有在官方的 django 教程片段中看到过这样的东西

最佳答案

查看文件顶部,但最常见的是这个重命名的导入:

from django.utils.translation import ugettext as _

(所以它是一个函数调用,而不是一个元组)

关于django CharField 定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11140774/

相关文章:

python - ManyToManyField 在使用自定义主键时引用 'id' 字段

Django-聚合条件子字段

php - DDD、PHP - 在哪里执行验证?

django - django 中的多线程对话(如 Reddit)

ruby-on-rails-3 - 从类方法 : "undefined method" 调用辅助方法

python - 如何将 django 的 TemporaryUploadedFile 视为常规 python 文件

Django 将值从 JQuery UI Slider 传递到 Form

django - 使用两个参数使用 Django DeleteView 进行删除

java - MVC : Is the View allowed to reference mutable elements of the Model without modifying them?

python-3.x - 加载相同保存的模型后,Keras 模型精度不同