我有2个型号如下
商人
class MerchantProfile(StateModel):
class Meta:
verbose_name = "Merchant Profile"
ordering = ('name',)
def __unicode__(self):
return u'%s' % (self.name,)
user = models.OneToOneField(UserProfile, related_name="merchant_profile")
payment_card = models.OneToOneField(PaymentCard, related_name="merchant_profile")
current_state = models.IntegerField('State', choices=STATE_CHOICES)
name = models.CharField('Merchant Name', max_length=64)
Run Code Online (Sandbox Code Playgroud)
类别
class Category(models.Model):
merchant = models.ForeignKey(MerchantProfile, related_name="category")
name = models.CharField(max_length=30)
is_active=models.BooleanField()
Run Code Online (Sandbox Code Playgroud)
我有资源文件如下
儿童资源
class MerchantCategoryResource(ModelResource):
api_key = fields.CharField(attribute='merchant__user__api_key', readonly=True)
class Meta:
#get username from headers and apply filter query
queryset = Category.objects.all()
resource_name = 'merchantcategory'
#excludes = ['id','email', 'password', 'is_active', 'is_staff', 'is_superuser']
detail_allowed_methods = …Run Code Online (Sandbox Code Playgroud) 我试图实现简单的ajax GET请求.在回调部分我想调用一些函数.代码如下
$.ajax({
url: "<?php echo SITE_URL?>ajax_pages/ajx_getcard.php?id="+obj.value,
context: document.body
}).done(function() {
$(this).addClass("done");
});
Run Code Online (Sandbox Code Playgroud)
但它显示例外
未捕获的类型错误:对象#没有 '完成' replace_entry.php方法:105 getCardno replace_entry.php:105的onblur replace_entry.php:118
我正在使用谷歌浏览器
我正在使用RESTAPI与django服务器通信php客户端.我发布了json数据.php代码是
$arr=array("username"=>"dtthtdas45",
"password"=>"123456",
"email"=>"ramg@ram.com",
"is_active"=>"1",
"is_staff"=>"1",
"is_superuser"=>"1",
"promo_code"=>"1212121",
"gender"=>"m",
"birth_year"=>"1991",
"zip"=>"77707",
"first_name"=>"john",
"last_name"=>"doe",
"current_state"=>"1"
);
echo $data_string= json_encode($arr);
$ch = curl_init('http://localhost:8000/api/ecp/user/?format=json');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);
Run Code Online (Sandbox Code Playgroud)
如何仅使用命令行调用相同的URL?
我尝试了下面的内容
curl -H 'Content-Type: application/json' -X POST -d '{"username": "dtthtdas45", "password": "123456","email":"email@email.com","is_active":"1","is_staff":"1","is_superuser",promo_code":"1212121","gender":"m","birth_year":"1991","zip":"77707","first_name":"john","last_name":"doe","current_state":"1"}' http://localhost:8000/api/ecp/user/?format=json
Run Code Online (Sandbox Code Playgroud)
但没有运气,它显示了下面的错误
curl: (6) Couldn't resolve host 'application'
curl: (6) Couldn't resolve host 'dtthtdas45,'
curl: (6) Couldn't resolve host 'password:'
Run Code Online (Sandbox Code Playgroud) 我有ATM卡的数据库,其中有字段account_no,card_no,is_blocked,is_activated,issue_date字段帐号和卡号不唯一,因为旧卡将过期并标记为is_block = Y和另一个具有相同卡号的记录,帐号将插入到is_blocked = N的新行中.现在我需要在issue_date ie的帮助下更新is_blocked/is_activated
UPDATE card_info set is_blocked='Y' where card_no='6396163270002509'
AND opening_date=(SELECT MAX(opening_date) FROM card_info WHERE card_no='6396163270002509')
Run Code Online (Sandbox Code Playgroud)
但是不允许我这样做它会引发跟随错误
1093 - You can't specify target table 'card_info' for update in FROM clause
Run Code Online (Sandbox Code Playgroud) 我有一个像下面的数组
Array
(
[0] => '13-Nov'
[1] => 'PUJA SUNUWAR'
[2] => '13-Nov'
[3] => '...301303'
[4] => 'TT1331600004\DLG'
[5] => '-10000.00'
[6] => '0'
[7] => '90000.00'
)
Run Code Online (Sandbox Code Playgroud)
我需要删除第四项数组并保存为
Array
(
[0] => '13-Nov'
[1] => 'PUJA SUNUWAR'
[2] => '13-Nov'
[3] => 'TT1331600004\DLG'
[4] => '-10000.00'
[5] => '0'
[6] => '90000.00'
)
Run Code Online (Sandbox Code Playgroud)
我不想迭代数组的每个元素.是否有任何一个镜头功能,如array_pop删除数组的第n个元素?
我用httpclient来调用用django编写的restapi.它返回了json输出.我的httpresponse变量存储它,然后将响应转换为字符串,然后转换为json对象,我认为它很长,虽然它正在工作.我是java的新手,任何人都可以告诉我,下面代码的最佳替代逻辑是什么
public void onClick(View v) {
// TODO Auto-generated method stub
HttpClient httpclient = new DefaultHttpClient();
HttpGet httppost = new HttpGet("http://10.0.2.2:8000/api/ca/entry/?
format=json&username=pragya");
try {
// Add your data
//List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
//nameValuePairs.add(new BasicNameValuePair("username", un.getText().toString()));
//nameValuePairs.add(new BasicNameValuePair("username", pw.getText().toString()));
//httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append((line + "\n")); …Run Code Online (Sandbox Code Playgroud) 我按照步骤创建了Hash Key.
下载openssl
解压缩并复制bin文件夹中的所有文件,包括openssl.exe
将从Openssl的bin文件夹复制的所有文件粘贴到Jdk bin文件夹.
然后我在openssl.exe终端窗口上使用了以下命令
keytool -exportcert -alias androiddebugkey -keystore C:\ Users\Joelle.android\debug.keystore | openssl sha1 -binary | openssl enc -a -e
但它抛出以下错误
openssl error :'keytool is invalid command'
Run Code Online (Sandbox Code Playgroud)
请指导我......
感谢名单
我使用python httplib来实现REST api以连接Django tastypie.但每当我尝试获取状态代码时,它都会显示以下错误
AttributeError at /actions/login
HTTPResponse instance has no attribute 'status_code'
Run Code Online (Sandbox Code Playgroud)
我的代码如下
import hashlib
import hmac
from django.shortcuts import render_to_response
from django.template import RequestContext
def loginAction(request):
username=request.POST['email']
password=request.POST['password']
import httplib, urllib
params = urllib.urlencode({'username': username})
#hash username here to authenticate
digest=hmac.new("qnscAdgRlkIhAUPY44oiexBKtQbGY0orf7OV1I50", str(request.POST['password']),hashlib.sha1).hexdigest()
auth=username+":"+digest
headers = {"Content-type": "application/json","Accept": "text/plain","Authorization":auth}
conn = httplib.HTTPConnection("localhost",8000)
conn.request("POST", "/api/ecp/profile/", params, headers)
conn.set_debuglevel(1)
response = conn.getresponse()
return response
Run Code Online (Sandbox Code Playgroud)