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

  • Home
  • SEARCH
  • 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 6592577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:34:22+00:00 2026-05-25T17:34:22+00:00

I am porting my API from Piston to TastyPie. We have existing clients, so

  • 0

I am porting my API from Piston to TastyPie. We have existing clients, so we want to keep the url structure of the API the same.

My site’s top level urls.py conf looks like this:

    urlpatterns = patterns('',
          ........LOTS OF STUFF

          (r'^v1/', include('api.urls')),

Using Piston, every individual resource is then registered independently in api.urls and added to the urlpatterns, so you might see /v1/deals/ for example.

Now, I’m having some issues recreating this structure with TastyPie. At its top level, the Tastypie Api() object’s urlpatterns expects a capturing group called “api_name”. By default, v1 is hardcoded as that top level pattern, though you can override it by passing “api_name” as a keyword argument when instantiating Api().

My current api.urls.py looks like this (with tastypie):

   v1_api = Api()
   v1_api.register(DealResource())

   urlpatterns = patterns('',
       (r'^', include(v1_api.urls)),

)

The result is that the pattern to be matched for the API is now ‘/v1/v1/[resource_name]/’.

One issue is that I don’t see how I can remove ^v1/’ from the top level url conf. Our index page matches ‘^$’, so I can’t just go that route.

I suppose I could just register individual modelresources, rather than the api object. That seems suboptimal though. Am I wrong?

I’ve also considered subclassing the Tastypie Api object and removing the “api_name” capturing group.

Any thoughts?

  • 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-05-25T17:34:22+00:00Added an answer on May 25, 2026 at 5:34 pm

    I believe the best approach is still to remove the ‘v1’ prefix from the top-level urlconf. Something along the lines of:

    urlpatterns = patterns('',
        ........LOTS OF STUFF
        (r'^$', 'app.views.home_page'),
        (r'', include('api.urls')),
    )
    

    This way, empty requests will map to your homepage while API requests will go on to your api.urls config.

    Another way to go about this is to simply add the API urls to the urlpatterns instance directly:

    urlpatterns = patterns('',
        ........LOTS OF STUFF
    )
    
    urlpatterns += api.urls.ulrpatterns
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been porting an application at work from the old Bing API to
Porting an application from C# (1.1 framework) to VB.NET (3.5 framework), and I have
I am currently porting an application from iOS into Android and I have ran
I'm currently porting a proprietary dll (an API) to C#, and I have some
I'm currently porting a proprietary dll (an API) to C#, and I have some
i have read the thread Google Goggles API . and From NotAnotherCodeBlog have created
I have a web API that I want to allow any domain to submit
I'm loading a URL from my own web site into a UIWebView in an
Is there a way to get the shortened t.co url from the API? I
I have a debugger that I am porting over to *bsd from linux. Currently,

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.