DRF shows wrong URL at apiroot if different applications have models with the same name #8824
Unanswered
Credentive-Sec
asked this question in
Potential Issue
Replies: 1 comment
-
First of all, use basename='user' / different name for different router with same model name use router = DefaultRouter() 2nd, this should now raise an exception #8438 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a dango project with three applications. Two of them have Models called "Review Comment". The models are identical, but the different applications show different objects based on filtering - note that the Models for the apps are maintained in separate tables in the database, since they are in different applications
I have set up separate Serializers and ViewSets - the view sets apply proper filtering.
in the project's url.py I have the following code (snippet):
these views show "ComplianceStatementReview" objects and "ReviewComment" objects for each of their applications.
When I visit the review manager HTML render page in DRF, I see the following:
"review_manager_review_comments": "http://localhost:8000/reviewmanager/api/v1/review_manager_review_comments/"
When I visit the compliance manager HTML Render page in DRF, I see the following:
"compliance_manager_review_comments": "http://localhost:8000/**reviewmanager**/api/v1/review_manager_review_comments/"
Note the the compliance manager HTML page refers to the review manager URL
If I manually visit the appropriate URL,
http://localhost:8000/compliancemanager/api/v1/compliance_manager_review_comments/
I see the expected data, so the issue is just api_root.
After experimenting with a lot of different changes, I have notice that the issue is caused because the Models in the application have the same name. If I change the model name in the application, the URL is rendered correctly.
I can change the model name, but I still think this is probably a bug.
Happy to provide more code and detail if needed.
Beta Was this translation helpful? Give feedback.
All reactions