{"id":21154,"library":"django-nonrelated-inlines","title":"django-nonrelated-inlines","description":"Django admin inlines for unrelated models – allows using inline formsets for models without a direct foreign key relationship. Version 0.2, released to PyPI in 2021 (last release). Requires Django >= 3.0 and Python >= 3.6. Currently in maintenance mode with no recent updates.","status":"maintenance","version":"0.2","language":"python","source_language":"en","source_url":"https://github.com/bhomnick/django-nonrelated-inlines","tags":["django","admin","inlines","unrelated-models"],"install":[{"cmd":"pip install django-nonrelated-inlines","lang":"bash","label":"pip"}],"dependencies":[{"reason":"Required for admin integration","package":"Django","optional":false}],"imports":[{"note":"Older docs may omit .admin submodule","wrong":"from nonrelated_inlines import NonRelatedTabularInline","symbol":"NonRelatedTabularInline","correct":"from nonrelated_inlines.admin import NonRelatedTabularInline"},{"note":"Wrong module path","wrong":"from admin import NonRelatedStackedInline","symbol":"NonRelatedStackedInline","correct":"from nonrelated_inlines.admin import NonRelatedStackedInline"}],"quickstart":{"code":"from django.contrib import admin\nfrom nonrelated_inlines.admin import NonRelatedTabularInline\nfrom .models import Author, Book\n\nclass BookInline(NonRelatedTabularInline):\n    model = Book\n    fields = ['title', 'published_date']\n    # Define how the inline relates to the parent via a custom queryset\n    def get_queryset(self, request, obj):\n        if obj:\n            return self.model.objects.filter(author=obj)\n        return self.model.objects.none()\n\n@admin.register(Author)\nclass AuthorAdmin(admin.ModelAdmin):\n    inlines = [BookInline]","lang":"python","description":"Define a non-related inline by providing a custom get_queryset method that filters based on the parent object."},"warnings":[{"fix":"Always provide a custom `get_queryset` method that filters by the parent instance.","message":"You must override `get_queryset` manually; the inline does not automatically filter based on any relationship. Omitting this will show all objects in the inline.","severity":"gotcha","affected_versions":"all"},{"fix":"Do not set `fk_name` on the inline class. Use `get_queryset` for filtering.","message":"The `fk_name` attribute is not used; it expects a foreign key but this library works with unrelated models. Setting `fk_name` will not work as expected.","severity":"gotcha","affected_versions":"all"},{"fix":"Test with your Django version; consider forking or using alternative approaches (e.g., custom admin views).","message":"The library has not been updated since 2021 and may not be compatible with newer Django versions (4.x, 5.x). Some admin internals have changed.","severity":"deprecated","affected_versions":"0.2"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Ensure you have imported NonRelatedTabularInline (or NonRelatedStackedInline) from `nonrelated_inlines.admin` and that your model does not have a direct FK; the inline is intended for unrelated models.","cause":"Django admin expects a foreign key relation; the library patches this but may fail if not set up correctly.","error":"django.core.exceptions.ImproperlyConfigured: Inline nonrelated_inlines.admin.NonRelatedTabularInline expects a ForeignKey but no related field found."},{"fix":"Remove fk_name from the inline definition; use get_queryset to filter related objects.","cause":"Attempting to set fk_name on the inline class, which is not supported.","error":"'NonRelatedTabularInline' object has no attribute 'fk_name'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}