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 6665623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:44:33+00:00 2026-05-26T02:44:33+00:00

I have a problems with my django api. I have a website that works

  • 0

I have a problems with my django api. I have a website that works well, and now I want make a api with django-piston to make a android app. When I try to get some data, and I sent some key in the url, the handlers of my api project are empty, these are my urls.py and handlers.py inside api app.

urls.py

from django.conf.urls.defaults import *
from piston.resource import Resource
from myproject.api.handlers import ProgramadorHandler
from myproject.api.handlers import UserHandler
from myproject.api.handlers import GetProgHandler
from myproject.api.handlers import GetUserHandler

prog_handler = Resource(ProgramadorHandler)
user_handler = Resource(UserHandler)
get_prog_handler = Resource(GetProgHandler)
get_user_handler = Resource(GetUserHandler)

urlpatterns = patterns('',
url(r'^1.0/(?P<username>)\w+/(?P<password>)\w+/(?P<api_key>)\d+/programadores.(?P<emitter_format>.+)$', prog_handler),
url(r'^1.0/(?P<username>)\w+/(?P<password>)\w+/(?P<api_key>)\d+/programadores/(?P<prog_id>\d+)/prog.(?P<emitter_format>.+)$', get_prog_handler),
url(r'^1.0/(?P<username>)\w+/(?P<password>)\w+/(?P<api_key>)\d+/usuarios.(? P<emitter_format>.+)$', user_handler),
url(r'^1.0/(?P<username>)\w+/(?P<password>)\w+/(?P<api_key>)\d+/user.(? P<emitter_format>.+)$', get_user_handler),
)

And this is my handlers.py

from piston.handler import BaseHandler
from piston.utils import rc, HttpStatusCode
from myproject.web.models import *
from django.contrib.auth import authenticate

class ProgramadorHandler(BaseHandler):
allowed_methods = ('GET',)
model = Programador

def read(self, request, username, password, api_key):
    user = authenticate(username=username, password=password)
#       if (api_key != 29010):
#           return rc.FORBIDDEN

    if user is not None:
        return Programador.objects.filter(nombre="Programador completo 2")

    return Programador.objects.all()


class GetProgHandler(BaseHandler):
allowed_methods = ('GET',)
model = Programador

def read(self, request, username, password, api_key, prog_id):
    user = authenticate(username=username, password=password)
    if user is None or (api_key != 29010):
        return rc.FORBIDDEN

    return Programador.objects.all()


class UserHandler(BaseHandler):
allowed_methods = ('GET',)
model = Usuario

def read(self, request, username, password, api_key):
    user = authenticate(username=username, password=password)
    if(api_key != 29010):
        return rc.FORBIDDEN

    return Usuario.objects.all()


class GetUserHandler(BaseHandler):
allowed_methods = ('GET',)
model = Usuario

def read(self, request, username, password, api_key):
    #user = authenticate(username=username, password=password)
#       if (api_key != 29010):
#           user = "hola"
        #return rc.FORBIDDEN

    return Usuario.objects.get(username="ersame")

How I can fix that?

  • 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-26T02:44:33+00:00Added an answer on May 26, 2026 at 2:44 am

    I think you may have your regex’s wrong in urls.py. The pattern specifier for the groups need to be inside the parenthesis, for example,

    instead of:

    url(r'^1.0/(?P<username>)\w+/(?P<password>)\w+/(?P<api_key>)\d+/programadores.(?P<emitter_format>.+)$', prog_handler), ...
    

    try:

    url(r'^1.0/(?P<username>\w+)/(?P<password>\w+)/(?P<api_key>\d+)/programadores.(?    P<emitter_format>.+)$', prog_handler), ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using django-piston for my REST json api, and I have it all set
I have a Django app that needs to pull the follower_count information from several
I am having problems with django forms and image uploads. I have googled, read
I have an odd problem with Django. I have a set of objects that
I have a problem with the jquery-autocomplete pluging and my django script. I want
We have a website made by Django. And there is no problem when access
I have problems with dealing with widows within a multicols environment, that is, I
I'm building a RESTful app on Django and Tasty Pie. I have a problem
I have just spotted that something is wrong with my django-admin.py command. I checked
Hi I have some problems that has been bothering me for a week. I

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.