我想为我的modelform中的标签创建一个自定义名称,这是我的forms.py
class PostForm(forms.ModelForm):
body = forms.CharField(widget=PagedownWidget)
publish = forms.DateField(
widget=forms.SelectDateWidget,
initial=datetime.date.today,
)
class Meta:
model = Post
fields = [
"title",
"body",
"author",
"image",
"image_url",
"video_path",
"video",
"publish",
"tags",
"status"
]
Run Code Online (Sandbox Code Playgroud)
我想改变而不是视频我希望它说嵌入.我检查了文档,但没有找到任何可以帮助我做到这一点.是不是我不得不重新安排我的模型?如果是这样的话?谢谢
我正在尝试设置我的项目,以便它可以在本地使用环境变量
香港专业教育学院试图将其添加到我的激活文件和其他列表的末尾。我正在尝试使用这个
from .base import *
if os.environ['DJANGO_SERVER_TYPE'] == 'local':
try:
from .local import *
except:
pass
if os.environ['DJANGO_SERVER_TYPE'] == 'production':
try:
from .production import *
except:
pass
Run Code Online (Sandbox Code Playgroud)
我是一个真正的新手,通常情况会简短而事实地解释。因此,全面的解释对我如何实现此感谢确实非常有益。我从来没有做过n Bash。香港专业教育学院试图这样做
export KEY=VALUE
Run Code Online (Sandbox Code Playgroud)
在激活文件中,只是为了使其不被系统识别,我必须将其删除才能使用本地服务器
python django bash development-environment environment-variables
我有几个月的编程经验。我目前正在学习如何在项目中自动化某些事情。我的目标是抓取文本、src 和 href 并将数据存储在我网站的数据库中,但是当我尝试时出现此错误
AttributeError: 'dict' object has no attribute 'text'
Run Code Online (Sandbox Code Playgroud)
但确实如此。这是我的代码。我创建了一个函数
def get_world_too():
url = 'http://www.example.com'
html = requests.get(url, headers=headers)
soup = BeautifulSoup(html.text, 'html5lib')
titles = soup.find_all('section', 'box')[:9]
entries = [{'href': box.a.get('href'),
'src': box.img.get('src'),
'text': box.strong.a.text,
'url': url
} for box in titles]
return entries
Run Code Online (Sandbox Code Playgroud)
然后我做了这个
def noindex(request):
world = get_world_too()
for entry in world:
post = Post()
post.title = entry.text
post.image_url = entry.src
# post.url = entry.url
# post.link = entry.href
# post.description = entry.description
#
# d …Run Code Online (Sandbox Code Playgroud)