hi,

i have a model like this:
class Incident(models.Model):
    
    escalate = models.IntegerField()
    escalatelist =
models.ManyToManyField(Escalatelist,null=True,blank=True)

other fields removed for clarity. If I save this in admin, I get this
error:
'Incident' instance needs to have a primary key value before a
many-to-many relationship can be used.

the full traceback is:

Environment:


Request Method: POST
Request URL: http://127.0.0.1:8999/admin/incident/incident/add/

Django Version: 1.3 SVN-15966
Python Version: 2.6.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'employee',
 'incident']
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 "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in
get_response
  111.                         response = callback(request,
*callback_args, **callback_kwargs)
File "/usr/lib/python2.6/site-packages/django/contrib/admin/options.py"
in wrapper
  306.                 return self.admin_site.admin_view(view)(*args,
**kwargs)
File "/usr/lib/python2.6/site-packages/django/utils/decorators.py" in
_wrapped_view
  90.                     response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/views/decorators/cache.py"
in _wrapped_view_func
  75.         response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/contrib/admin/sites.py" in
inner
  197.             return view(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/utils/decorators.py" in
_wrapper
  25.             return bound_func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/utils/decorators.py" in
_wrapped_view
  90.                     response = view_func(request, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/utils/decorators.py" in
bound_func
  21.                 return func(self, *args2, **kwargs2)
File "/usr/lib/python2.6/site-packages/django/db/transaction.py" in
inner
  211.                 return func(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/django/contrib/admin/options.py"
in add_view
  863.             if form.is_valid():
File "/usr/lib/python2.6/site-packages/django/forms/forms.py" in
is_valid
  121.         return self.is_bound and not bool(self.errors)
File "/usr/lib/python2.6/site-packages/django/forms/forms.py" in
_get_errors
  112.             self.full_clean()
File "/usr/lib/python2.6/site-packages/django/forms/forms.py" in
full_clean
  269.         self._post_clean()
File "/usr/lib/python2.6/site-packages/django/forms/models.py" in
_post_clean
  331.             self.instance.clean()
File "/home/lawgon/servicefirst/incident/models.py" in clean
  182.             if not self.escalatelist:
File
"/usr/lib/python2.6/site-packages/django/db/models/fields/related.py" in
__get__
  731.             reverse=False
File
"/usr/lib/python2.6/site-packages/django/db/models/fields/related.py" in
__init__
  493.                 raise ValueError("%r instance needs to have a
primary key value before a many-to-many relationship can be used." %
instance.__class__.__name__)

Exception Type: ValueError at /admin/incident/incident/add/
Exception Value: 'Incident' instance needs to have a primary key value
before a many-to-many relationship can be used.


-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to