subhranath / django-api-enabler Goto Github PK
View Code? Open in Web Editor NEWEnable APIs for your django apps in djangoish way
Enable APIs for your django apps in djangoish way
A Django helper app to let you specify API urls from within the apps. Why? ==== - Do you use multiple apps in your django project? - Do you use the conventional django way of managing your urlconfs (where you include other urlconfs to your apps)? - Do you wish to have URL prefix like '/api/' followed by your custom app prefix? - Do you like to keep the URLconf at the app level for individual mappings? If your answer is Yes to all, then this app is for you. What? ===== In simplest way, when your have your urlconf like: urlpatterns = patterns('', # ... snip ... (r'^accounts/', include('accounts.urls')), (r'^analytics/', include('analytics.urls')), (r'^search/', include('search.urls')), (r'^r/', include('inventory.urls')), # ... snip ... ) And you want to have APIs associated with different apps in your project like: /api/accounts/ /api/analytics/ /api/search/ # ... and more ... where the mapping to views remains within the individual apps. How to use? =========== - Include "api_enabler" in your INSTALLED_APPS. - Add "url(r'^api/', include('api_enabler.urls'))" to your base urlconf. Preferably somewhere on top. (Optional: You can change the string 'api' to whatever else you want as your root API prefix) - Add a api.py urlconf module to each of the apps where you want API urls enabled. (* See below) - API_URL_PREFIX in {{ app_name }}/api.py should be set to a custom url-slug to use as prefix for the app. * (For e.g. if you want to enable APIs in your accounts app your accounts/api.py file should look like: from django.conf.urls.defaults import patterns, include, url urlpatterns = patterns('accounts.views.apis', ... url(r'^register/$', 'api_register_handler'), url(r'^login/$', 'api_login_handler'), url(r'^logout/$', 'api_logout_handler'), ... ) API_URL_PREFIX = 'accounts' ) That's it! Now you can manage your API URLs with customizable slugs from within your app directory. Features: ========= - You can disable APIs associated with any particular app, by renaming your api.py of the app to anything else. - To disable APIs for the entire project, just remove 'api_enabler' from your INSTALLED_APPS.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.