2
votes

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?

1
The admin is not your app. It should only be used for trusted admins, and you should write views for everything else. - Matthew Schinckel

1 Answers

1
votes

app_label is used to indicate which Django application a model belongs to and not to alter the URL. If your application was named polls you could for example place models into polls\models\voting.py and into polls\models\results.py. The models would then need:

app_label = 'polls'

I don't know how to change the URLs for applications in the Admin site. Changing them on other parts of the site should be done using urls.py.