小编Pru*_*off的帖子

MongoError:无法更改文档的_id

我是MongoDB和Backbone的新手,所以我试着理解它们,但这很难.我有一个很大的问题:我无法理解如何操纵Backbone.Model中的属性只在我需要的视图中使用.更具体 - 我有一个模型:

window.User = Backbone.Model.extend({

    urlRoot:"/user",
    idAttribute: "_id",

    defaults: {
        _id: null,
        name: "",
        email: "foo@bar.baz"
    }
});

window.UserCollection = Backbone.Collection.extend({
    model: User,

    url: "user/:id"
});
Run Code Online (Sandbox Code Playgroud)

我有一个观点:

beforeSave: function(){
    var self = this;
    var check = this.model.validateAll();
    if (check.isValid === false) {
        utils.displayValidationErrors(check.messages);
        return false;
    }
    this.saveUser();
    return false;
},

saveUser: function(){
    var self = this;
    console.log('before save');
    this.model.save(null, {
        success: function(model){
            self.render();
            app.navigate('user/' + model.id, false);
            utils.showAlert('Success!', 'User saved successfully', 'alert-success');
        },
        error: function(){ …
Run Code Online (Sandbox Code Playgroud)

javascript mongodb express backbone.js

15
推荐指数
2
解决办法
8087
查看次数

Satchmo clonesatchmo.py ImportError:无法导入名称execute_manager

我得到satchmo尝试,但我一开始尝试有一个很大的问题,我不明白什么是错的.当我$ python clonesatchmo.py进入清晰的django项目时,它会产生一个错误:

$ python clonesatchmo.py
Creating the Satchmo Application
Customizing the files
Performing initial data synching
Traceback (most recent call last):
  File "manage.py", line 18, in <module>
    from django.core.management import execute_manager
ImportError: cannot import name execute_manager
Traceback (most recent call last):
File "manage.py", line 18, in <module>
  from django.core.management import execute_manager
ImportError: cannot import name execute_manager
Error: Can not copy the static files.
Error: Can not syncdb.
Run Code Online (Sandbox Code Playgroud)

AND创建一个商店文件夹.像这样尝试smth工作!!:

$ python manage.py shell
>>> import os, sys
>>> …
Run Code Online (Sandbox Code Playgroud)

python django django-models satchmo django-manage.py

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