Easier to be red
Ok so I have three tables in my database Customer Vms and Vmspecs
Vms is tied through customer by customer id through database id field and
vmspecs is tied to vms through the id field for Vms. However when I go into
admin panel and try to add vmspecs to vms after connecting the vm to a
customer i get the and error here is my model contorller.
class Customer(models.Model):
NAME = models.CharField(max_length=200)
WEBSITE = models.CharField(max_length=200)
PHONE = models.CharField(max_length=200)
EMAIL = models.CharField(max_length=200)
ADDRESS = models.CharField(max_length=200)
VMIDS = models.CharField(max_length=200)
def __unicode__(self):
return self.NAME
# return self.NAME
class Vms(models.Model):
VMID = models.CharField(max_length=200)
VMNAME = models.CharField(max_length=200)
VMSTATUS = models.CharField(max_length=200)
CUSTOMERID = models.ForeignKey(Customer)
def __unicode__(self):
return self.VMNAME
class Vmspecs(models.Model):
CPUS = models.CharField(max_length=200)
CORES = models.CharField(max_length=200)
MEMORY = models.CharField(max_length=200)
HDSPACE = models.CharField(max_length=200)
OS = models.CharField(max_length=200)
UPTIME = models.CharField(max_length=200)
VMID = models.ForeignKey(Vms)
def __unicode__(self):
return self.VMID
Here is there error
Environment:
Request Method: POST
Request URL: http://pythondev.enki.co:8001/admin/vmware/vmspecs/add/
Django Version: 1.6.4
Python Version: 2.7.3
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'vmware')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in
get_response
114. response = wrapped_callback(request, *callback_args,
**callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py"
in wrapper
432. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in
_wrapped_view
99. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py"
in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in
inner
198. return view(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in
_wrapper
29. return bound_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in
_wrapped_view
99. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in
bound_func
25. return func(self, *args2, **kwargs2)
File "/usr/local/lib/python2.7/dist-packages/django/db/transaction.py" in inner
371. return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py"
in add_view
1133. self.log_addition(request, new_object)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py"
in log_addition
600. action_flag=ADDITION
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/models.py" in
log_action
19. 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/vmware/vmspecs/add/
Exception Value: 'Vms' object has no attribute '__getitem__'
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/49db1073-852f-4040-8ba6-d35d8cc51071%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.