Random space inserted into UUID for email link

For some reason, random space is inserted into the record UUID. I am sending emails to people to click on confirmation or to cancel links to update records in my database. I use UUIDs to make sure they update the correct entry.

I am creating HTML for the link in my form.py. If I only have cancel_donation_link, it works fine. After adding a confirmation link. It adds a space between the canceled UUID of the link.

for special_word in values['special_words']:                     
    print special_word                                           
    text = values['text']                                        
    print text                                                   
    uuid = rescheduled_donor.uuid                                

    if special_word == "confirm_donation_link":                  
        values['text'] = text.replace(                           
            special_word,                                        
            '<a href="http://{0}/actions/email_blasts/confirm/' \
            '{1}">Confirm Donation</a>'.format(                  
                domain,                                          
                uuid                                             
            )                                                    
        )                                                        
        values['special_words'].remove(special_word)             
        continue                                                 

     if special_word == "cancel_donation_link":                  
         values['text'] = text.replace(                          
             special_word,                                       
             '<a href="http://{0}/actions/email_blasts/cancel/' \
             '{1}">Cancel</a>'.format(                           
                 domain,                                         
                 uuid                                            
             )                                                   
         )                                                       
         values['special_words'].remove(special_word)    
         continue        

Before sending the whole context to the email template, I print out an html that does not show the space between the UUIDs

<div>If you wish to cancel your donation click here:&nbsp; <a href="http://127.0.0.1:8000/actions/ema
il_blasts/cancel/f42f1915-2e6b-401c-bd0f-e99ba54e9ea5">Cancel</a>  </div>

Once the message has been sent, the URL contains a space in the UUID section. It is replaced by% 20. Cancel

template

 <div style="color:#500050">                                            
    <img src="{{ STATIC_URL}}images/email_logo2.jpg">                   
    <p>                                                                 
        {{ message|safe }}                                              
    </p>                                                                

    <p>                                                                 
        {% for image in pages %}                                        
            <img src="{{ MEDIA_URL }}{{ image }}">                      
        {% endfor %}                                                    
    </p>                                                                

    <p>                                                                 
        {{ closing_message|safe }}                                      

    </p>                                                                
 </div>    

~

, .

HTML

<div style="color:#500050">

        </p><div>If you have any questions or need any assistance you may reply by e-mail or call &nbsp;customer service <a href="tel:631-234-0000" value="+16312340000" target="_blank">631-234-0000</a>.<br></div><div><br></div><div><br></div><div>To confirm this new date, click here:&nbsp; <a href="http://127.0.0.1:8000/actions/email_blasts/confirm/1544ce69-3c44-4554-839a-a2fd09f049e3" target="_blank">Confirm Donation</a>  </div><div><br></div><div>To pick a different date, click here:&nbsp; <a href="http://127.0.0.1:8000/external/1544ce69-3c44-4554-839a-a2fd09f049e3/" target="_blank">Donate</a> </div><div><br></div><div>To cancel your donation, click here:&nbsp; <a href="http://127.0.0.1:8000/actions/email_blasts/cancel/1544ce%2069-3c44-4554-839a-a2fd09f049e3" target="_blank">Cancel</a> <br></div>
    <p></p>

    <p>

    </p>

    <p>
        <br>

    </p>
 </div>
+3
1

URL-, reverse reverse. , webfaction.

if special_word == "cancel_donation_link":                              

    values['text'] = text.replace(                           
        special_word,                                        
        '<a href="{0}{1}">Cancel</a>'.format(                
            domain,                                          
            reverse('email_blasts_cancel', kwargs={'donor_uuid': uuid})
        )                                                    
    )     
0

All Articles