2

I've been trying to customize the name of the app that is displayed and have run into an issue when using spaces in app_label, it results in a 404 error page when I try to visit the url. For example,

app_label = 'Occupational Therapy'

results in the text displaying as I intended, but visiting that url in the admin site gives the following, though the pages for individual models appear correctly. Example: url/admin/Occupational%20Therapy/ returns this:

 Page not found (404)
 Request Method: GET 
 Request URL: url/admin/Occupational%20Therapy/ 

but url/admin/Occupational%20Therapy/model displays everything correctly.

I've tried using this:

app_label = 'occupational_therapy'

as the django documentation seemed to state that it would be capitalized and strip out the underscore automatically, but the underscore remains, as Occupational_Therapy is what is displayed. In this case, the urls work perfectly so if there is a way to strip out the underscore, that would really solve the problem. Otherwise, I assume I would need to edit the urls.py file?

4

1 回答 1

1

app_label用于指示模型属于哪个 Django 应用程序,而不是更改 URL。例如,如果您的应用程序被命名polls,您可以将模型放入polls\models\voting.py和放入polls\models\results.py. 然后模型需要:

app_label = 'polls'

我不知道如何更改管理站点中应用程序的 URL。在站点的其他部分更改它们应该使用urls.py.

于 2013-07-04T00:25:14.120 回答