1

We're using a subclass of UserAdmin to add our user profile in Django 1.4 app on Google App Engine 1.8.1. Until recently, this worked fine, but the user profile won't show up in our app's admin interface when served from App Engine (i.e. appspot.com). Oddly, however, it still works just fine running on my development machine within the SDK and running under AppEngine Launcher.

Anyone else have any experience with this issue and possibly have a solution?

Here's the code we're using (in admin.py for our app):

admin.site.unregister(User)


class UserProfileInline(admin.StackedInline):
    model = UserProfile


class UserModelAdmin(UserAdmin):
    inlines = [UserProfileInline, ]
    list_display = ('username', )
    search_fields = ['username']


admin.site.register(User, UserModelAdmin)

It's nearly identical to code in a related SO question; the odd thing is it works in my dev environment but NOT on the server. Any ideas?

Community
  • 1
  • 1
foresmac
  • 125
  • 2
  • 8

1 Answers1

0

Turns out the problem was related to a ForeignKey field (school) that had approx 100,000 options to choose from. The query to get all those names to build a drop-down list was timing out on App Engine. The solution was to make that particular related field read only:

class UserProfileInline(admin.StackedInline):
    model = UserProfile
    readonly_fields = ('school', 'file_data')

This didn't really affect our app. The admin is purposefully limited because users should make changes themselves for the most part using forms on the front end; the school field uses an AJAX call to query the database to do a sort of auto-fill, returning matches as a user types in the text field.

foresmac
  • 125
  • 2
  • 8