Django Edamame
One idea of Class-based view module.
Django Edamame gives you inheritable module to bundle the multiple view functions like django.contrib.admin application.
Edamame corresponds to the following problems:
Reuse URL pattern.
Creating an application with a similar view function set.
Simple example
Inherits the Views class, and implement the method of view function. And implement get_urls method to return the URL pattern.
In order to use a views class, it create an instance in the module.
from edamame import base
class SiteViews(base.Views):
def index(self, request):
"""view function
"""
return render(request, 'index.html')
def get_urls(self):
urlpatterns = patterns(
'',
url(r'^$', self.wrap_view(self.index), name='index'),
)
return urlpatterns
site_views = SiteViews()
urls property of views instance, it can be passed to include function in urls.py.
from django.conf.urls import patterns, include, url
from note.views import site_views
urlpatterns = patterns('',
url(r'', include(site_views.urls)),
)
Generic view example
Import the ModelViews class, and inherits.
from django.core.urlresolvers import reverse_lazy
from edamame import generic
from . import models
class NoteViews(generic.ModelViews):
model = models.Note
success_url = reverse_lazy('note:index')
note_views = NoteViews()
In urls.py, use the include function.
from django.conf.urls import patterns, include, url
from note.views import note_views
urlpatterns = patterns('',
url(r'note/', include(note_views.urls)),
)
Example Project
example directory in the repository is an example project.
If you have installed Django and Edamame, can run immediately.
$ cd example $ python manage.py syncdb $ python manage.py runserver
License
MIT License
Metadata
Release files for django-edamame 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-edamame-0.1.tar.gz | 3.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_edamame-0.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 9.8 kB
Release files / django-edamame-0.1.tar.gz
| Download URL | django-edamame-0.1.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7943449a6deea67761da54641448e90c9d2e3ebc80bf857c861b47bc944172e5
|
|
BLAKE2b-256 checksum How to use checksums |
a3bc7e58e16c6b1b1130b524b2beee97a96318573684634f7221d0e005477e94
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_edamame-0.1-py2.py3-none-any.whl
| Download URL | django_edamame-0.1-py2.py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
cc942ab126c0cc0dc1908ff345e2c39cfa07a55ac2bbfb1849de91274a182ae8
|
|
BLAKE2b-256 checksum How to use checksums |
cd7943fd0562b7004bc569a09cc7a5ab5b67ca84074fa970d2d05674c8e8acf8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |