From cb6d95acc426ed7514f1fbad9e4685c281a970cc Mon Sep 17 00:00:00 2001 From: liushuaikobe Date: Wed, 25 Sep 2013 14:50:13 +0800 Subject: [PATCH 1/2] convert the readme txt to md --- README.txt => README.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) rename README.txt => README.md (76%) diff --git a/README.txt b/README.md similarity index 76% rename from README.txt rename to README.md index a3ef234..042240f 100644 --- a/README.txt +++ b/README.md @@ -4,21 +4,22 @@ A SingletonModel is a django model that only ever has one record. You can't use Some might argue that singleton models are an inefficient way of using a relational database, but in practice it's no biggie - most web sites have some important one-off content (eg. the Home Page), and singleton models map well to how content editors generally think. -I suspect I have cadged some of this code from someone else (likely ex-colleague http://github.com/jphalip/), but a quick Google doesn't show up anything like this already out there. So here it is. I hope you find it useful. +I suspect I have cadged some of this code from someone else (likely ex-colleague [http://github.com/jphalip/](http://github.com/jphalip/)), but a quick Google doesn't show up anything like this already out there. So here it is. I hope you find it useful. Installation ------------ +``` +$ pip install django-singletons +``` -pip install django-singletons - -To get the custom admin templates working, you need to add "singleton_models" to your INSTALLED_APPS +To get the custom admin templates working, you need to add `singleton_models` to your `INSTALLED_APPS` Example Usage ------------- -in models.py - +in `models.py` +``` from singleton_models.models import SingletonModel class HomePage(SingletonModel): @@ -30,11 +31,13 @@ class HomePage(SingletonModel): class Meta: verbose_name = "Home Page" # once again this will make sure your admin UI doesn't have illogical text verbose_name_plural = "Home Page" +``` +in `admin.py` -in admin.py - +``` from singleton_models.admin import SingletonModelAdmin from models import HomePage admin.site.register(HomePage, SingletonModelAdmin) +``` From cba61f1c40dd683e093d6cb6e1bc6ca4d1924145 Mon Sep 17 00:00:00 2001 From: liushuaikobe Date: Wed, 25 Sep 2013 14:59:27 +0800 Subject: [PATCH 2/2] add the python code render to readme --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 042240f..2fb9f6a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +django-singletons +============================================ + I keep finding myself re-using this simple bit of code, so I thought I should open-source it, even though it's not much more than a snippet. A SingletonModel is a django model that only ever has one record. You can't use the admin to create a new instance, or delete the existing one. @@ -19,7 +22,7 @@ Example Usage in `models.py` -``` +``` python from singleton_models.models import SingletonModel class HomePage(SingletonModel): @@ -35,7 +38,7 @@ class HomePage(SingletonModel): in `admin.py` -``` +``` python from singleton_models.admin import SingletonModelAdmin from models import HomePage