尝试上传文件时,我无法在商店中获得正确的价值.而不是文件内容,我得到类似的东西{ 0: {} }.这是代码:
const renderInput = field => (
<div>
<input {...field.input} type={field.type}/>
{
field.meta.touched &&
field.meta.error &&
<span className={styles.error}>{field.meta.error}</span>
}
</div>
);
render() {
...
<form className={styles.form} onSubmit={handleSubmit(submit)}>
<div className={styles.interface}>
<label>userpic</label>
<Field
name="userpic"
component={renderInput}
type="file"
/>
</div>
<div>
<button type="submit" disabled={submitting}>Submit</button>
<div>
</form>
...
}
Run Code Online (Sandbox Code Playgroud)
我发现的网络上的所有示例都是使用redux-form的v5制作的.
如何在redux-form v6中进行文件输入?
我正在努力弄清楚uwsgi服务器django或pyramid应用程序处理多个请求的大局.
我现在的理解是: 当多个http请求同时发送到uwsgi服务器时,服务器为每个请求创建一个单独的进程或线程(自身的副本)(或者为它们分配请求),并且每个 进程/线程加载webapplication的代码(比如django或金字塔)进入计算机内存并执行它并返回响应.在每个代码副本之间可以访问会话,缓存或数据库.通常有一个单独的数据库服务器,它还可以处理对数据库的并发请求.
所以这里有一些我正在与之抗争的问题.
我已经搜索了这些问题,并在StackOverflow上找到了非常有趣的答案,但无论如何都无法全面了解,整个过程对我来说仍然是一个谜.如果有人能用uwsgi或任何网络服务器用django或金字塔解释整个画面,那将是太棒了.
很抱歉提出一些愚蠢的问题,但他们每晚真的折磨我,我期待着你的帮助:)
我想在React应用程序中发出一个http请求,我想知道最好的方法是什么.我知道在Angular中你可以使用$http.get,所以类似于:
$http.get('API').success(function(data) {...
Run Code Online (Sandbox Code Playgroud)
但是我可以在React App中为同一目的使用什么.像Axios这样的东西会起作用吗?
请原谅我的无知,这里有新手.
似乎login_required@decorator 对我没有任何作用。如果用户未登录并调用注册,我希望它重定向到登录页面。我是不是错过了什么。我什至尝试设置,@login_required(login_url='/login/')但没有成功。
我已经确保设置LOGIN_URL和
LOGIN_URL_REDIRECT。所有必需的参数都在INSTALLED_APPS和 middleware_classes 中。我正在使用最新的 django 1.9
def user_login(request):
if request.method == 'POST':
form = LoginForm(request.POST)
username = request.POST['username']
password = request.POST['password']
print "u %s p:%s" % (username, password)
user = authenticate(username=username, password=password)
print "Authentication done"
if user is not None:
print "logging in"
login(request, user)
return HttpResponseRedirect(request.POST['next'])
else:
print("The username and password were incorrect.")
else:
form = LoginForm()
return render(request, 'login.html', {'loginForm': form})
@login_required
def registration(request):
dosomething...
class LoginForm(forms.ModelForm): …Run Code Online (Sandbox Code Playgroud) django ×2
javascript ×2
node.js ×1
pyramid ×1
python ×1
reactjs ×1
redux ×1
redux-form ×1
web ×1
webserver ×1