Hi,
I just want to point out that there is similar work done for the core.
If we're lucky it will be available in Django 2.0.
21.8.2017 0.07 "Malik Brahimi" <mbrahimi02@gmail.com> kirjoitti:
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 djrouteurls.pyfrom djroute import root, traverse
urlpatterns = [
# base pattern with admin routes
url(r'^admin/', admin.site.urls),
]
# goes into folders relative to project rootviews = 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 togetherfor example a subpackage might have a folder called banks with a folder inside called citizens with different modules one of which looks like sofrom 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 classviewif you like the packages to take a different name from their folder name, define PATH in __init__.pyLet 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 django-users+unsubscribe@googlegroups.com .
To post to this group, send email to django-users@googlegroups.com.
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 .
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CAHn91odAS0QBkKwerRzG%3DrB0bzFpHvnqvvCL_PkicLARCv9Npg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment