问题列表 - 第22574页

创建一个使用两个<input>的自定义Django表单字段

如何创建一个将自身呈现为一对输入字段的Django字段?

推理:我正在尝试编写一个新的自定义字段.我将它用于类似验证码的服务.该服务通过请求问题 - 然后接收一个和一个令牌来工作.通过发送 答案令牌来进行验证.我想写一个封装这个逻辑的表单字段.元素应该渲染(IMO)

<input type="hidden" name="_token" value="1234567890" />
<input type="text" name="answer" />
Run Code Online (Sandbox Code Playgroud)

在提交时,我需要价值_tokenanswer验证答案.

python django django-forms

5
推荐指数
2
解决办法
5362
查看次数

从通知中恢复活动

我的应用状态栏中有通知:

    Notification notification = new Notification(R.drawable.icon, null, System.currentTimeMillis());

    Intent notificationIntent = new Intent(this.parent, MainActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this.parent, 0, notificationIntent, 0);

    ...

    notification.flags = Notification.FLAG_ONGOING_EVENT;        
    mNotificationManager.notify(NOTIFICATION_ID, notification);
Run Code Online (Sandbox Code Playgroud)

这个问题是当你从应用程序按下主页按钮(将其推到后台),然后按下从状态栏访问的列表中的通知,它会启动活动的新副本.我想要做的就是恢复应用程序(比如当你长按主页按钮并按下应用程序的图标时).有没有办法创建一个Intent来做到这一点?

java notifications android android-activity

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

使用PHPMailer处理错误

我正在尝试将PHPMailer用于一个小项目,但我对使用该软件进行错误处理感到困惑.希望有人有经验.当我设置电子邮件时,我使用:

$result = $mail->Send();

if(!$result) {
    // There was an error
    // Do some error handling things here
} else {
    echo "Email successful";
}
Run Code Online (Sandbox Code Playgroud)

哪个工作正常,或多或少.问题是当出现错误时,PHPMailer似乎也将错误消除了,所以如果出现问题,它只是将该信息直接发送到浏览器,基本上打破了我试图做的任何错误处理.

有没有办法让这些消息沉默?它没有抛出异常,只是打印出错误,在我的测试用例中是:

invalid address: @invalid@email You must provide at least one recipient email address.
Run Code Online (Sandbox Code Playgroud)

它意味着是一个错误,但它应该驻留在$ mail-> ErrorInfo; 没有被软件回应.

php phpmailer

43
推荐指数
5
解决办法
17万
查看次数

MySQL:在大表中添加一个字段

我有一张约200,000条记录的表格.我想为它添加一个字段:

 ALTER TABLE `table` ADD `param_21` BOOL NOT NULL COMMENT 'about the field' AFTER `param_20`
Run Code Online (Sandbox Code Playgroud)

但它似乎是一个非常繁重的查询,它需要很长时间,即使在我的Quad amd PC上有4GB的RAM.

我在windows/xampp和phpMyAdmin下运行.在添加字段时,mysql是否与每条记录都有业务往来?或者我可以更改查询,以便更快地进行更改吗?

mysql performance

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

此适配器需要PDO扩展,但未加载扩展

当我尝试使用Zend_Db_Table_Abstract类的fetchall方法时,我收到以下异常...

An error occurred4545
EXCEPTION_OTHER
Exception information:
Message: The PDO extension is required for this adapter but the extension is not loaded 

