/ / potrzebujesz pomocy w subskrypcji e-mail w django (python) - django

potrzebuję pomocy w subskrypcji e-mail w django (python) - django

robię prosty projekt subskrypcji e-mail.mam plik html, który ma pole tekstowe e-mail. A teraz chcę uzyskać wpisaną wartość e-mail ze strony html i zapisać ją w bazie danych mysql. aby zrozumieć poprawnie.i sprawdziłem także stronę internetową dangoproject.can może po prostu wyjaśnić mi, jak to zrobić.

email.html

<html>
<head>
</head>
<body>
<form action="." method=POST>
enter email<input type =text name="email">
<input type=submit value="submit">
</form>
</body>
</html>

models.py

from django.db import models
class ferpost(models.Model):
useremail=models.CharField(max_length=50)

views.py

from django.http import HttpResponse
from django.shortcuts import render_to_response
def ind(request):
name=request.POST["form-email"]
print name
return render_to_response("email.html")

urls.py

 urlpatterns = patterns("",
# Examples:
# url(r"^$", "webapp1.views.home", name="home"),
# url(r"^webapp1/", include("webapp1.foo.urls")),

# Uncomment the admin/doc line below to enable admin documentation:
# url(r"^admin/doc/", include("django.contrib.admindocs.urls")),

# Uncomment the next line to enable the admin:
# url(r"^admin/", include(admin.site.urls)),
url(r"^$","app1.views.ind"),
)

settings.py

 INSTALLED_APPS = (
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.sites",
"django.contrib.messages",
"django.contrib.staticfiles",
#Uncomment the next line to enable the admin:
"django.contrib.admin",
# Uncomment the next line to enable admin documentation:
"django.contrib.admindocs",
"app1",#this is my app name
)

Odpowiedzi:

0 dla odpowiedzi № 1

Pobierz wiadomość e-mail z danych POST (querydictionary), zapisz ją w klasie modelu i gotowe. Twoim zdaniem

def ind(request):
email = request.POST.get("email", "noting@nothing.com")
f = ferpost(useremail=email)
f.save()