发送电子邮件附件(Sending email attachment)
我需要发送一封从SFTP收到的pdf文件,并附上一封电子邮件作为附件。 我只是想看是否可以在不使用自定义管道组件的情况下完成。 是否只能使用SMTP发送端口配置来完成此操作。 怎么能接近这个
I need to send a pdf file received from SFTP with an email as an attachment. I am just looking if this can be done without using custom pipeline component. Can this be done only with SMTP send port configuration. How can this be approached
原文:https://stackoverflow.com/questions/30303475
更新时间:2022-02-05 15:02
最满意答案
primary_key
表示unique=True
。 因此,正如警告所说,您应该使用OneToOneField。
primary_key
impliesunique=True
. So, as the warning says, you should probably be using a OneToOneField.
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
嗯,你能做的最好的就是第二个。 因为在第一篇文章中你只能在一篇文章中投一票。 在第二篇文章中,您可以在一篇文章中获得多个投票,但一次投票只能与一篇文章相关。 我认为这就是你想要的。 Well, the best you can do is the second one. Because in the first one you can only have one vote in one article. In the second one you can have many votes in one art ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
django OneToOneField和ForeignKey有什么区别?(What's the difference between django OneToOneField and ForeignKey?)[2022-04-20]
小心地意识到OneToOneField(SomeModel)和ForeignKey(SomeModel, unique=True)之间有一些区别。 正如Django的最终指南所述: OneToOneField 一对一的关系。 在概念上,这类似于具有unique=True的ForeignKey ,但是该关系的“反向”侧将直接返回单个对象。 与OneToOneField “反向”关系相反, ForeignKey “reverse”关系返回一个QuerySet 。 例 例如,如果我们有以下两个型号(下面的完整型号 ... -
primary_key表示unique=True 。 因此,正如警告所说,您应该使用OneToOneField。 primary_key implies unique=True. So, as the warning says, you should probably be using a OneToOneField.
-
如果您只需添加一个附加字段,则可以将其添加到UserForm 。 class UserForm(ModelForm): enabled = forms.BooleanField(default=True) class Meta: model = User fields = ['name', 'email', ...] 然后,在你的form_valid方法中,你可以设置base_user的值。 由于它是一个创建视图,我假设你必须先创建它。 class Us ...
-
您正在创建UserProfile的新实例,而不是从数据库加载现有的实例。 您可以使用访问OneToOne关系 myuser = MyUser.objects.get(email="dummy@domain.tld") profile = myuser.userprofile # access the onetoone relation profile.website 您可以在django文档中找到有关OneToOne关系的更多信息 You are creating a new instance ...
-
如何将updateview与ForeignKey / OneToOneField一起使用(How to use updateview with a ForeignKey/OneToOneField)[2022-04-09]
您可以使用slug_field和slug_url_kwarg属性: url(r'^moderate/(?P\d+)', ModEdit.as_view(),name='moderation') class Modedit(UpdateView): slug_field = 'issue_id' slug_url_kwarg = 'issue_id' model = ModTool template_name = 'myapp/moderate.html' ... -
OnetoOne意味着每个元组都是唯一的。 我认为你应该使用ForeignKey: class Farm(models.Model): """Keeps track of Townhall""" user = models.ForeignKey(User) template = models.ForeignKey(FarmTemplate) level = models.IntegerField() def __unicode__(self): return "User: %s, Farm le ...
-
如何使用ViewSet更新OneToOneField / ForeignKey?(how to update OneToOneField / ForeignKey using ViewSet? Django)[2023-03-22]
我认为您的序列化程序没有完成...... user和school的领域是实例模型,您需要在序列化程序中使用特定字段来实现实例模型,例如:with source='...'参数。 和例子: class VoteSerializer(serializers.ModelSerializer): # by `username` user = serializers.CharField( source='user.username', read_only=True ...