# switch to postgres account(venv)pi@raspberrypi:~/app/DjangoApps$ sudo su - postgres# create postgres userpostgres@raspberrypi:~$ createuser pi# create databasepostgres@raspberrypi:~$ createdb myproject# sql environmentpostgres@raspberrypi:~$ psql# add password for userpostgres=# ALTER USER pi...
(2). 把 django 项目整个传到树莓派上,项目根目录(manage.py 同级目录)下的全部文件全部复制到树莓派项目目录,复制之后,情况大概是这样: (venv) pi@raspberrypi:~/www/demo $ ls demo guestbook manage.py requirements.txt venv (3). 安装扩展库,记住在激活的环境下执行,命令行如下: pip3 install -r requ...
安装成功之后我们可以进入python命令行查看django版本: pi@raspberrypi:~ $ python importdjangoprint(django.VERSION) 安装过程中如果因为下载太慢失败的话,可以更改pip源为国内阿里源,具体内容见我前边写的树莓派初始设置。 安装过程中遇到报错: ERROR: Command erroredoutwithexit status1: python setup.py egg_info...
安装成功之后我们可以进入python命令行查看django版本: pi@raspberrypi:~ $ python 1. import django print(django.VERSION) 1. 2. 安装过程中如果因为下载太慢失败的话,可以更改pip源为国内阿里源,具体内容见我前边写的树莓派初始设置。 安装过程中遇到报错: ERROR: Command errored out with exit status 1: py...
pi@raspberrypi:~$ pythonPython3.9.2(default,Feb282021,17:03:44)[GCC10.2.120210110]on linuxType"help","copyright","credits"or"license"formore information.>>>import django>>>django.VERSION(4,1,4,'final',0)>>>exit()pi@raspberrypi:~$ ...
pi@raspberrypi ~/python_test$ python Python 2.7.3 (default, Mar 18 2014, 05:13:23) [GCC 4.6.3] on linux2 Type"help","copyright","credits"or"license"formoreinformation. >>>importdjango >>> print(django.VERSION) (1, 6, 5,'final', 0) ...
pi@raspberrypi ~/django_site/django_site $ vim views.py -- coding: utf-8 -- from django.http import HttpResponse def first_page(request): return HttpResponse("Hello World") 第一行说明字符编码为utf-8,为下面使用中文做准备。first_page函数的功能,是返回http回复,即这里的Hello World 。first...
pi@raspberrypi:~/DjangoProject/recruitment $ python3 manage.py makemigrationsNochanges detected#由于初始建项目,还没添加Model所以有这个消息 迁移Model到数据库 pi@raspberrypi:~/DjangoProject/recruitment $ python3 manage.py migrateOperationsto perform:Applyall migrations:admin,auth,contenttypes,sessionsRunning...
pi@raspberrypi:~ $ sudo pip install django Collecting django Exception: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", li...
pi@raspberrypi:~$ sudo pip install django Collecting djangoException:Traceback(most recent call last):File"/usr/lib/python2.7/dist-packages/pip/basecommand.py",line215,inmain status=self.run(options,args)File"/usr/lib/python2.7/dist-packages/pip/commands/install.py",line353,inrun ...