email - django sending mail using pre_save -


1. Déggens is a part of learning, I'm trying to send an email to the email id using the pre_save signal.

2. Mail should be sent to an email ID which is mentioned in the field. I have no proper way of using signals. Here I am models.py and views.py.

  views.py def addbook (): form = BookForm if request.POST: form = BookForm (request.POST) if form.is_valid (): cd = form.cleaned_data form.save ( ) Return Redirects   

products.py pre> class book (models.Model): Book_id = models.AutoField (primary_key = true, unique = true) book_name = models.CharField (max_length = 30) author_name = models.CharField (max_length = 30) publisher_name = model .CharField (max_length = 40) email = models.EmailField ( ) Bookref = models.CharField (max_length = 10) square meta: db_table = u'book 'def __unicode __ (self): return "% d% s% s% s% S"% (self.book_id, self.book_name, Self.author_name, self.publisher_name, self.email, self.bookref)

My requirement is an email that automatically ID

Under book model, create signals function.

  class book (model model): [....... ...] def send_update (sender, example, created, ** kwargs): if example. Auth_name: message = "Book has been updated" topic = "update" send_mail (subject, message, your_email, [instance.email,]) Post_save.connect (send_update, sender = book)   < / Div> 

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -