Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango error: TypeError: 'NoneType' object has no attribute '__getitem__'
    text
    copied!<p>Using Django (new to it and new to Python in general) to do a very basic contacts database.</p> <p>Trying to add a record via the Admin pages to a Contributor table, the model code for which is:</p> <pre><code>class Contributor(models.Model): first_name = models.CharField(max_length=20) last_name = models.CharField(max_length=20) organisation = models.ForeignKey('Organisation') mode = models.CharField(max_length=10, blank=True) email = models.CharField(max_length=30, blank=True) landline = models.CharField(max_length=10, blank=True) def __unicode__(self): print('%s %s' % (self.first_name, self.last_name)) </code></pre> <p>The error message I am getting is:</p> <pre><code> Environment: Request Method: POST Request URL: http://127.0.0.1:8000/admin/ramapp/contributor/add/ Django Version: 1.5.5 Python Version: 2.7.5 Installed Applications: ('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'south', 'ramapp') 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 "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 115. response = callback(request, *callback_args, **callback_kwargs) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper 372. return self.admin_site.admin_view(view)(*args, **kwargs) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view 91. response = view_func(request, *args, **kwargs) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 89. response = view_func(request, *args, **kwargs) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner 202. return view(request, *args, **kwargs) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper 25. return bound_func(*args, **kwargs) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view 91. response = view_func(request, *args, **kwargs) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func 21. return func(self, *args2, **kwargs2) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/db/transaction.py" in inner 223. return func(*args, **kwargs) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/contrib/admin/options.py" in add_view 1009. self.log_addition(request, new_object) File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/contrib/admin/options.py" in log_addition 530. action_flag = ADDITION File "/Users/lemon/.virtualenvs/ram/lib/python2.7/site-packages/django/contrib/admin/models.py" in log_action 18. e = self.model(None, None, user_id, content_type_id, smart_text(object_id), object_repr[:200], action_flag, change_message) Exception Type: TypeError at /admin/ramapp/contributor/add/ Exception Value: 'NoneType' object has no attribute '__getitem__' </code></pre> <p>Grateful for any assistance. Struggling! Thanks.</p> <p>Matt</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload