Skip to content

Commit

Permalink
Merge pull request #30 from neodark/master
Browse files Browse the repository at this point in the history
Django 1.7 compliant and separation between library and sample
  • Loading branch information
umutbozkurt committed Sep 8, 2014
2 parents d37a9ef + c2a0a3e commit 7b8cdd7
Show file tree
Hide file tree
Showing 21 changed files with 89 additions and 2 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ Install
---------
``` pip install django-rest-framework-mongoengine```

-----------------
Install as package
-----------------
You can use this library as a package to your project:

- Step 1: Installing required files
``` pip install -r requirements.txt```
- Step 2: make sure you're having a mongodb running locally:
```/bin/mongod --dbpath [path_to_data/db/]```
- Step 3: Create users and table in dbsqlite and django admin:
``` python manage.py syncdb```
- Step 4: Run the SampleApp demo:
``` python manage.py runserver```

Then run <b>http://localhost:8000/</b> on your favorite browser to test the interface

-----------------
Requirements
-----------------
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@

ALLOWED_HOSTS = []

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(BASE_DIR, '.','templates'),
)


# Application definition

Expand All @@ -36,8 +50,8 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'SampleApp',
'homepage',
'rest_framework'
)

Expand Down
3 changes: 2 additions & 1 deletion rest_framework_mongoengine/Sample/urls.py → Sample/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from django.conf.urls import patterns, include, url
from rest_framework_mongoengine.SampleApp import views
from SampleApp import views
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^$', include('homepage.urls')),
url(r'^users/$', views.UserList.as_view()),
url(r'^users/(?P<id>[\w]{24})/$', views.UserDetails.as_view()),
url(r'^blogs/$', views.BlogList.as_view()),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added homepage/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions homepage/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
Empty file added homepage/migrations/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions homepage/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
3 changes: 3 additions & 0 deletions homepage/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
7 changes: 7 additions & 0 deletions homepage/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.conf.urls import *
from django.conf import settings


urlpatterns = patterns('homepage.views',
url(r'^$', 'home', name="home"),
)
16 changes: 16 additions & 0 deletions homepage/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django.shortcuts import render

from django.conf import settings
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden, Http404
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
# Create your views here.

def home(request):

param1 = "parameter_1"
return render_to_response('homepage/index.html',
{
'param':param1
},
context_instance = RequestContext(request))
File renamed without changes.
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Django==1.7
mongoengine==0.8.7
djangorestframework==2.4.2
21 changes: 21 additions & 0 deletions templates/homepage/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<title>Django Rest Framework Mongoengine</title>
</head>
<b>Sample App using django-rest-framework and Mongoengine</b>
<body>
<div class="nav-collapse collapse">
<ul class="nav"><b>REST API</b>
<li><a href="/users">Users</a></li>
<li><a href="/blogs">Blogs</a></li>
<li><a href="/posts">Posts</a></li>
<li><a href="/comments">Comments</a></li>
</ul>
<ul class="nav"><b>Django Admin</b>
<li><a href="/admin">Admin</a></li>
</ul>
</div><!--/.nav-collapse -->
</body>
</html>

0 comments on commit 7b8cdd7

Please sign in to comment.