Hello Tiglath, On Monday, April 6, 2015 at 1:06:43 PM UTC-3, Tiglath Suriol wrote: > > > Environments have servers; servers have applications; applications can be > on various servers, and applications have files. > > - servers must be unique within environments, > - applications must be unique on each server. > - files must be unique within an applications. > > Will this accomplish it? >
You're almost there, you just have one relationship wrong: (I'll also add some refactoring suggestions for your attribute names) > > > class Environment(models.Model): > > ''' Environment can be "Production", "QA" or "CT" (customer test).''' > > env_name = models.CharField('Environment Name', max_length=20) > *env_name* could be only *name* for simplicity, in this case the class Environment (or the environment object) works as a context, so when you're accessing the *name* attribute it'll be cleaner, e.g: >> environ.name # better than environ.env_name > > class Server(models.Model): > > environment = models.ForeignKey(Environment) > > server_name = models.CharField('Server Name', max_length=20, > primary_key=True) > same here, use *name *instead. > > > class Application(models.Model): > > servers = models.ManyToManyField(Server) > > app_name = models.CharField('Application Name', max_length=50, > primary_key=True) > same here, use *name *instead. > > > class File(models.Model): > > applications = models.ManyToManyField(Application) > If you need unique files for application, you should be using a ForeignKey field instead of a ManyToMany. > file_name = models.CharField('File Name', max_length=100, > primary_key=True) > same here, use *name *instead. > > > Thanks > > > > > > > As far as I see everything else looks fine. Hope it helps! -- 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 django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. 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/6ef6e65e-04d4-4112-8bd3-04ea60482f56%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.