部分表单.py你知道吗
公共类(窗体.ModelForm)地址:
class Meta:
model = Publicacao
exclude = ('usuario', 'aprovado', 'cadastrado_em', 'slug')
def enviar(self):
titulo = 'mensagem enviada pelo site'
destino = self.cleaned_data['emailp']
mensagem = u"""
Message that will be sent after completing the form.
Here I must pass a link to the full URL into the body of the email, something like:
[ 1 ]http://www.domain.com/item/playstation3/
/view/slug/
""" % self.cleaned_data
send_mail(
subject = titulo,
message = mensagem,
from_email = 'inform@domain.com',
recipient_list =[destino],
)
[1]我读到关于“反向”的内容,尝试挂载url+view+parameter。 但是我不能正确生成链接,做了很多方法但是不能。你知道吗
我需要传递域名+视图+参数slug是完成表单后生成的。你知道吗
有关电子邮件收件人的信息,请参阅正确的链接。你知道吗
有人能帮我吗? 提前谢谢。你知道吗
使用
reverse()
通常是生成不带域的URL部分的正确方法。例如,如果您的URL配置包含以下内容:接下来的电话
应该返回
/item/playstation3/view/my-slug
。你知道吗最好,您的模型
Publicacao
应该定义一个get_absolute_url
方法,该方法返回模型实例的实际URL。见http://docs.djangoproject.com/en/1.2/ref/models/instances/#get-absolute-url。你知道吗可以使用站点框架检索域名部分:
当然,您必须正确配置站点的域。另见http://docs.djangoproject.com/en/1.2/ref/contrib/sites/#getting-the-current-domain-for-full-urls。你知道吗
伯恩德,谢谢。 关于“反面”我已经知道了。你知道吗
一个简短的例子。 这只是鉴定的问题。http://pastebin.ca/1977489
谢谢,我很抱歉,我还在学Django。你知道吗
相关问题 更多 >
编程相关推荐