'str' object has no attribute '_meta' error come when I uncomment admin.autodiscover()
Question: I am facing this error in django:

    
    
    AttributeError at /
    'str' object has no attribute '_meta'
    Request Method: GET
    Request URL:    http://localhost:8000/
    Django Version: 1.3
    Exception Type: AttributeError
    Exception Value:    
    'str' object has no attribute '_meta'
    Exception Location: C:\Python27\lib\site-packages\django\contrib\admin\sites.py in         register, line 80
    Python Executable:  C:\Python27\python.exe
    Python Version: 2.7.2
    Python Path:    ['D:\\programming\\django_projects\\ecomstore',
    'C:\\Python27\\lib\\site-packages\\setuptools-0.6c9-py2.7.egg',
     'C:\\Python27\\lib\\site-packages\\pymysql-0.3-py2.6.egg',
     'C:\\Windows\\system32\\python27.zip',
     'C:\\Python27\\DLLs',
     'C:\\Python27\\lib',
     'C:\\Python27\\lib\\plat-win',
     'C:\\Python27\\lib\\lib-tk',
     'C:\\Python27',
     'C:\\Python27\\lib\\site-packages',
     'C:\\Python27\\lib\\site-packages\\PIL']
     Server time:   Fri, 13 Jan 2012 16:44:18 +0500
    

this error doesn't occur if I comment out `admin.autodiscover()`, also I used
ModelForm in django so is it because of ModelForm? Following is ModelForm
code:

    
    
    from django import forms
    from catalog.models import Product
    
    class ProductAdminForm(forms.ModelForm):
      class Meta:
        model=Product
        def clean_price(self):
            if self.cleaned_data['price']<=0:
                raise forms.ValidationError('Price must be greater than zero')
            return self.cleaned_data['price']
    

So if some one understand the problem then please tell.

Following is traceback, pasted:

    
    
    Environment:
    
    
     Request Method: GET
     Request URL: http://localhost:8000/
    
     Django Version: 1.3
     Python Version: 2.7.2
     Installed Applications:
     ['django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.sites',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'django.contrib.admin',
      'ecomstore.catalog']
     Installed Middleware:
     ('django.middleware.common.CommonMiddleware',
      'django.contrib.sessions.middleware.SessionMiddleware',
      'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware')
    
    
    Traceback:
     File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
     101.                             request.path_info)
     File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in resolve
     250.             for pattern in self.url_patterns:
     File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in _get_url_patterns
     279.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
     File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in _get_urlconf_module
     274.             self._urlconf_module = import_module(self.urlconf_name)
     File "C:\Python27\lib\site-packages\django\utils\importlib.py" in import_module
     35.     __import__(name)
     File "D:\programming\django_projects\ecomstore\..\ecomstore\urls.py" in <module>
     5. admin.autodiscover()
     File "C:\Python27\lib\site-packages\django\contrib\admin\__init__.py" in autodiscover
     26.             import_module('%s.admin' % app)
     File "C:\Python27\lib\site-packages\django\utils\importlib.py" in import_module
     35.     __import__(name)
      File "D:\programming\django_projects\ecomstore\..\ecomstore\catalog\admin.py" in <module>
     19. admin.site.register('Product', 'ProductAdmin')
     File "C:\Python27\lib\site-packages\django\contrib\admin\sites.py" in register
     80.             if model._meta.abstract:
    
     Exception Type: AttributeError at /
     Exception Value: 'str' object has no attribute '_meta'
    


Answer: The issue is this line:

    
    
    admin.site.register('Product', 'ProductAdmin')
    

You have to pass in the class objects, not strings. This should work:

    
    
    admin.site.register(Product, ProductAdmin)
    

