Failed to send Email by Django

2023-03-24 Thread bing
I am using the email module in Django to inform of users with their 
registration. Sometimes it can send email successfully, but more often, it 
fails. I searched for many solutions, but did not change this situation.

The following is what I have configured:
settings.py:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.139.com'
EMAIL_PORT = 25
EMAIL_HOST_USER = 'EmailAddress' 
EMAIL_HOST_PASSWORD = ''
EMAIL_FROM = 'xx'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
EMAIL_USE_TLS = False  


views.py:
import smtplib
def sendEmail(subject, message, from_email, to_email):
try:
send_mail(subject, message, from_email, [to_email], fail_silently=
False)
return True
except smtplib.SMTPException as e:
print(e)
return False

Although I used the 'try', 'except' to catch the error, I still find no 
results in the output. Is there anything wrong? I would be very grateful if 
someone can give me some advice. Thanks in advance.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d869f7c6-8e32-428e-a1dc-6c769de3b6afn%40googlegroups.com.


ordering in the ManyRelatedManager object

2008-06-22 Thread Bing

Hi,

I have a general question regarding the ordering in
the ManyRelatedManager object.  For example,
There are two classes in my model:  one is
called Book for books and another is Author for authors.

A many-to-many field is defined  in class Book
authors = models.ManyToManyField(Author)

In database, the many-to-many relationship
is described in an additional table book_author
with three columns: (id, book_id, author_id)

Now for a Book object b, both b.authors.all() and b.authors.iterator()
are sorted in the order of book_author.author_id.
But what I want is to retrieve the authors of b
in the order of book_author.id because this is
the right order of the authors.

Any solution? Many thanks in advance!



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



deploying django at unix/linux homepage space without root access

2008-05-05 Thread Bing

I have a small django application which is running on a development
server.
The platform is linux and I am able to view the django-powered pages
at the url like
   http://127.0.0.1:8000/
Now if I want to deploy the website so that other people can visit it
under
my homepage space, http://name.of.some.site/~user/
what should I do?

I am looking at the
http://www.djangoproject.com/documentation/modpython/
and am wondering if something can be done without bugging my system
admin.
Is it possible that I can still use the existing default apache
service
without creating a new one on a different port?

Any hints? Many thanks in advance!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---