我一直在尝试使用多个内联表单集来执行基于Django类的CreateView和UpdateView
CreateView工作正常,但UpdateView无法正常工作,如果有人尝试使用多个内联formset的UpdateView,任何人都试过请分享updateview代码片段.
# models.py
from django.db import models
class Recipe(models.Model):
title = models.CharField(max_length=255)
description = models.TextField()
class Ingredient(models.Model):
recipe = models.ForeignKey(Recipe)
description = models.CharField(max_length=255)
class Instruction(models.Model):
recipe = models.ForeignKey(Recipe)
number = models.PositiveSmallIntegerField()
description = models.TextField()
# forms.py
from django.forms import ModelForm
from django.forms.models import inlineformset_factory
from .models import Recipe, Ingredient, Instruction
class RecipeForm(ModelForm):
class Meta:
model = Recipe
IngredientFormSet = inlineformset_factory(Recipe, Ingredient, extra=0)
InstructionFormSet = inlineformset_factory(Recipe, Instruction, extra=0)
# views.py
from django.http import HttpResponseRedirect
from django.views.generic.edit import CreateView, UpdateView
from …Run Code Online (Sandbox Code Playgroud) 我想制作一个包含以下内容的项目:
目录结构,不包括临时文件和其他垃圾:
.
??? Cargo.toml
??? src
? ??? c_bindings.rs // contains C bindings for library
? ??? compression.rs
? ??? const_data.rs
? ??? hash.rs
? ??? lib.rs // library
? ??? main.rs // simple executable that uses library
??? target
??? debug
??? gost_stribog
??? libgost_stribog.rlib
Run Code Online (Sandbox Code Playgroud)
我cargo build要这样做:
c_bindings.rsc_bindings.rs调试目录应为:
??? target
??? debug
??? gost_stribog
??? libgost_stribog.rlib
??? libgost_stribog.so
Run Code Online (Sandbox Code Playgroud)
我应该是什么Cargo.toml样?
我正在尝试在 CentOS 6 上设置 Apache(2.4,从源代码构建)+Django(1.8.12),但是当我尝试登录我的站点或创建用户或其他写入数据库的内容时,我收到错误:
尝试写入只读数据库
我已经尝试过:
无法打开数据库文件
我遵循了这个教程。
我的 httpd.conf (我添加的部分):
LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias / /var/www/project/project/wsgi.py
WSGIPythonPath /var/www/project:/var/www/env/lib/python3.5/site-packages
<Directory /var/www/project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Run Code Online (Sandbox Code Playgroud)
./manage createsuperuser工作正常,用户已添加到数据库。
为了提供媒体服务,我使用 Nginx(所有媒体和静态文件都能正确检索)。
UPD
完整回溯:
Environment:
Request Method: POST
Request URL: http://localhost:8080/accounts/login/
Django Version: 1.8.12
Python Version: 3.5.1
Installed Applications:
('bootstrap3',
'django_admin_bootstrapped',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'macros',
'django_ajax',
'ckeditor',
'accounts',
'main',
'tutor',
'public_testing',
'control_testing', …Run Code Online (Sandbox Code Playgroud)