add foreign key field 'deployment' to Controller.
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index 0160473..e8d0569 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -14,7 +14,7 @@
 from django.contrib.contenttypes import generic
 from suit.widgets import LinkedSelect
 from django.core.exceptions import PermissionDenied
-from django.core.urlresolvers import reverse, NoReverseMatch
+from django.core.urlresolvers import reverse, resolve, NoReverseMatch
 from django.utils.encoding import force_text, python_2_unicode_compatible
 from django.utils.html import conditional_escape, format_html
 from django.forms.utils import flatatt, to_current_timezone
@@ -446,7 +446,7 @@
             kwargs['queryset'] = Deployment.select_by_user(request.user)
 
         if db_field.name == 'controller':
-            kwargs['queryset'] = Controller.select_by_user(request.user)
+            kwargs['queryset'] = Controller.select_by_user(request.user).filter(deployment__id=int(resolve(request.path).args[0]))
 
         return super(SiteDeploymentInline, self).formfield_for_foreignkey(db_field, request, **kwargs)
 
diff --git a/planetstack/core/models/site.py b/planetstack/core/models/site.py
index d1f04dd..449a72b 100644
--- a/planetstack/core/models/site.py
+++ b/planetstack/core/models/site.py
@@ -252,6 +252,8 @@
     admin_password = models.CharField(max_length=200, null=True, blank=True, help_text="Password of theadmin user at this controller")
     admin_tenant = models.CharField(max_length=200, null=True, blank=True, help_text="Name of the tenant the admin user belongs to")
     domain = models.CharField(max_length=200, null=True, blank=True, help_text="Name of the domain this controller belongs to")
+    deployment = models.ForeignKey(Deployment,related_name='controllerdeployments')
+    
 
     def __unicode__(self):  return u'%s %s %s' % (self.name, self.backend_type, self.version)