Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django admin site: how to create a single page for global settings?

I would like to create a single page in the admin site of django where I can change some global variables of the website (title of the website, items in the navigation menu, etc). At the moment I have them coded as context processors but I would like to make them editable. Something similar to what happens in WordPress.

Is this possible?

  • I can store the data in the databse, but can I have a link in the admin site that goes straight to the first document record and doesnt allow the creation of multiple records (they wouldnt make sense)
  • Instead of creating a model in the database, would it be possible to change some context_processor from the admin site (I think this would be best)
like image 830
Matt Jakob Avatar asked Oct 06 '10 01:10

Matt Jakob


People also ask

How do I restrict access to parts of Django admin?

Django admin allows access to users marked as is_staff=True . To disable a user from being able to access the admin, you should set is_staff=False . This holds true even if the user is a superuser. is_superuser=True .

Can I use Django admin as frontend?

Django Admin's task is to provide an interface to the admin of the web project. Django's Docs clearly state that Django Admin is not made for frontend work.


1 Answers

django-preferences does exactly what you are looking for. The implementation is a bit hacky (particularly the setting of __module__ on the model class to trick Django into thinking it was loaded from a different app), but it works.

like image 154
Carl Meyer Avatar answered Sep 22 '22 01:09

Carl Meyer