Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

create feeds app

  • Loading branch information...
commit 2b4323c807112a3bc560335b96ffffcd66188fdc 1 parent 8ce85ce
@mattoufoutu authored Daroth committed
View
1  .gitignore
@@ -0,0 +1 @@
+*.db
View
0  apps/feeds/__init__.py
No changes.
View
3  apps/feeds/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
View
23 apps/feeds/tests.py
@@ -0,0 +1,23 @@
+"""
+This file demonstrates two different styles of tests (one doctest and one
+unittest). These will both pass when you run "manage.py test".
+
+Replace these with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+class SimpleTest(TestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.failUnlessEqual(1 + 1, 2)
+
+__test__ = {"doctest": """
+Another way to test that 1 + 1 is equal to 2.
+
+>>> 1 + 1 == 2
+True
+"""}
+
View
5 apps/feeds/urls.py
@@ -0,0 +1,5 @@
+from django.conf.urls.defaults import patterns
+
+urlpatterns = patterns('apps.feeds.views',
+ (r'^$', 'index'),
+)
View
8 apps/feeds/views.py
@@ -0,0 +1,8 @@
+from django.http import HttpResponse
+
+from lib.helpers import render_to
+
+
+@render_to('feeds/index.html')
+def index(request):
+ return {'content': "Hello World!"}
View
1  lib/__init__.py
@@ -0,0 +1 @@
+# -*- coding: utf-8 -*-
View
24 lib/helpers.py
@@ -0,0 +1,24 @@
+from functools import wraps
+
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+
+
+class render_to(object):
+ """
+ Simplify template rendering by using a decorator.
+ """
+ def __init__(self, template):
+ self.template = template
+
+ def __call__(self, view):
+ @wraps(view)
+ def wrapper(*args, **kwargs):
+ request = args[0]
+ context = view(*args, **kwargs)
+ return render_to_response(
+ self.template,
+ context,
+ context_instance=RequestContext(request),
+ )
+ return wrapper
View
2  settings.py
@@ -91,6 +91,8 @@
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
+
+ 'apps.feeds',
)
# use django-extensions and django-debug-toolbar
View
4 templates/feeds/index.html
@@ -0,0 +1,4 @@
+{% extends "base/sitebase.html" %}
+{% block content %}
+ {{ content }}
+{% endblock content %}
View
3  urls.py
@@ -2,10 +2,13 @@
from django.conf.urls.defaults import *
from django.contrib import admin
+import apps.feeds.urls
+
admin.autodiscover()
urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
+ (r'^', include(apps.feeds.urls)),
)
if settings.DEBUG:
Please sign in to comment.
Something went wrong with that request. Please try again.