小编Bri*_*n D的帖子

URL在jQuery中为AJAX请求编码字符串

我正在我的应用程序中实现Google的即时搜索.我想在用户输入文本输入时触发HTTP请求.我遇到的唯一问题是,当用户到达名字和姓氏之间的空格时,空间不会被编码为a +,从而破坏搜索.如何用a替换空格+,或者只是安全地对字符串进行编码?

$("#search").keypress(function(){       
    var query = "{% url accounts.views.instasearch  %}?q=" + $('#tags').val();
    var options = {};
    $("#results").html(ajax_load).load(query);
});
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery http

211
推荐指数
4
解决办法
40万
查看次数

是否可以通过Django的{%url%}模板标记传递查询参数?

我想将请求参数添加到{% url %}标签中,例如?office=foobar.

这可能吗?我找不到任何东西.

django django-templates

111
推荐指数
4
解决办法
6万
查看次数

PIL/JPEG库:"解码器jpeg不可用"

我尝试使用PIL在我的django应用程序中使用PIL进行一些JPEG工作,但是我得到了这个IOError ..不知道该怎么做.

""decoder jpeg not available""
Run Code Online (Sandbox Code Playgroud)

我错过了服务器上的JPEG解码器吗?如果是这样,我该如何解决?

python django redhat libjpeg python-imaging-library

51
推荐指数
4
解决办法
5万
查看次数

支持DB Context的模型已经改变; 考虑代码优先迁移

自创建数据库以来,支持"MyDbContext"上下文的模型已更改.请考虑使用"代码优先迁移"来更新数据库(http://go.microsoft.com/fwlink/?LinkId=238269).

是什么导致这种情况发生?我真的只是创建了一个全新的数据库并且什么都没改变,但每次我尝试从控制器访问一个模型时都会抛出这个.

编辑

它与我试图与两个独立实体共享连接字符串(即数据库)这一事实有关.

asp.net-mvc entity-framework

48
推荐指数
5
解决办法
13万
查看次数

如何在Android上的exif数据中保存GPS坐标?

我正在为我的JPEG图像写GPS坐标,并且坐标是正确的(正如我的logcat输出所示),但似乎它以某种方式被破坏了.读取exif数据会产生空值,或者在我的GPS情况下:512.976698 degrees, 512.976698 degrees.任何人都可以解释这个问题吗?

写它:

        try {
            ExifInterface exif = new ExifInterface(filename);
            exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, latitude);
            exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, longitude);
            exif.saveAttributes();
            Log.e("LATITUDE: ", latitude);
            Log.e("LONGITUDE: ", longitude);


        } catch (IOException e) {
            e.printStackTrace();
        }
Run Code Online (Sandbox Code Playgroud)

阅读它:

        try {
            ExifInterface exif = new ExifInterface("/sdcard/globetrotter/mytags/"+ TAGS[position]);
            Log.e("LATITUDE EXTRACTED", exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE));
            Log.e("LONGITUDE EXTRACTED", exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE));
        } catch (IOException e) {
            e.printStackTrace();
        }
Run Code Online (Sandbox Code Playgroud)

它会在(例如)37.715183,-117.260489和出来33619970/65540, 14811136/3368550,33619970/65540, 14811136/3368550.我做错了吗?

编辑:

所以,问题是我没有以正确定义的格式对其进行编码,这就像你在这里看到的那样:

在此输入图像描述

任何人都可以解释这种格式是什么?显然第一个数字是22/1 = 22度,但我无法弄清楚如何计算那里的小数.

gps android exif geotagging

23
推荐指数
3
解决办法
3万
查看次数

如果活动被杀死,AsyncTask会继续运行吗?

我想我知道这个问题的答案,但是一旦它的调用Activity被finish()编辑过,AsyncTask会继续存在吗?

    protected void onPreExecute() {
        Toast.makeText(getApplicationContext(), "Your data is processing.", Toast.LENGTH_LONG);
        finish();
    }
Run Code Online (Sandbox Code Playgroud)

编辑:到目前为止两个不同的答案:)

android android-asynctask

22
推荐指数
1
解决办法
1万
查看次数

mod_wsgi和python的多个安装

这是这个问题的延续,但它已经偏离,所以我开始了一个新问题.我想使用Python 2.5而不是OS X的默认2.6.我已经为我的终端和诸如此类的东西设置了这个,但是每当apache运行时它给我以下错误输出:

[Thu Jun 23 00:01:42 2011] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Thu Jun 23 00:01:42 2011] [warn] mod_wsgi: Compiled for Python/2.5.4.
[Thu Jun 23 00:01:42 2011] [warn] mod_wsgi: Runtime using Python/2.6.1.
[Thu Jun 23 00:01:42 2011] [notice] Digest: generating secret for digest authentication ...
[Thu Jun 23 00:01:42 2011] [notice] Digest: done
[Thu Jun 23 00:01:42 2011] [notice] Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l DAV/2 mod_wsgi/3.3 Python/2.6.1 configured -- resuming normal operations
Run Code Online (Sandbox Code Playgroud)

我已经设置了WSGIPythonPath以匹配sys.path在python shell中提供的内容: …

python apache mod-wsgi

17
推荐指数
2
解决办法
3万
查看次数

14
推荐指数
2
解决办法
1万
查看次数

使用Django中settings.py以外的设置文件

我想在django中使用不同的设置文件 - 特别是settings_prod - 但每当我尝试使用syncdb时--settings=settings_prod,它会抱怨:

python2.6 manage.py syncdb  --settings=settings_prod
Error: Can't find the file 'settings.py' in the directory containing 'manage.py'. It appears you've customized things.
You'll have to run django-admin.py, passing it your settings module.
(If the file settings.py does indeed exist, it's causing an ImportError somehow.)
Run Code Online (Sandbox Code Playgroud)

我也尝试过将环境变量设置DJANGO_SETTINGS_MODULE=settings_prod为止.

编辑:我还在我的wsgi文件中设置了环境变量,也没有结束:

import os
import sys

from django.core.handlers.wsgi import WSGIHandler

os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings_prod'
application = WSGIHandler()
Run Code Online (Sandbox Code Playgroud)

建议?

django

14
推荐指数
2
解决办法
2万
查看次数

对象无法写入是什么意思?

我不知道这里发生了什么......我只是想检查模型字段的值,然后相应地更新它......任何帮助或见解都值得赞赏!

模型:

class UserProfile(models.Model):
    user = models.ForeignKey(User, unique=True)
    beta = models.CharField(max_length=1, blank=True, null=True)
Run Code Online (Sandbox Code Playgroud)

视图:

from internal.accounts.models import UserProfile
from django.contrib.auth.models import User
@login_required    
def beta_testers(request):
    user = User.objects.get(username=request.user.username)
    user_profile = user.get_profile()

    count = UserProfile.objects.filter(beta='1').count()

    if count < 50 and not user_profile['beta']:
        user_profile['beta'] = '1'
        user_profile.save()
Run Code Online (Sandbox Code Playgroud)

错误:

TypeError at /utilities/beta-signup/
'UserProfile' object is unsubscriptable
Request Method: GET
Request URL:    http://localhost/utilities/beta-signup/?x=1&y=15
Django Version: 1.2.1
Exception Type: TypeError
Exception Value:    
'UserProfile' object is unsubscriptable
Exception Location: C:/django\internal\cms_helper\views.py in beta_testers, line 284
Run Code Online (Sandbox Code Playgroud)

django django-models django-views

12
推荐指数
2
解决办法
9659
查看次数