Is their model URL alias functionality in Django Admin Pages?

Is it feasible to establish an alias for a model on Django Admin Pages? For instance, if the admin page is accessible via the URL route “admin/” and there’s an app named “products” with a database table named “batch,” the default URL route generated by Django for the change list view would be “admin/products/batch.” Is there a way to create an alias for this model?

In other words, could “admin/products/batch” and “admin/products/lim” both be configured to reference the same database table? Navigating to either of these URLs would then lead to the batch change list view. Is such a capability supported in Django, allowing the creation of alias names for URL routes that point to the same model? I’ve been unable to find any examples of such aliases online.

models.py

class Batch(models.Model):
# fields here …

class Meta:
    verbose_name = 'Batch'
    verbose_name_plural = 'Batch'

admin.py

class BatchAdmin(admin.ModelAdmin):
fieldsets = [(‘Details’, {‘fields’ : […]})]
list_display = […]

admin.site.register(Batch, BatchAdmin)

I have retracted most of the code from the model and modelAdmin, but that should give a rough idea.

One option may be to create a Proxy model for “Batch” named “Lim”, and then create a ModelAdmin class for it. (In this case, you don’t need to add or change any functionality in that Proxy model - the only reason you are defining it is to give you a second ‘access path’ to the base model. You could then create your proxy’s ModelAdmin as a subclass of the base model’s ModelAdmin class, avoiding the need to replicate the functionality.

1 Like

Thank you, here is the solution I have created for anyone else who finds this in the future.

models.py

class LIM(Batch):
class Meta:
verbose_name = ‘LIM’
verbose_name_plural = ‘LIM’
proxy = True

admin.py

class LIMAdmin(BatchAdmin):
fieldsets = [(‘Details’, {‘fields’ : […]})]
list_display = […]

admin.site.register(LIM, LIMAdmin)

The LIM model inherits from Batch, and the ModelAdmin inherits from BatchAdmin