0
我想從提交HTML數據的數據庫(PostgreSQL的)。我正在使用Django我學習它。我點擊提交按鈕後,出現以下錯誤Postgres的。數據庫提交從HTML表單
形式爲:
<form action="\polls\Registration" method="POST">
<div class="form-group mb15">
<input type="text" class="form-control" name="userName" placeholder="Enter Your Username" required>
</div>
<div class="form-group mb15">
<input type="text" class="form-control" name="password" placeholder="Enter Your Password">
</div>
<div class="form-group mb15">
<input type="text" class="form-control" name="fullName" placeholder="Enter Your Full Name">
</div>
<div class="form-group mb20">
<label class="ckbox">
<input type="checkbox" name="checkbox">
<span>Accept terms and conditions</span>
</label>
</div>
<div class="form-group">
<button class="btn btn-success btn-quirk btn-block">Create Account</button>
<br>
<a href="/polls/signin" class="btn btn-default btn-quirk btn-stroke btn-stroke-thin btn-block btn-sign">Already a member? Sign In Now!</a>
</div>
</form>
模型爲:
from __future__ import unicode_literals
from django.db import models
# Create your models here.
from django.db import models
from django import forms
class Blog(models.Model):
name = models.CharField(max_length=100)
tagline = models.TextField()
def __str__(self): # __unicode__ on Python 2
return self.name
class Author(models.Model):
name = models.CharField(max_length=50)
email = models.EmailField()
def __str__(self): # __unicode__ on Python 2
return self.name
class Entry(models.Model):
blog = models.ForeignKey(Blog)
headline = models.CharField(max_length=255)
body_text = models.TextField()
pub_date = models.DateField()
mod_date = models.DateField()
authors = models.ManyToManyField(Author)
n_comments = models.IntegerField()
n_pingbacks = models.IntegerField()
rating = models.IntegerField()
def __str__(self): # __unicode__ on Python 2
return self.headline
class Registration(models.Model):
\t userName=forms.CharField(max_length=200)
\t password=forms.CharField(widget=forms.PasswordInput)
\t fullName=forms.CharField(max_length=250)
urls.py
from django.conf.urls import url
from django.contrib import admin
from . import myview
from . import view
from . import models
from django.conf.urls import include,url
urlpatterns = [
url(r'^$', myview.index,name='index'),
url(r'^admin/', admin.site.urls),
url(r'^accounts/', include('registration.backends.simple.urls')),
url(r'^accounts/', include('registration.backends.model_activation.urls')),
#url(r'^$',myview.index1, name='index1'),
#url(r'^$',view.index2, name='index2'),
url(r'^index', myview.index,name='index'),
url(r'^index2', myview.index2,name='index2'),
url(r'^signup', myview.signup,name='signup'),
url(r'^signin', myview.signin,name='signin'),
url(r'^logiin', myview.login,name='login'),
url(r'^auth', myview.auth_view,name='auth_view'),
url(r'^signout', myview.signout,name='signout'),
url(r'^Registration', models.Registration,name='Registration'),
]
我提交後,細節不提交到數據庫表也。
請哪裏是錯誤嗎?任何提示?
太棒了!祝你好運,記住你總是可以問一個描述性的問題,包括你已經嘗試和研究過的[如果]你卡住了! – Sayse
我試過了。請檢查上面編輯的代碼 – Colo
請閱讀[問]。另外,您的'Registration'類沒有任何模型字段 - 只有表單字段。 – Sayse