Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8567139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:48:52+00:00 2026-06-11T17:48:52+00:00

I would like to make a Tastypie based API adder. Here is how it

  • 0

I would like to make a Tastypie based API adder. Here is how it works… the user would post to the two numbers they would like added and using Tastypie + Django I would like to include the added number on the return to the user.

I have no interest in putting it into the mySQL database.

class Adder(resource):
    class Meta:
    authorization = Authorization()
    authentication = Authentication()

    def hydrate(self,bundle):
        _a = bundle.data['first_number']
        _b = bundle.data['second_number']

        self.create_response(request, return_dict)
        return bundle

The documentation for Tastypie really seems to revolve around the models (for obvious reasons).

But I was curious if the create_response can be called from within the hydrate method and if calling the hydrate method is the right way of handling the post data.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:48:53+00:00Added an answer on June 11, 2026 at 5:48 pm

    I would probably skip the finer-grained things like hydrate, apply_sorting, build_filters, etc.

    I’m assuming that without objects behind the api you’re using a list-looking url like /api/v1/add_stuff/, and assuming you’re accepting POST requests. If these assumptions are wrong you can adjust by changing to post_detail, get_list, etc.

    def post_list(self, request, **kwargs):
        _a = request.POST.get('first_number', None)
        _b = request.POST.get('second_number', None)
        if None in (_a, _b):
            raise HttpBadRequest()
        return self.create_response(request, {'result': _a + _b})
    

    Note that I think this code would work but I haven’t tested it. It’s meant to provide a starting point.

    This section of the Tastypie docs describes the order in which the various methods are called, and toward the bottom of the page there is a full API reference so you can see what parameters things expect and what they are supposed to return.

    Edit:

    The flow for this situation will look something like this:

    1. In dispatch, the request uri is inspected. Depending on whether a
      detail or a list uri was requested (/api/v1/add_stuff/<pk>/ or
      /api/v1/add_stuff/), handling is delegated to dispatch_detail or
      dispatch_list. This is also where authentication, authorization,
      and throttling checks happen.

    2. In dispatch_list, the request method is inspected and the call is
      delegated to a method named '%s_list' % request.METHOD.lower().
      To answer your comment, these are magical method names. If the
      request method is POST, dispatch_list looks for a method named
      post_list and an error is thrown if the appropriate handler
      is not defined.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like make a script using PHP (probably need JS) to send POST
I would like to make sure my classes are robust - even if they
I would like to make my app freeware, but if a user is willing
I would like to make web service which will delete post asynchronusly. I am
I would like to make sure that when user log in it will stay
I would like to make a user's changes to an ExtJS datagrid's column display
Hi I have not well understand how rhino license works. I would like make
I would like make an extension method for the generic class A which takes
Would like to make anapplication in Java that will not automatically parse parameters used
I would like to make a password and username entry field. And a submit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.