Skip to content

Instantly share code, notes, and snippets.

@toastdriven
Created March 16, 2012 17:37
Show Gist options
  • Save toastdriven/2051328 to your computer and use it in GitHub Desktop.
Save toastdriven/2051328 to your computer and use it in GitHub Desktop.
from django.contrib.auth.models import User
from tastypie import fields
from tastypie.resources import ModelResource
from profiles.models import Profile
class UserResource(ModelResource):
# Assumes a OneToOneField on the ``Profile``.
bio = fields.CharField(attribute='profile__bio', blank=True, default='', readonly=True)
website = fields.CharField(attribute='profile__website', blank=True, default='', readonly=True)
twitter = fields.CharField(attribute='profile__twitter', blank=True, default='', readonly=True)
class Meta:
queryset = User.objects.all()
excludes = ['email', 'password', 'is_staff', 'is_superuser']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment