Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow different views for same model #391

Closed
1 task done
jsmolina opened this issue Nov 28, 2022 · 5 comments
Closed
1 task done

Allow different views for same model #391

jsmolina opened this issue Nov 28, 2022 · 5 comments

Comments

@jsmolina
Copy link

Checklist

  • There are no similar issues or pull requests for this yet.

Is your feature related to a problem? Please describe.

Identity is not overwritten in metaclass even if in attrs
cls.identity = slugify_class_name(model.__name__)

Describe the solution you would like.

It should be possible to create something like
cls.identity = attrs.get("identity", slugify_class_name(model.__name__)

Although edit links will need to be updated accordingly, of course.

Describe alternatives you considered

No response

Additional context

No response

@aminalaee
Copy link
Owner

Hi,
yeah, even though I didn't plan to introduce this as a public API, I see this is already crept into the docs. This is an easy fix, feel free to do it, otherwise I will do it later.

@jsmolina
Copy link
Author

jsmolina commented Nov 28, 2022

Hi, yeah, even though I didn't plan to introduce this as a public API, I see this is already crept into the docs. This is an easy fix, feel free to do it, otherwise I will do it later.

I tried but I had some issues when trying to click on edit one of the rows, as it tried to use the normal identity of the table.
I could try to do you a PR but it will take some days to get some spare time.

Anyway thanks for your nice work on this sqladmin library 😄

@aminalaee
Copy link
Owner

Hey, can you clarify the use-case you have? I've been looking into this and there's a limitation:

In list page, if there's a relationship, we actually link the related model so let's say you are viewing list of Users and you click their Organization's name in list, then you are redirected to the Organization detail.

But with this approach we can't find which view to redirect as there are two views registered for this Model.

@jsmolina
Copy link
Author

well it's just having the same model but listing the users by role, let's say:

  • user roles
  • administrator roles
    Sorry for the late reply.

@aminalaee
Copy link
Owner

I think you're better off writing a custom view.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants