views file from django.core.mail import send_mail from django.http import HttpResponse # Create your views here. from django.shortcuts import render,redirect from django.urls import include import datetime from .forms import loginform,modelform def hidemelogin(request): if request.method == 'POST': form=loginform(request.POST) if form.is_valid(): subject = form.cleaned_data['your_name'] message = form.cleaned_data['message'] sender = form.cleaned_data['sender'] cc_myself = form.cleaned_data['cc_myself'] recipients = ['rk3545...@gmail.com'] if cc_myself: recipients.append(sender) print(subject, message,sender, cc_myself,recipients) print(type(form)) return redirect('/hideme/blog/') else : form=loginform() form1=modelform() return render(request,'login.html',{'form':form,'form1':form1}) def hidemehtml(request): print("shiva") return render(request,'index.html',{})
model file from django.db import models class BlogPost(models.Model): id=models.AutoField(primary_key=True) yourname=models.CharField(max_length=20) content=models.TextField(null=True,blank=True) ccself=models.BooleanField(default=True) sender=models.EmailField(blank=False) def __str__(self): return self.yourname # Create your models here. form file from django import forms from .models import BlogPost class loginform(forms.Form): your_name=forms.CharField(label='enter your name', max_length=100) message = forms.CharField(widget=forms.Textarea) sender = forms.EmailField() cc_myself = forms.BooleanField(required=False) class modelform(forms.ModelForm): class meta: model = BlogPost fields=[ "id","name","message","sender","carbon copy" ] -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMsYeuEwMsSZH6R27idvNm5yrokMo8qkQ1xOd19BpdwXW3%2BM%2Bw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.