小编Joh*_*irt的帖子

Django:关系"django_site"不存在

我在aws上运行测试django服务器,我刚刚安装了django-userena,当我尝试在点击提交时注册用户时,我收到以下消息:

关系"django_site"不存在第1行:..."django_site"."domain","django_site"."name"FROM"django_si ...

我不确定这里出了什么问题.我做了一些研究并添加" 'django.contrib.sites',"到我安装的应用程序中,但我仍然收到错误.我将失去一个额外的步骤.有什么建议或意见吗?

python django

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

Android SDK:如何设置屏幕亮度

我一直在环顾四周,我只能找到能够设置一个Activity的亮度的代码.我正在尝试更改实际的手机设置.我试过的代码是:

public class AutoPowerManagerActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        try {
            adjustBright();
        } catch (SettingNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    private void adjustBright() throws SettingNotFoundException {
        // TODO Auto-generated method stub
        int brightnessMode = Settings.System.getInt(getContentResolver(),
                Settings.System.SCREEN_BRIGHTNESS_MODE);
        if (brightnessMode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
            Settings.System.putInt(getContentResolver(),
                    Settings.System.SCREEN_BRIGHTNESS_MODE,
                    Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
        }

        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        layoutParams.screenBrightness = 0.5F;
        getWindow().setAttributes(layoutParams);
    }
}
Run Code Online (Sandbox Code Playgroud)

java android

5
推荐指数
1
解决办法
3672
查看次数

Django:ManyToManyField未定义错误

我一直在尝试在django-userena中编辑用户配置文件,除了我的ManyToManyFields之外一切都很好.我设置了以下型号:

class MyProfile(UserenaBaseProfile):
    user = models.OneToOneField(User,unique=True,  
                        verbose_name=_('user'),related_name='my_profile')
    favourite_snack = models.CharField(_('favourite snack'),max_length=5) 
    firstname = models.CharField(_('username'), max_length=55)
    lastname = models.CharField(_('lastname'), max_length=66)
    industry = models.CharField(_('industry'), max_length=190)
    occupation = models.CharField(_('occupation'), max_length=140)
    bio = models.TextField(_('bio'))
    phone = models.CharField(_('phone'), max_length=10)
    skills = models.ManyToManyField(Skills)
    Interests = models.ManyToManyField(Interests)
    website = models.URLField()

class Skills(models.Model):
    skillName = models.CharField(max_length=80)

class Interests(models.Model):
    interestName = models.CharField(max_length=140)
Run Code Online (Sandbox Code Playgroud)

当我同步数据库时,我收到以下错误:

 File "/pathtodjango/bin/app/accounts/models.py", line 17, in MyProfile
    skills = models.ManyToManyField(Skills)
NameError: name 'Skills' is not defined
Run Code Online (Sandbox Code Playgroud)

python django django-userena

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

无法在pdo语句中连接sql

我目前有一个Get varible

$name = $_GET['user'];
Run Code Online (Sandbox Code Playgroud)

我试图将它添加到我的sql语句中,如下所示:

$sql = "SELECT * FROM uc_users WHERE user_name = ". $name;
Run Code Online (Sandbox Code Playgroud)

并运行

$result = $pdo -> query($sql);
Run Code Online (Sandbox Code Playgroud)

我收到一个无效的列名.但这没有意义,因为如果我手动提出这样的请求

$sql = "SELECT * FROM uc_users WHERE user_name = 'jeff'";
Run Code Online (Sandbox Code Playgroud)

我得到列数据,而不是当我将其作为get变量输入时.我究竟做错了什么.我对pdo比较新.

更新:现在我有以下内容:

$name = $_GET['user'];
Run Code Online (Sandbox Code Playgroud)

$sql = "SELECT * FROM uc_users WHERE user_name = :name";
    //run the query and save the data to the $bio variable
    $result = $pdo -> query($sql);
    $result->bindParam( ":name", $name, PDO::PARAM_STR );
    $result->execute();
Run Code Online (Sandbox Code Playgroud)

但我得到了

> SQLSTATE[42000]: Syntax error or access violation: …
Run Code Online (Sandbox Code Playgroud)

php mysql sql pdo

0
推荐指数
1
解决办法
1507
查看次数

c ++:函数不能重载

我遇到以下输出的编译时错误:

$ g++ -ggdb `pkg-config --cflags opencv` -o `basename main.cpp .cpp` main.cpp StringMethods/StringMethods.cpp `pkg-config --libs opencv` -std=c++0x
In file included from main.cpp:2:0:
VideoFile.hpp:32:10: error: ‘bool VideoFile::fileExists(const string&)’ cannot be overloaded
     bool fileExists(const std::string & path)
          ^
VideoFile.hpp:15:10: error: with ‘bool VideoFile::fileExists(const string&)’
     bool fileExists(const std::string & path);
Run Code Online (Sandbox Code Playgroud)

但是,我没有看到该错误是如何有意义的,因为我只有函数声明,我在编写定义时直接复制和粘贴.

class VideoFile
{
private:
    std::string filePath;
    bool fileExists(const std::string & path);

public:

    VideoFile(const std::string & path)
        :filePath(path)
    {
        filePath = StringMethods::trim(path);
        if (!fileExists(filePath))
            throw std::runtime_error("The file: " + filePath + " was …
Run Code Online (Sandbox Code Playgroud)

c++ c++11

0
推荐指数
2
解决办法
8617
查看次数

标签 统计

django ×2

python ×2

android ×1

c++ ×1

c++11 ×1

django-userena ×1

java ×1

mysql ×1

pdo ×1

php ×1

sql ×1