简体   繁体   中英

Address case sensitivity in Django

Let's say I have an app named TaskDashboard . Yes, I know that the best practice is to give names for packages in lower case. But let's say that I can't change that.

Then I want to generate some docs using the built-in Django mechanisms. I wrote the following docstring for a model:

class Task(models.Model):
    """
    Every task is linked to a :model:`TaskDashboard.Column`.
    """

That allows to form the links to related models in the documentation. However, when I click on that, I get to the lower cased address /.../taskdashboard.column and get 404 error. If I change the address to /.../TaskDashboard.column/ I get the proper page.

How to solve the problem with case sensitivity without changing the app name?

Change AppConfig.label in app config

#TaskDashboard/apps.py
from django.apps import AppConfig


class TaskdashboardConfig(AppConfig):
    name = 'TaskDashboard'
    

and specify this new config class in INSTALLED_APPS

INSTALLED_APPS = [
    # other apps
    'TaskDashboard.apps.TaskdashboardConfig',
    # other apps
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM