Hello,

I have 2 questions:
1. How in Robot admin page do I limit Applications to only those which
belong to the same Project as Robot?
2. How can I use a better widget in ApplicationInline in Robot page?

Plus if you have any comments on the structure of models, be my guest.

I have following structure of models:

Layout (app):
- Project -< Line -< Robots
Properties (app)
- Application

There is a m2m relation between Robots and Application. I put it on
Application, but maybe it's wrong way to do it. In Pizza-Toppings example
relationship was on Pizzas (
https://docs.djangoproject.com/en/dev/topics/db/models/#many-to-many-relationships
). Is it correct to split my apps like this?

I would like to be able to go to admin interface and:
1. Select Application from Robot page
2. Go to Application page and select which Robots have this application

whichever way feels more comfortable at the moment.

I have it covered from Application side. I have to import models from
layout, so I guess it is a dependency. Then on the other side I import
Application, so is this circular dependency aka "no-no"?

Here's my code:

********
from django.contrib import admin
from django.contrib import messages

from makrozuli.commissioning.models import Application

import models

class ProjectAdmin(admin.ModelAdmin):
    pass

class LineAdmin(admin.ModelAdmin):
    pass

class ApplicationInline(admin.StackedInline):
    model = Application.robot.through

##    def get_queryset(self, request):
##        qs = super(ApplicationInline, self).get_queryset(request)
##        qs.filter(project= ???

class RobotAdmin(admin.ModelAdmin):
    inlines = [ ApplicationInline, ]

admin.site.register(models.Project, ProjectAdmin)
admin.site.register(models.Line, LineAdmin)
admin.site.register(models.Robot, RobotAdmin)
*********

The inline can be only Tabular or Stacked. I was looking for something like
filter widget if it is possible. Also I would like to only show Application
which belong only to the Project the Robot belongs to. How do I do it? The
commented part of the code was my attempt to do this, but I'm stuck.

Best regards,
Daniel Ozminkowski

-- 
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/CAEW8F8LTCS%3D4oqWDCph2ir5JxfdZjEFsKcFbVeKxf%3D%2BDcKf0BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to