我有一张桌子,看起来像:
class Tld(models.Model):
domainNm = models.CharField(validators=[ RegexValidator('^[0-9]^[a-z]','yourdomain.com only','Invalid Entry')], max_length=40)
dtCreated = models.DateField()
Run Code Online (Sandbox Code Playgroud)
对于domainNm - 我想验证任何看起来像这样的条目:
它必须遵循这样的方式:<domainname>.[com|biz|net]等等,并且是字母数字.
如何在django模型的模型级别上执行此操作?
谢谢
我正在尝试使用 django 假定的 PasswordResetForm 功能为我的 django 应用程序创建密码重置表单。
我在forms.py 中创建了一个表单
class UserForgotPasswordForm(PasswordResetForm):
email = forms.EmailField(required=True,max_length=254)
class Meta:
model = User
fields = ("email")
Run Code Online (Sandbox Code Playgroud)
我无法设置了view在views.py利用这种形式,我目前有:
def UserResetPassword(request):
form = UserForgotPasswordForm(None, request.POST)
if request.method == 'POST':
if form.is_valid():
email = request.POST.get('email', '')
user =
Run Code Online (Sandbox Code Playgroud)
我的网址.py
urlpatterns = patterns('',
(r'^ForgotPassword/$',UserResetPassword),
)
Run Code Online (Sandbox Code Playgroud)
我有点不知道如何进一步使用它,因为我发现的文档很少,而且通常不直接使用PasswordResetFormdjango 功能。
有人可以伸出援手吗?
谢谢你。
我已完成我之前的研究,但似乎无法找到如何正确配置nginx以接受子域.
我目前已为mydomain.com正确配置,但不是analytix.mydomain.com:
server {
listen 80;
server_name *.mydomain.com;
access_log /home/ubuntu/virtualenv/mydomain/error/access.log;
error_log /home/ubuntu/virtualenv/mydomain/error/error.log warn;
connection_pool_size 2048;
fastcgi_buffer_size 4K;
fastcgi_buffers 64 4k;
root /home/ubuntu/virtualenv/mydomain/homelaunch/;
location /static/ {
alias /home/ubuntu/virtualenv/mydomain/homelaunch/static/;
}
location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
}
Run Code Online (Sandbox Code Playgroud)
该server_name声明被接受<anythinghere>.mydomain.com,这是很好.
如果我访问analytix.mydomain.com它,它会抛出一个Http 500默认值,这很好,因为它从现有的应用程序抛出它mydomain.com
该域名已经传播到我正在尝试访问它的服务器上.
如何指定路径中的文件夹以容纳内容analytix.mydomain.com?我想我会要求更改nginx conf中的属性(如上所示)
我有一个控制器:landingpage.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class LandingPage extends CI_Controller {
public function index(){
$data = array(
'head' => $this->load->view('Landing_Header', '', true),
'guts' => $this->load->view('Landing_Guts', '', true),
'foot' => $this->load->view('Landing_Footer', '', true)
);
$this->load->view('index', $data);
}
public function validateInput(){
#load help libraries for use
$this->load->helper("form");
$this->load->helper("form_validation");
/////////////////////////////////////////////////////////////////
/////////////////////// New User Validation /////////////////////
/////////////////////// Format for Validation : ////////////////
////////// "field name","Error Value","validation method" ///////
$this->form_validation->set_rules('fullname','Your Name','required|min_length[2]|max_length[20]');
$this->form_validation->set_rules('email','Your Email','required|valid_email|is_unique[users.email]');
$this->form_validation->set_rules('emailConf','Email Confirm','required|matches[email]');
$this->form_validation->set_rules('password','Password','required|min_length[2]|max_length[20]');
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道如何实现SHA 512散列,就像我以前在程序上执行我的应用程序时一样,这次在CODEIGNITER中执行? …
提交的Html表格
<?php
////////////////////////////////////////////////////////////////////////////////////
###### Require Database ###### ////////////////////////
require_once('src/cfg/dbi.php');
////////////////////////////////////////////////////////////////////////////////////
###### Call Session Functions Include ###### ////////////////////////
require_once('src/cfg/sess_function.php'); ////////////////////////
###### Call function as contained in sess_function() ###### //
session_set_save_handler('_open','_close','_read','_write','_destroy','_clean'); //
###### Start session ###### ////////////////////////////////////////////////////////
session_start(); ///////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
#fullname, email, password
// Verify input was even provided
if (isset($_POST['fullname']) && isset($_POST['email']) && isset($_POST['password'])) {
// Clean Input
$userName = mysql_real_escape_string($_POST['fullname']);
$userEmailAddress = mysql_real_escape_string($_POST['email']);
$userPassword = mysql_real_escape_string($_POST['password']);
# hash cleaned pass...
$dynamSalt = mt_rand(20,9999);
$userPassword = hash('sha512',$dynamSalt.$userPassword);
# connect database, then …Run Code Online (Sandbox Code Playgroud) 我有一张桌子:
Person 列:
pID(PK)
FName
LName
plID(FK)
Run Code Online (Sandbox Code Playgroud)
另一张桌子Place:
plID(PK)
plCity
plState
plZip
Run Code Online (Sandbox Code Playgroud)
是不是更好,只是Person做了像:
pID(PK)
FName
LName
City
State
Zip
Run Code Online (Sandbox Code Playgroud)
例如:
John Doe New York, NY 00000
Jane Doe New York, NY 00000
Jim Doe New York, NY 00000
Run Code Online (Sandbox Code Playgroud) 我想要计算java中变量的值是否等于0.00,当前定义为大小数.
I have tried a variety of ways to do this including:
tempListPrice.getAmount() == 0.00;
tempListPrice.getAmount().equals(0.00);
public static final zeroed = 0.00
tempListPrice.getAmount().equals(zeroed);
Run Code Online (Sandbox Code Playgroud)
请记住,我已经做了相当多的谷歌搜索试图找到一种简单的方法来比较它.我如何比较它的值,tempListPrice看它是否等于0.00,之前定义为a big decimal datatype.
我该怎么做呢?(对不起,我是Java的新手).
谢谢
无论如何,我的代码点火器安装中的索引页(又名 homepage.php)工作正常。
问题在于使用子目录来存储其他页面,目前它的设置如下:

像加载主页一样http://localhost/VAw_CI/工作正常(加载 homepage.php),这是在 routes.php 中设置的:
$route['default_controller'] = "pages/homepage";
Run Code Online (Sandbox Code Playgroud)
在 config.php 中,我已经设置:
$config['base_url'] = 'http://localhost/VAw_CI';
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';
Run Code Online (Sandbox Code Playgroud)
我$config['index_page'] = '';在上面指定,因为我修改了位于以下位置的 .htaccess htdocs:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d …Run Code Online (Sandbox Code Playgroud) 我正在尝试做的事情:我正在尝试对运行此python脚本的目录进行递归 .tar文件备份.
我目前拥有的:
import os
import zipfile
import datetime
import tarfile
datetime = str( datetime.datetime.now() )
def zipdir(path, zip):
for root, dirs, files in os.walk(path):
for file in files:
zip.write(os.path.join(root, file))
backupdir = raw_input('Which directory should we backup to? \n')
if backupdir :
try:
zipf = zipfile.ZipFile('DrupalInstanceBackup'+datetime+'.zip', mode='w')
zipdir('/Users/localuser/Downloads/backup', zipf)
except Exception as e:
print e
finally:
zipf.close()
Run Code Online (Sandbox Code Playgroud)
它目前的作用: 它进行.zip备份,但在解压缩时它不会显示任何文件.
我想做什么:
有人可以帮助我以递归方式备份目录并.tar以递归方式创建目录及其文件的存档吗?
谢谢
我有一个功能:
def path_clone( source_dir_prompt, destination_dir_prompt) :
try:
shutil.copytree(source_dir_prompt, destination_dir_prompt)
print("Potentially copied?")
except OSError as e:
# If the error was caused because the source wasn't a directory
if e.errno == errno.ENOTDIR:
shutil.copy(source_dir_prompt, destination_dir_prompt)
else:
print('Directory not copied. Error: %s' % e)
Run Code Online (Sandbox Code Playgroud)
为什么失败并输出:
Directory not copied. Error: [Errno 17] File exists: '[2]'
Run Code Online (Sandbox Code Playgroud)
我的source目录与文件/目录一起存在。我的destination 文件夹存在,但是当我运行它时,没有文件被复制,并且命中了我的else声明。
我还尝试在两个文件夹上设置权限chmod 777以避免unix权限错误,但这也不能解决问题。
任何帮助是极大的赞赏。谢谢。