Anyone?

On Tuesday, May 6, 2014 11:34:51 AM UTC-6, G Z wrote:
>
> So I'm trying to set up my django app and I want to link multiple tables 
> each with a unique key identifier. To test this i have the following 
> models. py
> <code>
> from django.db import models
>
> # Create your models here.
> 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
> </code>
>
> If works fantastic until I try to add a vmspecs in the admin panel and 
> link it to a VM it gives the following error
>
>
>
>
>
> <code>
>
> 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__'
> </code>
>

-- 
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/e7aaf400-d6d9-4cfb-ae9e-fcbcd1f96567%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to