from django.db import models
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect

class FacebookProfileModel(models.Model):
    '''
    Abstract class to add to your profile model.
    
    NOTE: If you don't use this this abstract class, make sure you copy/paste
    the fields in.
    '''
    about_me = models.TextField(blank=True, null=True)
    facebook_id = models.IntegerField(blank=True, null=True)
    facebook_name = models.CharField(max_length=255, blank=True, null=True)
    facebook_profile_url = models.TextField(blank=True, null=True)
    website_url = models.TextField(blank=True, null=True)
    blog_url = models.TextField(blank=True, null=True)
    image = models.ImageField(blank=True, null=True, upload_to='profile_images')
    date_of_birth = models.DateField(blank=True, null=True)
    raw_data = models.TextField(blank=True, null=True)

    def __unicode__(self):
        return self.user.__unicode__()
    
    class Meta:
        abstract = True
        
    def post_facebook_registration(self):
        '''
        Behaviour after registering with facebook
        '''
        url = reverse('facebook_connect')
        response = HttpResponseRedirect(url)
        response.set_cookie('fresh_registration', self.user.id)
        return response


        

from django.db import models
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect

class FacebookProfileModel(models.Model):
    '''
    Abstract class to add to your profile model.
    
    NOTE: If you don't use this this abstract class, make sure you copy/paste
    the fields in.
    '''
    about_me = models.TextField(blank=True, null=True)
    facebook_id = models.IntegerField(blank=True, null=True)
    facebook_name = models.CharField(max_length=255, blank=True, null=True)
    facebook_profile_url = models.TextField(blank=True, null=True)
    website_url = models.TextField(blank=True, null=True)
    blog_url = models.TextField(blank=True, null=True)
    image = models.ImageField(blank=True, null=True, upload_to='profile_images', max_length=255)
    date_of_birth = models.DateField(blank=True, null=True)
    raw_data = models.TextField(blank=True, null=True)

    def __unicode__(self):
        return self.user.__unicode__()
    
    class Meta:
        abstract = True
        
    def post_facebook_registration(self):
        '''
        Behaviour after registering with facebook
        '''
        url = reverse('facebook_connect')
        response = HttpResponseRedirect(url)
        response.set_cookie('fresh_registration', self.user.id)
        return response


        

Allow for a longer image path
Allow for a longer image path

My profile image for example does not fit
in the default VARCHAR(100)

  from django.db import models
  from django.core.urlresolvers import reverse
  from django.http import HttpResponseRedirect
  
  class FacebookProfileModel(models.Model):
      '''
      Abstract class to add to your profile model.
      
      NOTE: If you don't use this this abstract class, make sure you copy/paste
      the fields in.
      '''
      about_me = models.TextField(blank=True, null=True)
      facebook_id = models.IntegerField(blank=True, null=True)
      facebook_name = models.CharField(max_length=255, blank=True, null=True)
      facebook_profile_url = models.TextField(blank=True, null=True)
      website_url = models.TextField(blank=True, null=True)
      blog_url = models.TextField(blank=True, null=True)
-     image = models.ImageField(blank=True, null=True, upload_to='profile_images')
+     image = models.ImageField(blank=True, null=True, upload_to='profile_images', max_length=255)
      date_of_birth = models.DateField(blank=True, null=True)
      raw_data = models.TextField(blank=True, null=True)
  
      def __unicode__(self):
          return self.user.__unicode__()
      
      class Meta:
          abstract = True
          
      def post_facebook_registration(self):
          '''
          Behaviour after registering with facebook
          '''
          url = reverse('facebook_connect')
          response = HttpResponseRedirect(url)
          response.set_cookie('fresh_registration', self.user.id)
          return response
  
  
          
  
Allow for a longer image path
## Code Before:
from django.db import models
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect

class FacebookProfileModel(models.Model):
    '''
    Abstract class to add to your profile model.
    
    NOTE: If you don't use this this abstract class, make sure you copy/paste
    the fields in.
    '''
    about_me = models.TextField(blank=True, null=True)
    facebook_id = models.IntegerField(blank=True, null=True)
    facebook_name = models.CharField(max_length=255, blank=True, null=True)
    facebook_profile_url = models.TextField(blank=True, null=True)
    website_url = models.TextField(blank=True, null=True)
    blog_url = models.TextField(blank=True, null=True)
    image = models.ImageField(blank=True, null=True, upload_to='profile_images')
    date_of_birth = models.DateField(blank=True, null=True)
    raw_data = models.TextField(blank=True, null=True)

    def __unicode__(self):
        return self.user.__unicode__()
    
    class Meta:
        abstract = True
        
    def post_facebook_registration(self):
        '''
        Behaviour after registering with facebook
        '''
        url = reverse('facebook_connect')
        response = HttpResponseRedirect(url)
        response.set_cookie('fresh_registration', self.user.id)
        return response


        

## Instruction:
Allow for a longer image path
## Code After:
from django.db import models
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect

class FacebookProfileModel(models.Model):
    '''
    Abstract class to add to your profile model.
    
    NOTE: If you don't use this this abstract class, make sure you copy/paste
    the fields in.
    '''
    about_me = models.TextField(blank=True, null=True)
    facebook_id = models.IntegerField(blank=True, null=True)
    facebook_name = models.CharField(max_length=255, blank=True, null=True)
    facebook_profile_url = models.TextField(blank=True, null=True)
    website_url = models.TextField(blank=True, null=True)
    blog_url = models.TextField(blank=True, null=True)
    image = models.ImageField(blank=True, null=True, upload_to='profile_images', max_length=255)
    date_of_birth = models.DateField(blank=True, null=True)
    raw_data = models.TextField(blank=True, null=True)

    def __unicode__(self):
        return self.user.__unicode__()
    
    class Meta:
        abstract = True
        
    def post_facebook_registration(self):
        '''
        Behaviour after registering with facebook
        '''
        url = reverse('facebook_connect')
        response = HttpResponseRedirect(url)
        response.set_cookie('fresh_registration', self.user.id)
        return response


        
