/dememe.html
<!DOCTYPE html>
<html>
<head>
<title>Doktor Ekleme</title>
<link rel="stylesheet" type="text/css" href="/dosyalar/base.css" />
</head>
<body>
<h1>Doktor Ekle</h1>
<form action="/deneme/" method="POST">
{% csrf_token %}
<input maxlength="50" name="adi" type="text" value=""/>
<input type="submit" value="Gönder" class="default" name="save">
</form>
</body>
</html>
/views.py
from django.http import *
from django.template import RequestContext
def deneme(request):
if request.method=='POST':
adi=request.POST.get('adi')
kaydet=doktor(adi=adi)
kaydet.save()
return render_to_response('deneme.html',context_instance = RequestContext(request))
那个代码不是错误而是保存
/models.py
from django.db import models
class doktor(models.Model):
adi = models.CharField(max_length='50')
def __str__(self):
return 'adi :%s' %(self.adi)
没有错误但没有保存
/urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
import portal_site.views
import yonetim.views
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'DernekPortali.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'', include('portal_site.urls')),
url(r'', include('yonetim.urls')),
url(r'^deneme/',yonetim.views.deneme),
)
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
错误在哪里?这是代码。不保存数据库!! 帮助我 帮助我 帮助我plsss
代码没有错误但代码没有保存
答案 0 :(得分:0)
解散:)))))
/。views.py
def deneme(request):
替换
def xx(request):
/。urls.py
url(r'^deneme/',yonetim.views.deneme),
替换
url(r'^deneme/',yonetim.views.xx),
那是错误=&gt;相同的变量