django-spaceview

Father app dependency in reusable aplications, object and context access using namespaces and class bas...
Download

django-spaceview Ranking & Summary

Advertisement

  • Rating:
  • License:
  • MIT/X Consortium Lic...
  • Price:
  • FREE
  • Publisher Name:
  • Gustavo Diaz Jaimes
  • Publisher web site:
  • https://github.com/gustavodiazjaimes/

django-spaceview Tags


django-spaceview Description

django-spaceview is a Django app that can father app dependency in reusable applications, object and context access using namespaces and class base views.InstallIn settings.py:Install the app: INSTALLED_APPS = add the middleware MIDDLEWARE_CLASSES = create the variable SPACEVIEW_SPACES as a list of space views # settings.py ... SPACEVIEW_SPACES = ...Create the Space View in your reusable app and treat it like a Detail View (Class Base View) # myapp/views.py from __future__ import absolute_import from spaceview.views import SpaceView from .models import Myapp class ProjectSpace(SpaceView): namespace = 'myapp' model = Myapp context_object_name = "myapp" slug_url_kwarg = 'myapp_slug' template_name = 'myapp/myapp_base.html' def get_context_data(self, **kwargs): context = super(ProjectSpace, self).get_context_data(**kwargs) context = self.object.foo() return contextUsageRead namespace url in django docs ;) # myapp/urls.py ... urlpatterns = patterns('', ... url(r"^(?P< myapp_slug >+)/reusableapp/", include(ReusableAapp, namespace='myapp', app_name='reusableapp')), )Now you can access to space objects in reusable app views # reusableapp/view.py ... class ReusableappView(FooView): model = ReusableApp context_object_name = "reusableapp" template_name = "reusableapp/reusableapp_foo.html" @method_decorator(login_required) def dispatch(self, request, *args, **kwargs): space = request.space.object if not space.foo_permission(): HttpResponseForbidden() return super(MemberUpdateSetView, self).dispatch(request, *args, **kwargs)Variables request.resolve, url resolve object request.space, space-view object relative to last namespace resolve in url request.spaces, dict of namespace an space-view objectProduct's homepage


django-spaceview Related Software