Hey guys! Do you mind checking out my new package and letting me know what
you think? Essentially it is a Flask inspired routing system for Django
(only Python2.x) that works by recursively searching through a folder, for
example:
pip install djroute
urls.py
from djroute import root, traverse
urlpatterns = [
# base pattern with admin routes
url(r'^admin/', admin.site.urls),
]
# goes into folders relative to project root
views = root('app_name', 'views')
for i in traverse(views):
# add URLS to patterns
urlpatterns.append(i)
djroute will recurse the entire tree defined with the root function by
joining paths together
for example a subpackage might have a folder called banks with a folder
inside called citizens with different modules one of which looks like so
from djroute import route
# @route(PATH:required, NAME:optional)
@route('fn', 'funcview')
def funcview(request):
# do something
@route('cls', 'classview')
class classview(View):
# do something in methods
This would generate the routes
^banks/citizens/fn/$ with name funcview
^banks/citizens/cls/$ with name classview
if you like the packages to take a different name from their folder name,
define PATH in __init__.py
Let me know if this does not make sense
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/c48d9b75-1b70-4bd1-bcf7-dbfde80eb1b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.