作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
来自 Django 教程:
我已经定义了我的模型如下:
from django.db import models
import datetime
from django.utils import timezone
# Create your models here.
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self): # Python 3: def __str__(self):
return self.question
def was_published_recently(self):
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
def __unicode__(self): # Python 3: def __str__(self):
return self.choice_text
>>> p = Poll.objects.get(pk=1)
# Display any choices from the related object set -- none so far.
>>> p.choice_set.all()
最佳答案
我不知道你想要多深的解释,但是当你做的时候 Django 会为你定义 poll = models.ForeignKey(Poll)
.
You can read here about it.
关于Django 教程 selection_set,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17566031/
来自 Django 教程: 我已经定义了我的模型如下: from django.db import models import datetime from django.utils import ti
我正在 python 中使用 tkk 构建一个 gui,但我在使用 Treeview 命令 selection_set() 时遇到了问题。我试图在我的程序启动时使用它来设置默认选择,但它似乎无法接受其
通过 selectmode 配置,可以使 Tkinter Listbox 允许选择多个项目。但是,如果我现在以编程方式选择并激活一个条目,那么将 shift 键与向上或向下箭头键组合使用不会将选择范围
我是一名优秀的程序员,十分优秀!