小编Tay*_*red的帖子

OperationalError,没有这样的列.Django的

我是django的新手,能够在没有任何错误的情况下完成djangoproject.com上的教程.我现在正在浏览http://www.django-rest-framework.org/上的Django REST框架教程. 我几乎完成了它并且刚刚添加了身份验证.现在我得到:

OperationalError at /snippets/
no such column: snippets_snippet.owner_id
Request Method: GET
Request URL:    http://localhost:8000/snippets/
Django Version: 1.7
Exception Type: OperationalError
Exception Value:    
no such column: snippets_snippet.owner_id
Exception Location: /Users/taylorallred/Desktop/env/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py in execute, line 485
Python Executable:  /Users/taylorallred/Desktop/env/bin/python
Python Version: 2.7.5
Python Path:    
['/Users/taylorallred/Desktop/tutorial',
 '/Users/taylorallred/Desktop/env/lib/python27.zip',
 '/Users/taylorallred/Desktop/env/lib/python2.7',
 '/Users/taylorallred/Desktop/env/lib/python2.7/plat-darwin',
 '/Users/taylorallred/Desktop/env/lib/python2.7/plat-mac',
 '/Users/taylorallred/Desktop/env/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Users/taylorallred/Desktop/env/Extras/lib/python',
 '/Users/taylorallred/Desktop/env/lib/python2.7/lib-tk',
 '/Users/taylorallred/Desktop/env/lib/python2.7/lib-old',
 '/Users/taylorallred/Desktop/env/lib/python2.7/lib-dynload',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Users/taylorallred/Desktop/env/lib/python2.7/site-packages']
Server time:    Sat, 11 Oct 2014 07:02:34 +0000
Run Code Online (Sandbox Code Playgroud)

我已经在网上找了几个地方,而不仅仅是解决方案的stackoverflow,似乎一般来说问题出在我的数据库上,需要删除它然后重新制作它,我已经做了好几次,教程甚至还有我删除数据库并在点重新制作.这是我的models.py:

from django.db import models
from pygments.lexers import …
Run Code Online (Sandbox Code Playgroud)

python django django-rest-framework

35
推荐指数
8
解决办法
8万
查看次数

在javascript中返回字符串中的第一个非重复字符

所以我试着在搜索中寻找这个,但我最接近的是几种不同语言的类似答案,我想用Javascript来做.

问题是我有一个任意字符串,我想返回第一个非重复字符.EX:'aba' - >会返回b'aabcbd' - >会返回c.这是我到目前为止,只是一个简单的for循环开始.

var someString = 'aabcbd';



var firstNonRepeatedCharacter = function(string) {
for(var i = 0; i < someString.length; i++){

}
};
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/w7F87/ 不知道从哪里开始

javascript

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

application(_:didFinishLaunchingWithOptions :)不会在其中打印任何内容

我正在测试一个简单的应用程序上的推送通知.目前,它所做的只是接收推送通知而不做任何其他事情.

当我尝试print()application(_:didFinishLaunchingWithOptions:)函数内部输出信息时,它拒绝打印任何东西.

我的代码:

class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        print("TEST TEST TEST")
        registerForPushNotifications(application)
        print("TEST TEST TEST")
        if let notification = launchOptions?[UIApplicationLaunchOptionsRemoteNotificationKey] as? [String: AnyObject] {
            print(notification)
            let aps = notification["aps"] as! [String: AnyObject]
            print(aps)
        }
        return true
    }

    func registerForPushNotifications(application: UIApplication) {
        let notificationSettings = UIUserNotificationSettings(forTypes: [.Badge, .Sound, .Alert], categories: nil)
        application.registerUserNotificationSettings(notificationSettings)
    }
}
Run Code Online (Sandbox Code Playgroud)

函数中的所有打印行都不会向控制台打印任何内容.我已经确认他们被使用断点击中了.为什么没有印刷?

我能够找到一个使用警报的解决方法,这些工作很好,并提供了我需要的所有信息,但它无法回答为什么在控制台中没有打印任何内容.

解决方法代码:

class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: …
Run Code Online (Sandbox Code Playgroud)

swift

4
推荐指数
1
解决办法
639
查看次数

有没有办法让服务器在不使用推送通知的情况下将数据推送到应用程序?

我正在寻找一种方法将数据推送到类似于APN但不使用APN的应用程序.有没有办法做到这一点?我想这样做的原因是,如果用户禁用了我想仍然能够将数据发送到应用程序的通知,而无需用户输入,例如拉动刷新或者你有什么.我只希望它在App处于前台时发生.

基本上,我希望它像普通一样使用推送通知,因此如果有新数据可用,则会通知用户应用程序是否已关闭,以便用户可以单击该应用程序并打开应用程序并显示新信息.然后,如果用户通过设置禁用推送通知,则用户将不再接收通知,但如果有新数据可用,应用仍会刷新.

我尝试使用GCM/FCM,但只是背负APN,所以如果设置关闭通知,它将无法工作.

这甚至可能吗?

apple-push-notifications ios

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