title: How to register an app with django.admin?
body: <p>I am following the <a href="https://docs.djangoproject.com/en/1.7/intro/tutorial01/" rel="nofollow">django tutorial</a> and am having some trouble registering my app with the admin interface.</p>
  
  <p>For reference, I made some slight alteration to the documented "polls" app.  Here is my model.py:</p>
  
  <pre><code>import datetime
  
  from django.db import models
  from django.utils import timezone
  
  # Create your models here.
  
  # Survey class groups questions together.
  class Survey(models.Model):
      survey_name = models.CharField('name', max_length=200)
      survey_date = models.DateTimeField('date published')
  
      def __str__(self):
          return self.survey_name
  
      def was_published_recently(self):
          return self.survey_date &gt;= timezone.now() - datetime.timedelta(days=7)
  
  # Question class that may be assigned to a survey.
  class Question(models.Model):
      survey = models.ForeignKey(Survey)
      question_text = models.TextField('question')
  
      def __str__(self):
          return self.question_text
  
  # Choice are individual choices that are linked to questions.
  class Choice(models.Model):
      question = models.ForeignKey(Question)
      choice_text = models.CharField('choice', max_length=200)
      choice_votes = models.IntegerField('votes', default=0)
  
      def __str__(self):
          return self.choice_text
  </code></pre>
  
  <p>My admin.py:</p>
  
  <pre><code>from django.contrib import admin
  
  # Register your models here.
  
  class SurveyAdmin(admin.ModelAdmin):
      fieldsets = [
          (None,               {'fields': ['survey_name']}),
          ('Date Information', {'fields': ['survey_date']}),
      ]
  
  admin.site.register(Survey, SurveyAdmin)
  </code></pre>
  
  <p>But when running my site locally the development server reports:</p>
  
  <pre><code>NameError: name 'Survey' is not defined
  </code></pre>
  
  <p>My urls.py has <code>autodiscover</code>.</p>
  
  <p>Edit: Here is my urls.py:</p>
  
  <pre><code>from django.conf.urls import *  # NOQA
  from django.conf.urls.i18n import i18n_patterns
  from django.contrib.staticfiles.urls import staticfiles_urlpatterns
  from django.contrib import admin
  from django.conf import settings
  from cms.sitemaps import CMSSitemap
  
  admin.autodiscover()
  
  urlpatterns = i18n_patterns('',
      url(r'^admin/', include(admin.site.urls)),  # NOQA
      url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap',
          {'sitemaps': {'cmspages': CMSSitemap}}),
      url(r'^', include('cms.urls')),
  )
  
  # This is only needed when using runserver.
  if settings.DEBUG:
      urlpatterns = patterns('',
          url(r'^media/(?P&lt;path&gt;.*)$', 'django.views.static.serve',  # NOQA
              {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
          ) + staticfiles_urlpatterns() + urlpatterns  # NOQA
  </code></pre>