我在 Django 3.1 上有一个现有项目,并将我的项目升级到 Django 3.2。我在我的项目中创建了一个名为支付的应用程序。但是当我进行迁移时。它犯了一个错误
AttributeError: 'TextField' object has no attribute 'db_collation'
from django.db import models
from django.conf import settings
from django.utils.translation import gettext_lazy as _
# Create your models here.
from simple_history.models import HistoricalRecords
class TransactionType(models.TextChoices):
CASH_IN = 'IN', _('Cash In')
CASH_OUT = 'OUT', _('Cash Out')
class TransactionMethod(models.TextChoices):
STUDENT_TR = 'STT', _('Student Transaction')
BANK_TR = 'BKT', _('Bank Transaction')
SCHOOL_TR = 'SLT', _('School Transaction')
Teacher_TR = 'TRT', _('Teacher Transaction')
DONATE_TR = 'DET', _('Donate Transaction')
class Payment(models.Model):
id = models.AutoField(primary_key=True) …Run Code Online (Sandbox Code Playgroud) 如果我在 sublime text 或 PyCharm 中运行 Flask,我收到此错误消息sublime issue ( My OS: Ubuntu 16.04) "socket.error: [Errno 98] Address already in use"。但是如果我在我的 Ubuntu终端上运行 Flask ,它正在运行。我知道该端口使用了另一项服务。然后我试图从 google/stackoverflow 解决这个问题。
# ps ax | grep 5000 // or # ps ax | grep name_of_service
# kill 3750 // or # killall name_of_service
Run Code Online (Sandbox Code Playgroud)
但什么都没有改变。只有当我尝试在 sublime 或 pycharm IDE 上运行时才发现这个问题。
我正在用Django开发应用程序。浏览选择链接时,我想生成pdf。所以我用weasyprint模块来转换我的pdf。我导入了weasyprint模块。但是,当我运行该应用程序时,发现了一些错误。这是views.py文件
def customersProfile(request, customer_id, sys_type):
sys_type=sys_type
area="profile"
site_credit = site_credit1
time_now=timezone.now()
customers=get_object_or_404(CustomerInfo, pk=customer_id)
html_string = render_to_string('shop/profile.html', {'customers': customers, 'todaydate': today_date,'site_name': 'Moon Telecom', 'time_now': time_now, 'site_credit': site_credit, 'area': area})
html = HTML(string=html_string)
result = html.write_pdf()
response = HttpResponse(content_type='application/pdf;')
response['Content-Disposition'] = 'inline; filename=list_people.pdf'
response['Content-Transfer-Encoding'] = 'binary'
with tempfile.NamedTemporaryFile(delete=True) as output:
output.write(result)
output.flush()
output = open(output.name, 'r')
response.write(output.read())
return response
Run Code Online (Sandbox Code Playgroud)
这是HTML文件。我想创建pdf这个html文件。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head> …Run Code Online (Sandbox Code Playgroud) 该函数接受两个字符串并返回 struct 或 nil,我在该函数内编写了一个 struct 仅供该函数使用。
\ntype OrgFundingsDetailsFCT struct {\n ID int `db:"id"`\n OrgProfileID int `db:"org_profile_id"`\n OrgID int `db:"org_id"`\n RefID string `db:"ref_id"`\n AmountUSD float64 `db:"amount_usd"`\n FundingDate string `db:"funding_date"`\n Status string `db:"status"`\n Round string `db:"round"`\n CreatedBy string `db:"created_by"`\n}\nRun Code Online (Sandbox Code Playgroud)\nfunc (s *Server) getCompareOrgFundingsByRefID(refID, status string) (*OrgFundingsDetailsFCT, error) {\n type orgFunding struct {\n RefID string `db:"ref_id"`\n Status string `db:"status"`\n }\n\n var orgFundingsDetailsFCT OrgFundingsDetailsFCT\n\n orgfunding := orgFunding{\n RefID: refID,\n Status: status,\n }\n\n const query = `SELECT id,\n org_profile_id,\n org_id,\n ref_id,\n amount_usd,\n funding_date,\n …Run Code Online (Sandbox Code Playgroud) python ×3
django ×2
comparison ×1
flask ×1
flask-login ×1
go ×1
null ×1
sockets ×1
sublimetext3 ×1
weasyprint ×1