我正在研究一个用于学习目的的django项目.我已经创建了一个应用organization并安装了它.当我运行python manage.py makemigrations organization它工作正常显示更改.
Migrations for 'organization':
organization/migrations/0001_initial.py:
- Create model Organization
- Create model Principle
Run Code Online (Sandbox Code Playgroud)
但是当我运行python manage.py migrate organization它时,它不会迁移并且不会显示任何要应用的更改.
Operations to perform:
Apply all migrations: organization
Running migrations:
No migrations to apply.
Run Code Online (Sandbox Code Playgroud)
删除所有文件夹后我正在使用postgresql并尝试.但仍然行不通.它每次都表明同样的事情.怎么解决这个?drop owned by user_name;migrations
环境:
操作系统版本Ubuntu 16.04
Django版本1.10.3
PostgreSQL版本9.5.7
组织/ models.py
from django.db import models
from django.contrib.postgres.fields import JSONField
class Principle(models.Model):
name = models.CharField(max_length=256)
description = models.CharField(max_length=256)
contact_no = models.CharField(max_length=256)
status = models.BooleanField()
class Organization(models.Model):
name = …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个简单的Pig Latin代码.我想检查输入字符串的第一个字母是否是元音,如果是,则运行该特定代码.如何询问y是否等于其中一个值.
function pigLatin() {
var y = prompt("Enter a word:")
if (y.charAt(0) = a,e,i,o,u) {
var pigLatin = y + "ay";
document.getElementById("answer").innerHTML = "Answer is: " + pigLatin;
} else {
var wordLength = y.length + 1;
var pigLatin = y.substring(1, wordLength) + y.charAt(0) + "ay";
document.getElementById("answer").innerHTML = "Answer is: " + pigLatin;
}
}
Run Code Online (Sandbox Code Playgroud) 呈现页面时,如何将对象传递到模型表单中以预填充字段?我想做一些类似于Django UpdateView基于类的视图中的构建,但要基于函数的视图。
我想在 python 上使用图形 API,这样我就可以对帖子进行分析。到目前为止,我尝试导入库:
import facebook
Run Code Online (Sandbox Code Playgroud)
但我得到了错误
import facebook
File "C:\Users\matan\Desktop\Machine Learning Forex\facebook.py", line 11
pip install -e git+https://github.com/mobolic/facebook-sdk.git#egg=facebook-sdk
^
SyntaxError: invalid syntax
File "C:\Users\matan\Desktop\Machine Learning Forex\facebook.py", line 11
pip install -e git+https://github.com/mobolic/facebook-sdk.git#egg=facebook-sdk
^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)
我怎样才能导入这个库?
我正在使用MAC和python版本2.7.14
Collecting psycopg2
Could not fetch URL https://pypi.python.org/simple/psycopg2/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:661) - skipping
Could not find a version that satisfies the requirement psycopg2 (from versions: )
No matching distribution found for psycopg2
Run Code Online (Sandbox Code Playgroud) 关于如何显示员工的计算工资,我又遇到了一个问题.当我输入小时工资时,工资总额不会显示..
这是我到目前为止所做的......
WageCalcu.java
public class WageCalcu
{
private String employeeName;
private int hours;
private double rate, pay;
public void setEmployeeName ( String name )
{
employeeName = name;
}
public String getEmployeeName()
{
return employeeName;
}
public double calculatePay( int hours, double rate )
{
if ( hours > 40 )
{
int extraHours = hours - 40;
pay = ( 40 * rate ) + ( extraHours * rate );
}
else pay = hours * rate;
return pay; …Run Code Online (Sandbox Code Playgroud) 这是代码。当我尝试使用输入类型重置时,它不起作用。我试图将其删除到 div 之外,但仍然无法正常工作。
<div class="container-fluid">
<div class="row">
<div class="col s4"></div>
<div class="col s4">
<form class="form" action="<?=base_url()?>item/updatedata/<?=$this->uri->segment(3)?>" method="POST">
<div class="row">
<label>ITEM ID</label>
<input type="text" readonly="" value="<?=$items->item_id?>" class="validate">
<label>ITEM NAME</label>
<input type="text" value="<?=$items->item_name?>" name="item_name" class="validate">
<label>ITEM DESCRIPTION</label>
<input type="text" value="<?=$items->item_desc?>" name="item_desc" class="validate">
<label>ITEM PRICE</label>
<input type="text" value="<?=$items->item_price?>" name="item_price" class="validate">
<div class="col s6">
<button class="btn waves-effect waves-light " type="submit" value="SUBMIT">Submit
<i class="material-icons right">send</i>
</button>
</div>
<div class="col s6">
<input class="btn waves-effect waves-light red" type="reset" value="Reset">
</div>
</div>
</form>
</div>
<div class="col s4"></div>
</div> …Run Code Online (Sandbox Code Playgroud) 我刚刚开始学习 Django,它从一开始就阻止了我。正如您从图像中看到的,每当我尝试运行服务器时,都会出现 Errno 11001 。所以我用谷歌搜索它,似乎是代理问题,所以我尝试了我能找到的所有方法,但没有解决它。(环境变量、尝试不同的代理等..)
任何人都可以帮助我吗?
我写了以下代码:
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
template <class T> T Min(T a, T b)
{
cout<<"template function: ";
if(a<b)
return a;
return b;
}
char *Min(char *a, char *b)
{
cout<<"non-template function: ";
if(strcmp(a,b)==0)
return a;
return b;
}
int main()
{
char c[]="x",d[]="y";
cout<<Min('x','y')<<endl;
cout<<Min("x","y")<<endl;
cout<<Min(c,d)<<endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
template function: x
template function: y
non-template function: y
Run Code Online (Sandbox Code Playgroud)
第一个函数调用正常,它正在调用模板函数.但是,为什么第二个函数也调用模板函数,而它是一个字符串常量.不应该调用非模板函数???
另外为什么第二次函数调用的输出y不应该是x?使用字符串常量调用函数和char类型数组之间有什么区别,尽管两者都是字符串?
我只是一个初学者,所以我在做第一个项目时遇到了一些问题。我在视图中有代码:
def signup(request):
if request.method == 'POST':
form = SignupForm(request.POST)
if form.is_valid():
user = form.save(commit=False)
user.is_active = False
user.save()
current_site = get_current_site(request)
mail_subject = '?????????'
message = render_to_string('acc_active_email.html', {
'user': user,
'domain': current_site.domain,
'uid':urlsafe_base64_encode(force_bytes(user.pk)),
'token':account_activation_token.make_token(user),
})
print(message) # ????? ? ?????? ????? ????????? ?????????
to_email = form.cleaned_data.get('email')
email = EmailMessage(
mail_subject, message, to=[to_email]
)
email.send()
return HttpResponse('??????????, ??????????? ????? ??????????? ?????')
else:
form = SignupForm()
return render(request, 'signup.html', {'form': form})
def activate(request, uidb64, token):
try:
uid = force_text(urlsafe_base64_decode(uidb64))
user = …Run Code Online (Sandbox Code Playgroud) python ×6
django ×4
javascript ×2
postgresql ×2
c++ ×1
django-forms ×1
django-views ×1
function ×1
html ×1
if-statement ×1
java ×1
list ×1
pip ×1
psycopg2 ×1
templates ×1