Java Jester

August 21, 2008

Manga pictures of me and my honey

Manga pics of me and my honey


sporty, a little geeky (with the ver 1.0 thing on shirt), artsy, sexy, cutey, and almost a rock star chic.

geeky, naughty, also a cutey, sparkling hunk. :D

 

August 15, 2008

Sending email using gmail smtp

It was amazing that the django framework included an easy way to integrate email sending using gmail smtp. I simply added the following code on my setttings.py and the email is sent using gmail smtp:

# use gmail smtp
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'mygmailaccount@gmail.com'
EMAIL_HOST_PASSWORD = 'mypassword123'
EMAIL_PORT = 587

 

 

August 13, 2008

Elegant custom validation in django

At the time of this writing, the official django documentation doesn't teach an elegant way to handle custom form validation. After digging the django source code for a couple of minutes, I learned that I can place custom field validation on form class by defining a method named 'clean_<field_name>(self)'. In my example below, I'm adding custom fields that need to be validated against the database because I don't want any registration using the same email address. The following code shows how to do this:

 

 

class RegistrationForm(forms.ModelForm):

gender = forms.ChoiceField(required=True, widget=forms.RadioSelect, choices=GENDER)
    agree_to_terms = forms.BooleanField(required=True, help_text='You must agree to terms and conditions') 
    email = forms.EmailField(required=True)
    password = forms.CharField(required=True, widget=forms.PasswordInput())
    password2 = forms.CharField(required=True, label='Re-enter password')

def clean_email(self):
    email = self.cleaned_data["email"]
    try:
        User.objects.get(email=email)
    except
        User.DoesNotExist: return email raise forms.ValidationError('This email address is already taken.')

def clean_password2(self):
    password = self.cleaned_data["password"]
    password2 = self.cleaned_data["password2"]
    if password == password2:
        return password2
    raise forms.ValidationError('Confirmation password should be equal to the password')

class Meta:
    model = UserProfile
    exclude = ('user', 'is_activated', 'activation_key', )

 

August 05, 2008

Nokia code camp in the philippines

Just received an invitation to attend the code camp here in the philippines from forum nokia community. I probably have received this because I was an aggressive member of their community 2 years ago.

Registration link:

http://codecamp.forumnokia-apac.com/index.html

 

August 04, 2008

Pinging Google (Re-indexing your links at google)

While playing around with django, I came across a library component called "Sitemap Framework". Its documentation teaches something about "forcing Google to re-index sitemap." I started googling around and found the official documentation from Google on  how to submit sitemap to google. I think this technique is pretty useful so that the links of your website will always be updated.

Going back to django... This framework has a built in module/function called "ping_google" which submits the website's sitemap.xml to Google's search engine. I tried using such and so now I'm still waiting for the web stat logs to verify if google re-indexed my website.

 

 

 

Older Posts >>

recommended books
popular posts
Jester Cap Logo by Vonn reyjexter.com | Valid XHTML & CSS | © 2008 | Design by: vonnhugo

powered by:

djangopython