You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A rule can have multiple sorted alternatives (one to many) and multiple sorted dimensions (many to many).
from django.db import models
class Dimension(models.Model):
name = models.CharField(max_length=255, unique=True)
class Rule(models.Model):
name = models.CharField(max_length=255, unique=True)
dimensions = models.ManyToManyField(Dimension, through='RuleDimension')
class RuleDimension(models.Model):
class Meta:
ordering = ('ordering', )
unique_together = (("rule", "dimension"),)
ordering = models.PositiveIntegerField(default=0, null=False, blank=False)
rule = models.ForeignKey(Rule, on_delete=models.CASCADE)
dimension = models.ForeignKey(Dimension, on_delete=models.CASCADE)
class Alternative(models.Model):
class Meta:
ordering = ('ordering',)
name = models.CharField(max_length=255, unique=True)
rule = models.ForeignKey(Rule, on_delete=models.CASCADE)
ordering = models.PositiveIntegerField(default=0, null=False, blank=False)
Now I want to manage the rule while being able to manage the alternatives inline as well as the dimension mappings.
from .models import Rule, Alternative, Dimension
from adminsortable2.admin import SortableAdminBase, SortableTabularInline, SortableStackedInline
@admin.register(Alternative)
class AlternativeAdmin(admin.ModelAdmin):
class Meta:
model = Alternative
# or SortableTabularInline
class AlternativeInline(SortableStackedInline):
model = Alternative
# or SortableTabularInline
class DimensionInline(SortableStackedInline):
model = Rule.dimensions.through
@admin.register(Dimension)
class DimensionAdmin(admin.ModelAdmin):
resource_class = DimensionResource
class Meta:
model = Dimension
@admin.register(Rule)
class RuleAdmin(SortableAdminBase, admin.ModelAdmin):
class Meta:
model = Rule
However on http://127.0.0.1:8000/admin/rules/rule/add/ I do not see any of the UI elements to re-order (up/down buttons or drag&drop). jQuery, sortable.css ect seem to be loaded.
The text was updated successfully, but these errors were encountered:
A rule can have multiple sorted alternatives (one to many) and multiple sorted dimensions (many to many).
Now I want to manage the rule while being able to manage the alternatives inline as well as the dimension mappings.
However on http://127.0.0.1:8000/admin/rules/rule/add/ I do not see any of the UI elements to re-order (up/down buttons or drag&drop). jQuery, sortable.css ect seem to be loaded.
The text was updated successfully, but these errors were encountered: