-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Description
Discussed in #8824
Originally posted by Credentive-Sec December 31, 2022
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):
import compliancemanager.views as cc_views
import reviewmanager.views as rm_views
compliancemanager_router = routers.DefaultRouter()
compliancemanager_router.register(r"compliance_statement_responses", cc_views.ComplianceStatementResponseViewSet)
compliancemanager_router.register(
r"compliance_manager_review_comments", cc_views.ComplianceManagerReviewCommentViewSet
)
# Registered ViewSets - review manager
reviewmanager_router = routers.DefaultRouter()
reviewmanager_router.register(r"compliance_statement_reviews", rm_views.ComplianceStatementReviewViewSet)
reviewmanager_router.register(r"review_manager_review_comments", rm_views.ReviewCommentViewSet)
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. I have confirmed that the same behavior occurs on the JSON rendered page, so it's not an issue with the HTML interface.
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.