1π
I think if you use foreign key it will be easier for your case, and it will easy to use with the _set
option from django.
0π
- Yes it is possible but it will not be dynamic (meaning that changing the value of location will not magically update themselves without first saving the change) which might be very unpractical.
- You should use formfield_for_manytomany in your admin -> https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_manytomany
- The easiest way to implement this would be to add custom javascript filtering on that particular admin form
π€Emma
0π
Leave for models as it was and try to use inlines in admin page.
So, your admins.py would look something like this:
class SubLocationInline(admin.StackedInline):
model = SubLocation
@admin.register(Location)
class LocationAdmin(admin.ModelAdmin):
.....
inlines = [SubLocationInline]
π€DAKZH
- [Answer]-Django: if model has related models (ForeignKey) display Fields in main modelform
- [Answer]-Passing RSS feeds to django view using AJAX
Source:stackexchange.com