Hi all,

As I am trying to extend the django user model not using the
auth_profile

I have model like this

class Profile(models.Model):
    """KSK Employee accounts to use this application"""

    user = models.ForeignKey(User, unique=True)
    department = models.CharField(maxlength=3,
choices=DEPARTMENT_LIST)
    level = models.CharField(maxlength=3, choices=LEVEL_LIST)



    class Admin:
        pass

    def _get_username(self):
        return self.user.username

    username = property(fget=_get_username)

In order to make use of the profile model as easy as the django user
model

I can make a middleware like this

from ksk.main.models import Profile

class ProfileMiddleware(object):
    """Use to synchronize django user and ksk profile"""

    def process_request(self, request):
        if request.user.is_authenticated():
            request.profile = Profile.objects.get(user = request.user)
        else:
            request.profile = None

and with context_processors like this

def profile(request):
    return {'profile': request.profile}


or just use only context_processors like this

from ksk.main.models import Profile
def profile(request):
    if request.user.is_authenticated():
        profile = Profile.objects.get(user = request.user)
    else:
        profile = None
    return {
         'profile': profile,

    }

both of them works, but I don't have any idea which is better in terms
of design? security? performance?

Thanks
james


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to