old_contents: from django.contrib import admin
  from django.contrib.sites.models import RequestSite
  from django.contrib.sites.models import Site
  from django.utils.translation import ugettext_lazy as _
  
  from models import RegistrationProfile
  from scheduler.models import Need
  
  
  class RegistrationAdmin(admin.ModelAdmin):
      actions = ['activate_users', 'resend_activation_email']
      list_display = ('user', 'activation_key_expired', 'get_user_email')
      raw_id_fields = ['user']
      search_fields = ('user__username', 'user__first_name', 'user__last_name')
  
      def get_field_queryset(self, db, db_field, request):  #
          if db_field.name == 'needs' \
                  and db_field.model._meta.object_name == 'RegistrationProfile':
              return Need.objects.select_related('time_period_from',
                                                 'time_period_to',
                                                 'topic',
                                                 'location')
  
          return super(RegistrationAdmin, self).get_field_queryset(db,
                                                                   db_field,
                                                                   request)
  
      def activate_users(self, request, queryset):
          """
          Activates the selected users, if they are not alrady
          activated.
  
          """
          for profile in queryset:
              RegistrationProfile.objects.activate_user(profile.activation_key)
  
      activate_users.short_description = _("Activate users")
  
      def resend_activation_email(self, request, queryset):
          """
          Re-sends activation emails for the selected users.
  
          Note that this will *only* send activation emails for users
          who are eligible to activate; emails will not be sent to users
          whose activation keys have expired or who have already
          activated.
  
          """
          if Site._meta.installed:
              site = Site.objects.get_current()
          else:
              site = RequestSite(request)
  
          for profile in queryset:
              if not profile.activation_key_expired():
                  profile.send_activation_email(site)
  
      resend_activation_email.short_description = _("Re-send activation emails")
  
  
  admin.site.register(RegistrationProfile, RegistrationAdmin)
  
new_contents: from django.contrib import admin
  from django.contrib.sites.models import RequestSite
  from django.contrib.sites.models import Site
  from django.utils.translation import ugettext_lazy as _
  
  from models import RegistrationProfile
  from scheduler.models import Need
  
  
  class RegistrationAdmin(admin.ModelAdmin):
      actions = ['activate_users', 'resend_activation_email']
      list_display = ('user', 'activation_key_expired', 'get_user_email')
      raw_id_fields = ['user']
      search_fields = ('user__username', 'user__first_name', 'user__last_name')
  
      def get_field_queryset(self, db, db_field, request):  #
          if db_field.name == 'needs' \
                  and db_field.model._meta.object_name == 'RegistrationProfile':
              return Need.objects.select_related('topic',
                                                 'location')
  
          return super(RegistrationAdmin, self).get_field_queryset(db,
                                                                   db_field,
                                                                   request)
  
      def activate_users(self, request, queryset):
          """
          Activates the selected users, if they are not alrady
          activated.
  
          """
          for profile in queryset:
              RegistrationProfile.objects.activate_user(profile.activation_key)
  
      activate_users.short_description = _("Activate users")
  
      def resend_activation_email(self, request, queryset):
          """
          Re-sends activation emails for the selected users.
  
          Note that this will *only* send activation emails for users
          who are eligible to activate; emails will not be sent to users
          whose activation keys have expired or who have already
          activated.
  
          """
          if Site._meta.installed:
              site = Site.objects.get_current()
          else:
              site = RequestSite(request)
  
          for profile in queryset:
              if not profile.activation_key_expired():
                  profile.send_activation_email(site)
  
      resend_activation_email.short_description = _("Re-send activation emails")
  
  
  admin.site.register(RegistrationProfile, RegistrationAdmin)
  
subject: Fix for changed Need datamodel