Django Angular Project 2

Published: Nov. 23, 2016, 8:09 p.m. Back

Author: rachell

Homework from last time was to work on 'people' app and foreign keys. I worked on both but got stuck on both. 

11/23 Wednesday: 

  1. Combined deleted accounts app and put user models in donate for simplification on angular side

  2. Fixed foreign key category and subcategory selection html

    • <p>
      <label>Category choice: </label>
      <select ng-model="donate.category">
      <option data-ng-repeat="cat in categories" value="{{cat.resource_uri}}" ng-click="getSubCategories(cat)">{{cat.title}}<option>
      </select>
      </p>
      <p ng-show="donate.category">
      <label>SubCategory choice: </label>
      <select ng-model="donate.subcategory">
      <option data-ng-repeat="sub in subcategories" value="{{sub.resource_uri}}">{{sub.title}}<option>
      </select>
      </p>
    • ....

      <td ng-bind="d.category.title"></td>
      <td ng-bind="d.subcategory.title"></td>
  3. call to foreign keys cat and subcat in apiSvc.js:

    • function get(resourceName, params){
      var queryString = "";
      for (var k in params){
      if (params.hasOwnProperty(k)){
      queryString += "&" + k + "=" + params[k]
      }}
  4. Add a delete function in apiSvc.js

    • function remove(resourceName, resourceId){
      return $http.delete("/api/v1/" + resourceName+"/"+ resourceId + "/?format=json")
      }
  5. in resources.py import and add filtering 

    • from tastypie.resources import ModelResource, ALL, ALL_WITH_RELATIONS
    • class SubCategoryResource(ModelResource):
      category = fields.ForeignKey(CategoryResource, 'category', null=True, full=True)
      class Meta:
      queryset = SubCategory.objects.all()
      filtering = {
      'category' : ALL_WITH_RELATIONS,
      }
      resource_name = 'subcategory'
  6. Homework: Define minimum viable product. 

Check out my progress here


No comments here yet


New Comment