To fix the issue you can do The real tricky part isn't parsing the emails, but getting the emails from your server. There are three ways I can think of doing this: Use php's imap library http://php.net/manual/en/book.imap.php. I personally haven't worked with it very much but since you're just fetching all emails, it might be useful. The downside is that you'll end up fetching all of your other mails as well. Use a 3rd-party service to handle the imap and expose your email via a simpler REST interface. Ideally you'd want to search for a key term (maybe "user signed up") and then parse it. Use offlineimap to download all the emails as a Maildir and store it localy. Now you can use PHP to search all the emails and it'll be faster and easier to test the version here.
Creating a form to send multiple emails to existing emails using Rails
Hope this helps If you install Django debugtoolbar you could actually see the queries being fired, and the code responsible on firing them. This slowness is mainly because django fires a new db query every time you do e.mobile and e.contact_owner, in the loop.
wish of those help There is a lot of very very odd code in this question. Some pointers: There is no point in setting username in the session, since the user is already available via the request. if 'username' is None compares the literal string "username" with None, which is never going to be True. You should redirect to the home page if the user is not logged in, not render the home page template. Don't use has_key; the correct way to determine if a dict has a key is if key in dict. Don't compare things with == False. The result of the expression (in or has_key) is already a boolean which is true or false. You completely ignore the form, since you compare all the values directly with request.POST. You should be using the form.cleaned_data dict after calling form.is_valid(). But you don't need to compare those things anyway, since they are precisely the things that are caught by form validation; that's the whole point. You can't pass keyword arguments to a form. You pass the data dictionary, ie request.POST. Then call is_valid and save. The result of instantiating a form class is, well, a form instance, not a model instance. The model instance comes from calling form.save(). instance.Comment += 1 literally makes no sense at all; neither the form nor the model has a Comment attribute. Never ever ever do a blank try/except. That just hides the errors. Remove those statements completely.
Creating multiple objects with one request in Django and Django Rest Framework