Commits

Anonymous committed 161e667

sample_wiki is now provide wiki/* and admin/*

Comments (0)

Files changed (6)

+syntax: glob
+*.db

django_restwiki/admin.py

 from django_restwiki.models import Page
 from django.contrib import admin
 
-class PollAdmin(admin.ModelAdmin):
+class PageAdmin(admin.ModelAdmin):
     fields = ['content']
 
 admin.site.register(Page, PageAdmin)

django_restwiki/models.py

 
     def save(self, *args, **kwargs):
         # get name
-        (heading, remain) = content.split('\n', 1)
-        self.name = heading
+        (heading, remain) = self.content.split('\n', 1)
+        self.name = heading.strip()
         # TODO: use docutils to convert
         self.rendered = self.content
         super(Page, self).save(*args, **kwargs)

django_restwiki/views.py

+from django.shortcuts import get_object_or_404, render_to_response
+from django_restwiki.models import Page
+
+def view(request, name):
+    page = get_object_or_404(Page, name=name)
+    return render_to_response("django_restwiki/view.html", {"page": page})

sample_wiki/settings.py

 # Django settings for sample_wiki project.
+import os
+
+
+def rel(*args):
+    return os.path.join(os.path.abspath(os.path.dirname(__file__)), *args)
 
 DEBUG = True
 TEMPLATE_DEBUG = DEBUG
 
 DATABASES = {
     'default': {
-        'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
-        'NAME': '',                      # Or path to database file if using sqlite3.
+        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+        'NAME': rel('sqlite.db'),                      # Or path to database file if using sqlite3.
         'USER': '',                      # Not used with sqlite3.
         'PASSWORD': '',                  # Not used with sqlite3.
         'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
 # timezone as the operating system.
 # If running in a Windows environment this must be set to the same as your
 # system time zone.
-TIME_ZONE = 'America/Chicago'
+TIME_ZONE = None
 
 # Language code for this installation. All choices can be found here:
 # http://www.i18nguy.com/unicode/language-identifiers.html
     'django.contrib.sites',
     'django.contrib.messages',
     # Uncomment the next line to enable the admin:
-    # 'django.contrib.admin',
+    'django.contrib.admin',
+    'django_restwiki',
 )

sample_wiki/urls.py

 from django.conf.urls.defaults import *
 
 # Uncomment the next two lines to enable the admin:
-# from django.contrib import admin
-# admin.autodiscover()
+from django.contrib import admin
+admin.autodiscover()
 
 urlpatterns = patterns('',
     # Example:
     # (r'^sample_wiki/', include('sample_wiki.foo.urls')),
+    (r'^wiki/', include('django_restwiki.urls')),
 
     # Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
     # to INSTALLED_APPS to enable admin documentation:
     # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
 
     # Uncomment the next line to enable the admin:
-    # (r'^admin/', include(admin.site.urls)),
+    (r'^admin/', include(admin.site.urls)),
 )