Stack trace:
#0 D:\www\TestProject\library\Zend\Db\Adapter\Pdo\Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect()
#1 D:\www\TestProject\library\Zend\Db\Adapter\Abstract.php(448): Zend_Db_Adapter_Pdo_Mysql->_connect()
#2 D:\www\TestProject\library\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('DESCRIBE `album...', Array)
#3 D:\www\TestProject\library\Zend\Db\Adapter\Pdo\Mysql.php(156): Zend_Db_Adapter_Pdo_Abstract->query('DESCRIBE `album...')
#4 D:\www\TestProject\library\Zend\Db\Table\Abstract.php(823): Zend_Db_Adapter_Pdo_Mysql->describeTable('albums', NULL)
#5 D:\www\TestProject\library\Zend\Db\Table\Abstract.php(862): Zend_Db_Table_Abstract->_setupMetadata()
#6 D:\www\TestProject\library\Zend\Db\Table\Abstract.php(969): Zend_Db_Table_Abstract->_setupPrimaryKey()
#7 D:\www\TestProject\library\Zend\Db\Table\Select.php(100): Zend_Db_Table_Abstract->info()
#8 D:\www\TestProject\library\Zend\Db\Table\Select.php(78): Zend_Db_Table_Select->setTable(Object(Application_Model_Albums))
#9 D:\www\TestProject\library\Zend\Db\Table\Abstract.php(1005): Zend_Db_Table_Select->__construct(Object(Application_Model_Albums))
#10 D:\www\TestProject\library\Zend\Db\Table\Abstract.php(1303): Zend_Db_Table_Abstract->select()
#11 D:\www\TestProject\application\controllers\IndexController.php(17): Zend_Db_Table_Abstract->fetchAll()
#12 D:\www\TestProject\library\Zend\Controller\Action.php(513): IndexController->indexAction()
#13 D:\www\TestProject\library\Zend\Controller\Dispatcher\Standard.php(289): Zend_Controller_Action->dispatch('indexAction')
#14 D:\www\TestProject\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#15 D:\www\TestProject\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#16 D:\www\TestProject\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() …
Run Code Online (Sandbox Code Playgroud)

php zend-framework apache2.2

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

如何在Android ListView的末尾显示一个按钮

我想在Android列表视图的末尾显示一个按钮.我怎样才能做到这一点?

我不想坚持使用alignparentbottom="true".使用layout_below对我也不起作用.

我目前的XML:

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/main_bg">

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <ListView
            android:id="@+id/android:list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:drawSelectorOnTop="false"
            android:cacheColorHint="#ff6a00"
            android:divider="#ff8f40"
            android:dividerHeight="1px" />

    </LinearLayout>

    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
            android:layout_height="50sp"
        android:background="#676767"
        android:orientation="vertical">

        <Button
            android:layout_width="100px"
            android:layout_height="wrap_content"
            android:id="@+id/btnGetMoreResults"
            android:layout_marginLeft="10px"
            android:text="Get more" />

    </RelativeLayout>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

android listview

41
推荐指数
5
解决办法
6万
查看次数

没有JavaScript的Ajax

由于用户可以在浏览器中禁用JavaScript,我想知道是否有任何方法可以开发使用Ajax但不使用Javascript的应用程序,因此即使Javascript被禁用,它也会继续工作.有没有限制?

javascript ajax

14
推荐指数
6
解决办法
8118
查看次数

获取两个字段值的唯一组合

可能以前有人问过,但我找不到答案。

表数据有两列:

Source   Dest
1         2
1         2
2         1
3         1
Run Code Online (Sandbox Code Playgroud)

我试图提出一个 MS Access 2003 SQL 查询,它将返回:

1       2
3       1
Run Code Online (Sandbox Code Playgroud)

但一切都无济于事。请帮忙!

更新:确切地说,我试图排除 2,1,因为 1,2 已经包含在内。我只需要独特的组合,其中顺序并不重要。

sql ms-access

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

如何确保XML模式中的唯一元素值?

我想确保以下xml中没有重复的书名:

<?xml version="1.0" encoding="UTF-8"?>
<books xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="books3.xsd">
    <book>
        <title>Book1</title>
    </book>
    <book>
        <title>Book2</title>
    </book>
    <book>
        <title>Book1</title>  <!-- duplicate should not be allowed -->
    </book> 
</books>
Run Code Online (Sandbox Code Playgroud)

我使用以下架构:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:element name="books">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="book"/>
      </xs:sequence>
    </xs:complexType>
    <xs:unique name="testUnique">
      <xs:selector xpath="book"/>
      <xs:field xpath="title"/>
    </xs:unique>
  </xs:element>
  <xs:element name="book">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="title"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="title" type="xs:NCName"/>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)

oXygen XML编辑器告诉我,当我验证时这是有效的.

谁能看到我做错了什么?

xml schema xsd oxygenxml

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

自然语言处理包

我已经开始研究一个需要自然语言处理的项目.我们已经进行了拼写检查以及将句子映射到短语及其同义词.我首先想到使用GATE,但我对使用什么感到困惑?我发现这里有一篇有趣的帖子让我更加困惑.

http://lordpimpington.com/codespeaks/drupal-5.1/?q=node/5

请帮我决定最适合我的目的.我正在使用这个NLP工具作为服务的Web应用程序.

nlp stanford-nlp

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