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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:57:31+00:00 2026-06-10T08:57:31+00:00

This is my api.py # myapp/api.py from django.contrib.auth.models import User from tastypie.authorization import Authorization

  • 0

This is my api.py

# myapp/api.py

from django.contrib.auth.models import User
from tastypie.authorization import Authorization
from tastypie import fields
from tastypie.resources import ModelResource, ALL, ALL_WITH_RELATIONS
from links.models import Link


class UserResource(ModelResource):

    class Meta:
        queryset = User.objects.all()
        resource_name = 'users'
        excludes = ['email', 'password', 'is_active', 'is_staff', 'is_superuser']
        allowed_methods = ['post','get']
        fields = ['username']

        def obj_create(self, bundle, request=None, **kwargs):
            try:
                bundle = super(CreateUserResource, self).obj_create(bundle, request, **kwargs)
                bundle.obj.set_password(bundle.data.get('password'))
                bundle.obj.save() 
            except IntegrityError:
                raise BadRequest('That username already exists')
            return bundle

Typed that on a python shell:

  r = requests.post("http://localhost:8000/api/users/username=Puck")

And got 404 as error response. How do I go about creating a new user using post?

urls.py

from django.conf.urls import patterns, include, url
from django.conf.urls.defaults import *
from links.api import LinkResource
from links.api import UserResource
from tastypie.api import Api
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

v1_api = Api(api_name='v1')
v1_api.register(UserResource())
v1_api.register(LinkResource())




urlpatterns = patterns('',
    # Examples:


    # Uncomment the admin/doc line below to enable admin documentation
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
     (r'^api/', include(v1_api.urls)),
)

url schema:

^admin/
^api/ ^(?P<api_name>v1)/$ [name='api_v1_top_level']
^api/ ^(?P<api_name>v1)/ ^(?P<resource_name>link)/$ [name='api_dispatch_list']
^api/ ^(?P<api_name>v1)/ ^(?P<resource_name>link)/schema/$ [name='api_get_schema']
^api/ ^(?P<api_name>v1)/ ^(?P<resource_name>link)/set/(?P<pk_list>\w[\w/;-]*)/$ [name='api_get_multiple']
^api/ ^(?P<api_name>v1)/ ^(?P<resource_name>link)/(?P<pk>\w[\w/-]*)/$ [name='api_dispatch_detail']
^api/ ^(?P<api_name>v1)/ ^(?P<resource_name>users)/$ [name='api_dispatch_list']
^api/ ^(?P<api_name>v1)/ ^(?P<resource_name>users)/schema/$ [name='api_get_schema']
^api/ ^(?P<api_name>v1)/ ^(?P<resource_name>users)/set/(?P<pk_list>\w[\w/;-]*)/$ [name='api_get_multiple']
^api/ ^(?P<api_name>v1)/ ^(?P<resource_name>users)/(?P<pk>\w[\w/-]*)/$ [name='api_dispatch_detail']
The current URL, api/v1/users/username=Puck, didn't match any of these.
  • 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-10T08:57:33+00:00Added an answer on June 10, 2026 at 8:57 am

    The URL you want to access is:

    http://localhost:8000/api/v1/users/?username=Puck
    

    since you declared api_name='v1'.

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

Sidebar

Related Questions

I'm building a simple API using django-tastypie. The idea is I have two resources:
My app uses an API from an external JAR file. This JAR file has
I've had a read of this http://docs.b-list.org/django-registration/0.8/backend-api.html and i've had a shot at making
I try to fetch user's feeds via graph api from my Android application. It
I'm requesting an API key from this site and they are asking me for
Question: Is this API authentication technique easily hackable? apiKey = 123456789 apiCallId = 1256341451
So I'm trying to access this api https://www.clarityaccounting.com/api-docs/ using SUDS. Here is the code
I'm using LIFT to serve a RESTful API, and I want this API to
I'm consuming some data using the fogbugz XML API. This API always offers data
I am trying to upload a pdf file using webservice api. But this api

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.