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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:10:38+00:00 2026-06-03T14:10:38+00:00

I have used django-tastypie using GET,POST,PUT,DELETE methods , they are working smoothly when both

  • 0

I have used django-tastypie using GET,POST,PUT,DELETE methods , they are working smoothly when both client and server are from same domain but if I make a request from different domain nothing happened at all.

Any clue?

models.py

from django.db import models
class Entry(models.Model):
    title = models.CharField(max_length=30)
    body = models.CharField(max_length=40)
    pub_date = models.DateField()
    slug=models.CharField(max_length=30)

resources.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 myapp.models import Entry


class UserResource(ModelResource):
    class Meta:
        queryset = User.objects.all()
        resource_name = 'user'
        excludes = ['email', 'password', 'is_active', 'is_staff', 'is_superuser']
        filtering = {
        'username': ALL,
        }


class EntryResource(ModelResource):

    class Meta:
    queryset = Entry.objects.all()
    resource_name = 'entry'
    authorization = Authorization()
    filtering = {
        'user': ALL_WITH_RELATIONS,
        'pub_date': ['exact', 'lt', 'lte', 'gte', 'gt'],
        }

urls.py

from django.views.generic.simple import direct_to_template
from django.conf.urls.defaults import *
from tastypie.api import Api
from myapp.resources import EntryResource, UserResource

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

urlpatterns = patterns('',
# The normal jazz here...
     (r'^api/', include(v1_api.urls)),
     (r'^basic/$', direct_to_template, {'template': 'todos/test.html'})
)

And template file is as below

<!DOCTYPE html>
<html>
    <head>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script language="javascript">
  jQuery(document).ready(function($) {
      var data = JSON.stringify({
      "body": "This will prbbly be my lst edited  post.",
      "pub_date": "2011-05-22T00:46:38",
       "slug": "another-post",
      "title": "Another Post",

     });
  $.ajax({
        url: "http://localhost:8000/api/v1/entry/1/?format=json",
        type: 'PUT',
            contentType: 'application/json',
        data: data,
        dataType: 'json',
        processData: false,
        success:function(data) { 
            alert(data);
            },
        error : function(data){
            alert('error')
            },  
        })
  }) 

 </script>
    </head>
    <body>
body content goes here 
    </body>
</html>

now when i run http://localhost:8000/basic it working perfectly for CRUD

later i installed apache server and copied that basic.html. When I run http://localhost:81/basic.html then json data are not accepted by server. I have run both apache and python server parallelly.

  • 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-03T14:10:41+00:00Added an answer on June 3, 2026 at 2:10 pm

    You will need to set your client and your server to do cross domain ajax.

    In jquery, you would do set crossDomain : true in your $.ajax() call
    (see http://api.jquery.com/jQuery.ajax/)

    On the server side, you will need to set a couple of accept headers
    http://enable-cors.org/

    You can find out more about cross domain request by looking up the CORS specification:
    http://www.w3.org/TR/cors/

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

Sidebar

Related Questions

First i want to thanks you for watching my post! I have used django
I am used to using Django for some time now. Now I have to
It's my first time using PostgreSQL 8.4.2 with Django(I have always used MySQL or
I have an apps and I am making used of django admin, but my
I have a django app which is used for managing registrations to a survey.
I have used the Telerik ASP.NET controls, and personally I think they have been
I have used Django before (version 1.2) and generally I like it... it is
How well does Django's anti-spam system in the comments framework work? Have you used
Has anyone used django-social-auth , django-registration and django-profiles together. Do they work well together?
Have you used django-proxy ? Can you give me an example of when it

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.