dxdb=> \d dxtest_loadprofiletosale
Table "public.dxtest_loadprofiletosale"
Column | Type | Modifiers
-------------+----------+-----------------------------------------------------------------------
id | integer | not null default nextval('dxtest_loadprofiletosale_id_seq'::regclass)
TransDate | date |
IssueDate | date |
CustomerNum | smallint | not null
Indexes:
"dxtest_loadprofiletosale_pkey" PRIMARY KEY, btree (id)
dxdb=> INSERT INTO dxtest_loadprofiletosale(id, TransDate, IssueDate, CustomerNum) VALUES(1, '2015-03-04','2015-01-01',01);
ERROR: column "transdate" of relation "dxtest_loadprofiletosale" does not exist
LINE 1: INSERT INTO dxtest_loadprofiletosale(id, TransDate, IssueDat...
Run Code Online (Sandbox Code Playgroud)
对不起,我已经有了专栏"transdate",为什么它说不存在?
Installing collected packages: Django
Successfully installed Django-1.8
[root@manage ~]# PYTHON
-bash: PYTHON: command not found
[root@manage ~]# python
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "/usr/lib/python2.6/site-packages/django/utils/version.py", line 7, in <module>
from django.utils.lru_cache import lru_cache
File "/usr/lib/python2.6/site-packages/django/utils/lru_cache.py", line 28 …Run Code Online (Sandbox Code Playgroud) 我正在使用"Lightweight Django"这本书学习Django.我正在使用Django 1.8.但是,我无法运行此代码.这是错误消息:
工作树:
build.py
import os
import shutil
from django.conf import settings
from django.core.management import call_command
from django.core.management.base import BaseCommand
from django.core.urlresolvers import reverse
from django.test.client import Client
def get_pages():
for name in os.listdir(settings.SITE_PAGES_DIRECTORY):
if name.endswith('.html'):
yield name[:-5]
class Command(BaseCommand):
help = 'Build static site output.'
leave_locale_alone = True
def handle(self, *args, **options):
if os.path.exists(settings.SITE_OUTPUT_DIRECTORY):
shutil.rmtree(settings.SITE_OUTPUT_DIRECTORY)
os.mkdir(settings.SITE_OUTPUT_DIRECTORY)
os.makedirs(settings.STATIC_ROOT, exists_ok=True)
call_command('collectstatic', interactive=False, clear=True,verbosity=0)
client = Client()
for page in get_pages():
url = reverse('page', kwargs={'slug': page})
response = client.get(url)
if page …Run Code Online (Sandbox Code Playgroud) 每一个,我都要改变一些代码从python 3.*到2.7 ,,,但是,我只是不知道data = urllib.parse.urlencode(values)python 2.7中的代码是什么
python3.*
import urllib.parse
import urllib.request
def sendsms(phonenumber,textcontent):
url = 'http://urls?'
values = {'username' : 'hello',
'password' : 'world',
'dstaddr' : phonenumber ,
'smbody': textcontent
}
data = urllib.parse.urlencode(values)
data = data.encode('Big5')
req = urllib.request.Request(url, data)
with urllib.request.urlopen(req) as response:
the_page = response.read()
Run Code Online (Sandbox Code Playgroud)
python 2.7
from urlparse import urlparse
from urllib2 import urlopen
from urllib import urlencode
def sendsms(phonenumber,textcontent):
url = 'http://urls?'
values = {'username' : 'hello',
'password' : 'world',
'dstaddr' : phonenumber …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Django 1.8构建我的博客但是我不知道如何订购博客.看图像
我想在底部显示'最早',在顶部显示'最新'.这是我的
的index.html
{% extends 'layouts/base.html' %}
{% block title %}
Homepage - {{ block.super }}
{% endblock title %}
{% block content %}
<center>
{% for blog in blogs %}
<h2><a href="{% url 'blog_detail' slug=blog.slug %}">
{{ blog.name }}
</a></h2>
<p>{{ blog.description }}</p>
{% endfor %}
</center>
{% endblock content %}
Run Code Online (Sandbox Code Playgroud)
models.py
# -*- coding: utf-8 -*-
from django.db import models
from django.utils import timezone
class blog(models.Model):
name = models.CharField(max_length=255)
description = models.TextField()
slug = models.SlugField(unique=True)
date_time = …Run Code Online (Sandbox Code Playgroud) 每个人:我正在尝试使用 django 1.8,mysql db 练习将 Django 与旧数据库集成,但没有成功,谁能告诉我发生了什么?非常感谢!我的 旧数据库
模型.py
# -*- coding: utf-8 -*-
from django.db import models
from django.utils import timezone
class blog(models.Model):
name = models.CharField(max_length=255)
description = models.TextField()
slug = models.SlugField(unique=True)
date_time = models.DateTimeField(auto_now_add = True)
def __unicode__(self):
return self.name
def get_image_path(instance, filename):
return '/'.join(['blog_images', instance.bupimg.slug, filename])
class Upload(models.Model):
bupimg = models.ForeignKey(blog, related_name="uploads")
image = models.ImageField(upload_to=get_image_path)
Run Code Online (Sandbox Code Playgroud)
为什么我的 pidapp/models.py 显示的与旧数据库的 models.py 非常不同
pidapp/models.py
# This is an auto-generated Django model module.
# You'll have …Run Code Online (Sandbox Code Playgroud) 我正在尝试从数据库中搜索并列出两个日期之间的内容,但不知道该怎么做?这
模型.py
...
class ProductsTbl(models.Model):
created = models.DateTimeField(editable=False)
...
Run Code Online (Sandbox Code Playgroud)
视图.py
def search(request):
error = False
if 'q1' and 'q2'in request.GET:
q = request.GET['q1','q2']
if not q:
error = True
else:
books = ProductsTbl.objects.filter(created__range=q)
return render(request, 'search_results.html',
{'books': books, 'query': q})
return render(request, 'search_form.html', {'error': error})
Run Code Online (Sandbox Code Playgroud)
我在这里查找了stackoverflow但不明白该怎么做
我应该在 models.py 中再添加一个 DateTimeField 来帮助搜索吗?
实际上我可以在 python manage.py shell 中做到这一点,但我怎样才能让它在网络上工作?

我的
搜索表单.html
<form action="" method="get">
<table style="width:30%">
<tr>
<td><input type="text" class="datepicker" name="q1"> </td>
<td style="width:5%"> between </td>
<td><input type="text" class="datepicker" name="q2"></td>
<br> …Run Code Online (Sandbox Code Playgroud) django ×5
python ×4
centos6.5 ×1
django-views ×1
html ×1
insert ×1
mysql ×1
python-2.7 ×1
python-3.x ×1
urllib ×1
urllib2 ×1