django-usda:与 USDA 营养数据库兼容的易于设置的 Django Rest Framework API

  • v0_988691
    了解作者
  • 17.9KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-13 19:28
    上传日期
姜戈美国农业部 一个易于设置的 Django Rest Framework API,与美国农业部营养数据库兼容。 要求 Python (2.6.5+, 2.7, 3.2, 3.3, 3.4) Django (1.4.11+, 1.5.5+, 1.6, 1.7) Django Rest 框架 (2.4.4) 演示 要快速查看此包的功能,请转到。 安装 您可以使用 Python PIP 安装 Django USDA: pip install git+https://github.com/zundrium/django-usda.git 现在,您可以将 Django USDA 连同所需的依赖项一起添加到项目settings.py的INSTALLED_APPS中。 INSTALLED_APPS = ( ... ' rest_framework ', 'django_usda
django-usda-master.zip
内容介绍
# Django USDA An easy to set up Django Rest Framework API that is compatible with the USDA Nutrient Database. ## Requirements - Python (2.6.5+, 2.7, 3.2, 3.3, 3.4) - Django (1.4.11+, 1.5.5+, 1.6, 1.7) - Django Rest Framework (2.4.4) ## Demo To quickly see what this package can do, go to the [Demo repository][2]. ## Installation 1. You can install Django USDA with Python PIP: ``` pip install git+https://github.com/zundrium/django-usda.git ``` 2. Now you can add Django USDA to your `INSTALLED_APPS` in the `settings.py` of your project together with the required dependencies. ```python INSTALLED_APPS = ( ... 'rest_framework', 'django_usda', ) ``` 3. Add the following settings to the `settings.py` for Django Rest Framework to function properly. ```python REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' ], 'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend',), 'PAGINATE_BY': 250, 'PAGINATE_BY_PARAM': 'page_size', 'MAX_PAGINATE_BY': 250 } ``` 4. After that add the ViewSets that you want to use and the required url patterns to the `urls.py` of your project. ```python from django_usda.modelviewsets import FoodViewSet, FoodGroupViewSet, FoodLanguaLFactorViewSet, LanguaLFactorViewSet, NutrientDataViewSet, NutrientViewSet, SourceViewSet, DerivationViewSet, WeightViewSet, FootnoteViewSet, DataLinkViewSet, DataSourceViewSet, FoodInfoViewSet from django.contrib import admin router = routers.DefaultRouter() router.register(r'foods', FoodViewSet) router.register(r'foodgroups', FoodGroupViewSet) router.register(r'foodlangualfactors', FoodLanguaLFactorViewSet) router.register(r'langualfactors', LanguaLFactorViewSet) router.register(r'nutrientdatas', NutrientDataViewSet) router.register(r'nutrients', NutrientViewSet) router.register(r'sources', SourceViewSet) router.register(r'derivations', DerivationViewSet) router.register(r'weights', WeightViewSet) router.register(r'footnotes', FootnoteViewSet) router.register(r'datalinks', DataLinkViewSet) router.register(r'datasources', DataSourceViewSet) router.register(r'foodinfo', FoodInfoViewSet) urlpatterns = patterns('', ... url(r'^', include(router.urls)), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), ) ``` 5. Run `python manage.py migrate` if you have South or Django 1.7 installed. Otherwise use `python manage.py syncdb`. 6. [Download][1] the ASCII version of the 27th release of the USDA Nutrient Database. 7. Run `python manage.py import_r27 <path_to_zipfile>`. This can take up to 10 minutes. 8. Start the development server (Normally `python manage.py runserver`). 9. That's it, now you can use the viewsets in your application! (Example: `http://localhost:8000/foodinfo/01001`). [1]: http://www.ars.usda.gov/Services/docs.htm?docid=24912 [2]: https://github.com/Zundrium/django-usda-demo
评论
    相关推荐
    • django_rundirect:移至https
      django_rundirect 这是一个简单的Django命令,可在加载了Django设置和环境设置的情况下运行自定义Python脚本(或一行Python代码)。 因此,您无需在脚本中放入任何与Django设置相关的代码。 要安装此软件包 pip ...
    • Django 小例子
      NULL 博文链接:https://zzh.iteye.com/blog/370298
    • Django样板
      $~ git clone https://github.com/ibnuhalimm/django-boilerplate.git < your> 将virtualenv安装到您的项目中 $~ virtualenv 去你的项目 $~ cd 激活virtualenv $~ source bin/activate 安装所有依赖项 $~ pip...
    • Django Model
      NULL 博文链接:https://booby325.iteye.com/blog/1715169
    • django实例
      NULL 博文链接:https://yanshaozhi.iteye.com/blog/1835370
    • django_rest_tutorial:从https学习Django REST框架
      django_rest_tutorial 从学习django REST框架
    • lfs - django
      NULL 博文链接:https://lsqwzz.iteye.com/blog/1387958
    • django_app:https
      构建Project是为了使人们对Django框架更加熟悉。 这个项目的想法是用票务系统构建一个问题跟踪器。 人们可以轻松地为问题投票。 投票的想法是简单地显示应该首先修复哪些错误。 还应将功能与支付系统连接。 该项目的...
    • Django中间件
      NULL 博文链接:https://summerbell.iteye.com/blog/364461
    • Django的书
      NULL 博文链接:https://boyfuxin.iteye.com/blog/772696