如何在默认的Django管理模板Submit_line.html

时间:2018-08-23 18:07:28

标签: django django-models django-templates django-views

我很麻烦,花了将近3天的时间寻找这个问题,但没有得到实际的答案,所以问题是 我已经覆盖了我的submi_line.html

 {% load i18n admin_urls %}
<div class="submit-row">
{% if show_save %}<input type="submit" value="{% trans 'Save' %}" class="default" name="_save" {{ onclick_attrib }}/>{% endif %}
{% if show_delete_link %}<p class="deletelink-box"><a href="{% url opts|admin_urlname:'delete' original.pk|admin_urlquote %}" class="deletelink">{% trans "Delete" %}</a></p>{% endif %}
{% if show_save_as_new %}<input type="submit" value="{% trans 'Save as new' %}" name="_saveasnew" {{ onclick_attrib }}/>{%endif%}
{% if show_save_and_add_another %}<input type="submit" value="{% trans 'Save and add another' %}" name="_addanother" {{onclick_attrib}}/>{% endif %}
{% if show_save_and_continue %}<input type="submit" value="{% trans 'Save and continue editing' %}" name="_continue" {{ onclick_attrib }}/>{% endif %}
</div>

如果我想更改按钮的名称,那么它工作正常。 但是我不知道这{{onclick_attrib}}在这里做什么。我想要如果单击(保存,保存并继续,保存并添加另一个),然后会向用户发送一封自动电子邮件,其中会写上您当前的电子邮件。密码是这个,您可以通过单击此页面来更改密码。电子邮件阅读器必须看到该链接,以便他可以重置密码。MYmodels.py是这个

class Company(models.Model):
class meta:
    db_table = 'user_company'
Company_Name = models.CharField(max_length = 100,blank=False,
    error_messages={'required':'Please provide your name'})
Company_Address = models.CharField(max_length =300,blank=False,
    error_messages = {'required': 'Please provide your  Address.'},)
Company_Phone_Regex = RegexValidator(regex=r'^\+?1?\d{9,15}$', message="Phone number must be entered in the format: '+999999999'. Up to 15 digits allowed.")
Company_Phone_Number = models.CharField(validators=[Company_Phone_Regex], max_length=15, blank=True) # validators should be a list
Company_logo =models.ImageField()
Company_Country = CountryField(blank_label='(select country)')
Admin_Email = models.EmailField(max_length=254, blank=False, unique=True,
                          error_messages={'required': 'Please provide your email address.',
                                          'unique': 'An account with this email exist.'}, )
Password = models.CharField(max_length=50, blank=False, unique=True,
                          error_messages={'required': 'Please provide your Password.'}, )
# Confirm_Password = models.CharField(max_length=254, blank=False, unique=True,
#                           error_messages={'required': 'Please Confirm your password.'},)
# if Password != Confirm_Password:
#         raise Model.add_error('confirm_password', "Password does not match")
Choicesss =(('Invoice', 'Invoice'), 
           ('Receipt','Receipt'),
           ('Application Form', 'Application Form'),)
Use_Case = MultiSelectField(choices= Choicesss, max_choices=3)          
created_date = models.DateTimeField(
        default=timezone.now)

published_date = models.DateTimeField(
        blank=True, null=True)

def publish(self):
    self.published_date = timezone.now()
    self.save()

def __str__(self):
    return self.Company_Name

我希望自动邮件将被发送到Admin_Name,并带有一个用于重置密码的链接。 请提供完整代码帮助我,该代码如何发送自动邮件以重置密码 感谢您阅读本文,我们将不胜感激。 请帮助我,我陷入了严重的麻烦。

0 个答案:

没有答案