Wiki

Version 69 (Etienne Pallier, 03/18/2016 12:28 pm)

1 1 Etienne Pallier
h1. Technical Documentation for the PYROS project (FGFT-CC)
2 1 Etienne Pallier
3 1 Etienne Pallier
4 1 Etienne Pallier
HOWTO Format Redmine Wiki : http://www.redmine.org/projects/redmine/wiki/FrRedmineWikiFormatting
5 1 Etienne Pallier
6 1 Etienne Pallier
{{>toc}}
7 1 Etienne Pallier
8 1 Etienne Pallier
9 1 Etienne Pallier
10 3 Etienne Pallier
---
11 1 Etienne Pallier
12 57 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}TODO%
13 57 Etienne Pallier
14 58 Etienne Pallier
ajouter lien vers pyros.sql
15 57 Etienne Pallier
16 57 Etienne Pallier
---
17 57 Etienne Pallier
18 17 Etienne Pallier
h2. %{margin-left:0px; font-weight:bold; font-size:25px;  display:block; color:red;}I - INSTALLATION%
19 2 Etienne Pallier
20 51 Etienne Pallier
h3. If necessary, install MySql
21 2 Etienne Pallier
22 49 Etienne Pallier
 * Linux Ubuntu
23 49 Etienne Pallier
<pre>
24 49 Etienne Pallier
TODO:
25 49 Etienne Pallier
$ sudo apt-get install mysql
26 49 Etienne Pallier
...
27 49 Etienne Pallier
</pre>
28 49 Etienne Pallier
29 49 Etienne Pallier
 * Linux CentOS
30 49 Etienne Pallier
<pre>
31 49 Etienne Pallier
TODO:
32 49 Etienne Pallier
$ sudo yum install mysql
33 49 Etienne Pallier
...
34 49 Etienne Pallier
</pre>
35 49 Etienne Pallier
36 49 Etienne Pallier
 * Mac OS X
37 49 Etienne Pallier
<pre>
38 49 Etienne Pallier
TODO:
39 49 Etienne Pallier
Install XAMPP
40 49 Etienne Pallier
(but you could also use the pre-installed Mac OS MySql)
41 49 Etienne Pallier
</pre>
42 49 Etienne Pallier
43 49 Etienne Pallier
 * Windows
44 49 Etienne Pallier
<pre>
45 49 Etienne Pallier
TODO:
46 49 Etienne Pallier
</pre>
47 49 Etienne Pallier
48 49 Etienne Pallier
49 49 Etienne Pallier
---
50 1 Etienne Pallier
51 6 Etienne Pallier
h3. Create database
52 1 Etienne Pallier
53 52 Etienne Pallier
54 52 Etienne Pallier
 * Linux and Mac OS X:
55 52 Etienne Pallier
<pre>
56 3 Etienne Pallier
One liner:
57 3 Etienne Pallier
$ mysql -u root < pyros.sql
58 1 Etienne Pallier
59 3 Etienne Pallier
Or :
60 3 Etienne Pallier
$ mysql -u root
61 3 Etienne Pallier
mysql> create database pyros;
62 3 Etienne Pallier
mysql> use pyros;
63 3 Etienne Pallier
mysql> source pyros.sql;
64 1 Etienne Pallier
65 3 Etienne Pallier
(
66 3 Etienne Pallier
TODO:
67 3 Etienne Pallier
mysql> grant all on pyros.* to pyros@localhost identified by ‘pyros’;)
68 3 Etienne Pallier
mysql> flush privileges;
69 3 Etienne Pallier
)
70 52 Etienne Pallier
</pre>
71 1 Etienne Pallier
72 53 Etienne Pallier
73 53 Etienne Pallier
 * Windows:
74 52 Etienne Pallier
<pre>
75 52 Etienne Pallier
TODO: Use phpmyadmin ?
76 52 Etienne Pallier
</pre>
77 1 Etienne Pallier
78 1 Etienne Pallier
79 4 Etienne Pallier
---
80 5 Etienne Pallier
81 6 Etienne Pallier
h3. Install python3.5
82 1 Etienne Pallier
83 11 Etienne Pallier
84 11 Etienne Pallier
 * Mac OS X :
85 23 Etienne Pallier
<pre>
86 24 Etienne Pallier
1) Installer MacPort
87 24 Etienne Pallier
(TODO: doc)
88 24 Etienne Pallier
89 24 Etienne Pallier
2) Installer le "port" python35
90 1 Etienne Pallier
$ sudo port install python35
91 23 Etienne Pallier
</pre>
92 1 Etienne Pallier
93 11 Etienne Pallier
 * Linux (Ubuntu) :
94 23 Etienne Pallier
<pre>
95 1 Etienne Pallier
$ sudo apt-get ...
96 23 Etienne Pallier
</pre>
97 1 Etienne Pallier
98 5 Etienne Pallier
99 3 Etienne Pallier
100 4 Etienne Pallier
---
101 5 Etienne Pallier
102 13 Etienne Pallier
h3. Create project dir
103 13 Etienne Pallier
104 68 Etienne Pallier
<pre>
105 13 Etienne Pallier
$ mkdir pyros
106 68 Etienne Pallier
</pre>
107 13 Etienne Pallier
108 13 Etienne Pallier
---
109 59 Etienne Pallier
110 59 Etienne Pallier
h3. Get the project (from git)
111 59 Etienne Pallier
112 59 Etienne Pallier
TODO:
113 59 Etienne Pallier
114 59 Etienne Pallier
115 59 Etienne Pallier
---
116 59 Etienne Pallier
117 60 Etienne Pallier
h3. Create virtualenv with python3.5 dedicated to pyros project (inside the project folder)
118 3 Etienne Pallier
119 3 Etienne Pallier
$ cd pyros/
120 3 Etienne Pallier
121 3 Etienne Pallier
$ which python3.5
122 3 Etienne Pallier
/opt/local/bin/python3.5
123 3 Etienne Pallier
124 15 Etienne Pallier
$ virtualenv-3.5 venv_py35_pyros -p /opt/local/bin/python3.5
125 3 Etienne Pallier
=> creates a venv_py35_pyros/ folder inside pyros/
126 3 Etienne Pallier
127 1 Etienne Pallier
128 1 Etienne Pallier
129 7 Etienne Pallier
---
130 3 Etienne Pallier
131 65 Etienne Pallier
h3. Activate the python virtual environment (from inside the project)
132 7 Etienne Pallier
133 55 Etienne Pallier
<pre>
134 1 Etienne Pallier
135 65 Etienne Pallier
$ pwd
136 65 Etienne Pallier
.../pyros
137 1 Etienne Pallier
138 65 Etienne Pallier
$ source ./venv_py35_pyros/bin/activate
139 65 Etienne Pallier
140 3 Etienne Pallier
$ python -V
141 1 Etienne Pallier
Python 3.5.1
142 3 Etienne Pallier
143 3 Etienne Pallier
$ which pip
144 65 Etienne Pallier
.../pyros/venv_py35_pyros/bin/pip
145 16 Etienne Pallier
146 18 Etienne Pallier
Upgrade pip to last version available :
147 3 Etienne Pallier
$ pip install --upgrade pip
148 3 Etienne Pallier
Collecting pip
149 3 Etienne Pallier
  Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB)
150 3 Etienne Pallier
Installing collected packages: pip
151 3 Etienne Pallier
  Found existing installation: pip 7.1.2
152 3 Etienne Pallier
    Uninstalling pip-7.1.2:
153 3 Etienne Pallier
      Successfully uninstalled pip-7.1.2
154 1 Etienne Pallier
Successfully installed pip-8.1.1
155 55 Etienne Pallier
156 55 Etienne Pallier
</pre>
157 18 Etienne Pallier
158 27 Etienne Pallier
h3. Install needed python packages (from within the virtual environment)
159 18 Etienne Pallier
160 66 Etienne Pallier
First, be sure that the virtual environment is activated:
161 66 Etienne Pallier
<pre>
162 66 Etienne Pallier
$ python -V
163 66 Etienne Pallier
Python 3.5.1
164 66 Etienne Pallier
</pre>
165 66 Etienne Pallier
166 62 Etienne Pallier
 * *Automatic Installation of all packages*
167 1 Etienne Pallier
168 62 Etienne Pallier
TODO:
169 62 Etienne Pallier
<pre>
170 62 Etienne Pallier
$ pip install -r requirements.txt
171 62 Etienne Pallier
</pre>
172 62 Etienne Pallier
173 62 Etienne Pallier
 * *Manual installation of each package*
174 62 Etienne Pallier
175 62 Etienne Pallier
  * *Install Django* :
176 32 Etienne Pallier
<pre>
177 3 Etienne Pallier
$ pip install django
178 3 Etienne Pallier
Collecting django
179 3 Etienne Pallier
  Downloading Django-1.9.4-py2.py3-none-any.whl (6.6MB)
180 3 Etienne Pallier
Installing collected packages: django
181 3 Etienne Pallier
Successfully installed django-1.9.4
182 3 Etienne Pallier
183 3 Etienne Pallier
$ pip install django-admin-tools
184 3 Etienne Pallier
Collecting django-admin-tools
185 3 Etienne Pallier
  Downloading django_admin_tools-0.7.2-py2.py3-none-any.whl (289kB)
186 3 Etienne Pallier
Installing collected packages: django-admin-tools
187 3 Etienne Pallier
Successfully installed django-admin-tools-0.7.2
188 3 Etienne Pallier
189 21 Etienne Pallier
$ pip install django-debug-toolbar
190 21 Etienne Pallier
Collecting django-debug-toolbar
191 21 Etienne Pallier
  Downloading django_debug_toolbar-1.4-py2.py3-none-any.whl (212kB)
192 21 Etienne Pallier
Requirement already satisfied (use --upgrade to upgrade): Django>=1.7 in ./venv_py35_pyros/lib/python3.5/site-packages (from django-debug-toolbar)
193 21 Etienne Pallier
Collecting sqlparse (from django-debug-toolbar)
194 21 Etienne Pallier
  Downloading sqlparse-0.1.19.tar.gz (58kB)
195 21 Etienne Pallier
Building wheels for collected packages: sqlparse
196 21 Etienne Pallier
  Running setup.py bdist_wheel for sqlparse ... done
197 21 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/7b/d4/72/6011bb100dd5fc213164e4bbee13d4e03261dd54ce6a5de6b8
198 21 Etienne Pallier
Successfully built sqlparse
199 21 Etienne Pallier
Installing collected packages: sqlparse, django-debug-toolbar
200 21 Etienne Pallier
Successfully installed django-debug-toolbar-1.4 sqlparse-0.1.19
201 21 Etienne Pallier
202 21 Etienne Pallier
$ pip install django-extensions
203 21 Etienne Pallier
Collecting django-extensions
204 21 Etienne Pallier
  Downloading django_extensions-1.6.1-py2.py3-none-any.whl (202kB)
205 21 Etienne Pallier
Collecting six>=1.2 (from django-extensions)
206 21 Etienne Pallier
  Downloading six-1.10.0-py2.py3-none-any.whl
207 21 Etienne Pallier
Installing collected packages: six, django-extensions
208 21 Etienne Pallier
Successfully installed django-extensions-1.6.1 six-1.10.0
209 21 Etienne Pallier
210 21 Etienne Pallier
$ pip install django-suit
211 21 Etienne Pallier
Collecting django-suit
212 21 Etienne Pallier
  Downloading django-suit-0.2.18.tar.gz (587kB)
213 21 Etienne Pallier
Building wheels for collected packages: django-suit
214 1 Etienne Pallier
  Running setup.py bdist_wheel for django-suit ... done
215 1 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/12/8b/9a/e02ab0ad9229881638aa040d47d77c8f562999533811927d41
216 1 Etienne Pallier
Successfully built django-suit
217 1 Etienne Pallier
Installing collected packages: django-suit
218 1 Etienne Pallier
Successfully installed django-suit-0.2.18
219 21 Etienne Pallier
220 32 Etienne Pallier
</pre>
221 32 Etienne Pallier
222 63 Etienne Pallier
  * *Install the web application server gunicorn (will be used in production instead of the dev django web server)* :
223 32 Etienne Pallier
<pre>
224 25 Etienne Pallier
$ pip install gunicorn
225 25 Etienne Pallier
Collecting gunicorn
226 25 Etienne Pallier
  Downloading gunicorn-19.4.5-py2.py3-none-any.whl (112kB)
227 21 Etienne Pallier
Installing collected packages: gunicorn
228 26 Etienne Pallier
Successfully installed gunicorn-19.4.5
229 1 Etienne Pallier
</pre>
230 1 Etienne Pallier
231 63 Etienne Pallier
  * *Install the python mysql client*:
232 32 Etienne Pallier
<pre>
233 32 Etienne Pallier
$ pip install mysqlclient
234 32 Etienne Pallier
...
235 32 Etienne Pallier
</pre>
236 20 Etienne Pallier
237 33 Etienne Pallier
=> Issue under Mac OS X:
238 21 Etienne Pallier
<pre>
239 69 Etienne Pallier
$ pip install mysqlclient
240 3 Etienne Pallier
Collecting mysqlclient
241 3 Etienne Pallier
  Downloading mysqlclient-1.3.7.tar.gz (79kB)
242 1 Etienne Pallier
Building wheels for collected packages: mysqlclient
243 22 Etienne Pallier
  Running setup.py bdist_wheel for mysqlclient ... error
244 3 Etienne Pallier
245 3 Etienne Pallier
  ----------------------------------------
246 1 Etienne Pallier
  Failed building wheel for mysqlclient
247 1 Etienne Pallier
  Running setup.py clean for mysqlclient
248 1 Etienne Pallier
Failed to build mysqlclient
249 1 Etienne Pallier
Installing collected packages: mysqlclient
250 1 Etienne Pallier
  Running setup.py install for mysqlclient ... done
251 1 Etienne Pallier
Successfully installed mysqlclient-1.3.7
252 1 Etienne Pallier
253 1 Etienne Pallier
BOUH !!!
254 1 Etienne Pallier
255 1 Etienne Pallier
$ pip install --upgrade wheel
256 1 Etienne Pallier
Collecting wheel
257 1 Etienne Pallier
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
258 1 Etienne Pallier
Installing collected packages: wheel
259 1 Etienne Pallier
  Found existing installation: wheel 0.24.0
260 1 Etienne Pallier
    Uninstalling wheel-0.24.0:
261 1 Etienne Pallier
      Successfully uninstalled wheel-0.24.0
262 1 Etienne Pallier
Successfully installed wheel-0.29.0
263 1 Etienne Pallier
264 1 Etienne Pallier
$ pip uninstall mysqlclient
265 1 Etienne Pallier
266 1 Etienne Pallier
$ pip install mysqlclient
267 1 Etienne Pallier
Collecting mysqlclient
268 1 Etienne Pallier
  Using cached mysqlclient-1.3.7.tar.gz
269 1 Etienne Pallier
Building wheels for collected packages: mysqlclient
270 1 Etienne Pallier
  Running setup.py bdist_wheel for mysqlclient ... done
271 1 Etienne Pallier
  Stored in directory: /Users/epallier/Library/Caches/pip/wheels/9b/06/50/d11418c26cf8f2156b13d4363b5afde8e7e75ebb8540d0228d
272 1 Etienne Pallier
Successfully built mysqlclient
273 1 Etienne Pallier
Installing collected packages: mysqlclient
274 1 Etienne Pallier
Successfully installed mysqlclient-1.3.7
275 1 Etienne Pallier
276 1 Etienne Pallier
YES !!!
277 21 Etienne Pallier
</pre>
278 1 Etienne Pallier
279 1 Etienne Pallier
280 12 Etienne Pallier
281 12 Etienne Pallier
282 12 Etienne Pallier
---
283 12 Etienne Pallier
284 28 Etienne Pallier
h3. Project organization
285 12 Etienne Pallier
 
286 29 Etienne Pallier
Example of a good organization :
287 1 Etienne Pallier
288 29 Etienne Pallier
1 project = N applis
289 29 Etienne Pallier
(but 1 appli can be part of many projects)
290 30 Etienne Pallier
(then 1 appli = N models)
291 12 Etienne Pallier
292 31 Etienne Pallier
<pre>
293 34 Etienne Pallier
294 29 Etienne Pallier
MYPROJECT/
295 34 Etienne Pallier
296 50 Etienne Pallier
297 1 Etienne Pallier
	src/
298 1 Etienne Pallier
		myproject/
299 34 Etienne Pallier
		appli1/
300 34 Etienne Pallier
		appli2/
301 12 Etienne Pallier
302 34 Etienne Pallier
		appliN/
303 34 Etienne Pallier
304 12 Etienne Pallier
	public/
305 34 Etienne Pallier
		static/
306 34 Etienne Pallier
307 12 Etienne Pallier
	private/
308 1 Etienne Pallier
		requirements.txt
309 50 Etienne Pallier
310 50 Etienne Pallier
	venv_py35_pyros/
311 50 Etienne Pallier
312 1 Etienne Pallier
</pre>
313 1 Etienne Pallier
314 1 Etienne Pallier
315 37 Etienne Pallier
Set needed folders:
316 37 Etienne Pallier
<pre>
317 37 Etienne Pallier
$ cd pyros/
318 12 Etienne Pallier
$ mkdir private public
319 12 Etienne Pallier
$ mkdir public/static
320 37 Etienne Pallier
</pre>
321 3 Etienne Pallier
322 7 Etienne Pallier
---
323 3 Etienne Pallier
324 39 Etienne Pallier
h3. Create Django project pyros
325 7 Etienne Pallier
326 38 Etienne Pallier
<pre>
327 38 Etienne Pallier
$ cd pyros/
328 38 Etienne Pallier
329 3 Etienne Pallier
$ django-admin startproject pyros
330 3 Etienne Pallier
331 3 Etienne Pallier
$ tree pyros/
332 3 Etienne Pallier
pyros/
333 3 Etienne Pallier
├── manage.py
334 3 Etienne Pallier
└── pyros
335 3 Etienne Pallier
    ├── __init__.py
336 3 Etienne Pallier
    ├── settings.py
337 3 Etienne Pallier
    ├── urls.py
338 3 Etienne Pallier
    └── wsgi.py
339 3 Etienne Pallier
340 3 Etienne Pallier
$ mv pyros src
341 3 Etienne Pallier
342 3 Etienne Pallier
$ cd src/
343 3 Etienne Pallier
344 3 Etienne Pallier
$ ./manage.py runserver
345 40 Etienne Pallier
(or gunicorn pyros.wsgi)
346 1 Etienne Pallier
==> http://localhost:8000
347 38 Etienne Pallier
</pre>
348 3 Etienne Pallier
349 3 Etienne Pallier
350 7 Etienne Pallier
---
351 3 Etienne Pallier
352 42 Etienne Pallier
h3. Set Database engine as MySql
353 7 Etienne Pallier
354 3 Etienne Pallier
Edit src/pyros/settings.py
355 3 Etienne Pallier
356 41 Etienne Pallier
<pre>
357 3 Etienne Pallier
DATABASES = {
358 3 Etienne Pallier
    'default': {
359 3 Etienne Pallier
        'ENGINE': 'django.db.backends.mysql',
360 1 Etienne Pallier
        'NAME': 'pyros',
361 3 Etienne Pallier
        'USER': 'root',
362 1 Etienne Pallier
        'PASSWORD': ''
363 1 Etienne Pallier
    }
364 1 Etienne Pallier
}
365 41 Etienne Pallier
</pre>
366 3 Etienne Pallier
367 7 Etienne Pallier
---
368 3 Etienne Pallier
369 43 Etienne Pallier
h3. Import database into Django (with inspectdb)
370 7 Etienne Pallier
371 43 Etienne Pallier
$ cd src/
372 3 Etienne Pallier
373 3 Etienne Pallier
$ ./manage.py inspectdb > models.py
374 3 Etienne Pallier
375 44 Etienne Pallier
*Issue on Mac OS X*:
376 44 Etienne Pallier
<pre>
377 3 Etienne Pallier
Traceback (most recent call last):
378 3 Etienne Pallier
  File "/Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 25, in <module>
379 3 Etienne Pallier
    import MySQLdb as Database
380 3 Etienne Pallier
  File "/Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/MySQLdb/__init__.py", line 19, in <module>
381 3 Etienne Pallier
    import _mysql
382 3 Etienne Pallier
ImportError: dlopen(/Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so, 2): Library not loaded: libmysqlclient.18.dylib
383 3 Etienne Pallier
  Referenced from: /Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so
384 3 Etienne Pallier
  Reason: image not found
385 3 Etienne Pallier
386 3 Etienne Pallier
=> BOUH !!!
387 3 Etienne Pallier
388 3 Etienne Pallier
LA SOLUTION EST ICI : http://stackoverflow.com/questions/6383310/python-mysqldb-library-not-loaded-libmysqlclient-18-dylib
389 3 Etienne Pallier
390 3 Etienne Pallier
(
391 3 Etienne Pallier
Apparemment, ceci aurait dû suffire:
392 3 Etienne Pallier
mkdir -p /usr/local/lib   
393 3 Etienne Pallier
ln -s /usr/local/mysql/lib/libmysql* /usr/local/lib
394 3 Etienne Pallier
)
395 3 Etienne Pallier
396 3 Etienne Pallier
Mais j’ai fait ceci:
397 3 Etienne Pallier
398 3 Etienne Pallier
$ otool -L /Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so
399 3 Etienne Pallier
/Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so:
400 1 Etienne Pallier
	libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
401 10 Etienne Pallier
...
402 3 Etienne Pallier
403 3 Etienne Pallier
$ locate libmysqlclient.18.dylib
404 3 Etienne Pallier
/Applications/XAMPP/xamppfiles/lib/libmysqlclient.18.dylib
405 1 Etienne Pallier
/Library/SystemMigration/History/Migration-68137DFB-CB6A-4FBB-81E2-11BDB5D01E48/QuarantineRoot/usr/lib/libmysqlclient.18.dylib
406 1 Etienne Pallier
407 1 Etienne Pallier
$ sudo install_name_tool -change libmysqlclient.18.dylib /Applications/XAMPP/xamppfiles/lib/libmysqlclient.18.dylib /Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so
408 1 Etienne Pallier
409 10 Etienne Pallier
$ otool -L /Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so
410 10 Etienne Pallier
/Users/epallier/Documents/_W_more/PROJECTS/GFT/SOFT/PYROS/pyros/venv_py35_pyros/lib/python3.5/site-packages/_mysql.cpython-35m-darwin.so:
411 10 Etienne Pallier
	/Applications/XAMPP/xamppfiles/lib/libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
412 10 Etienne Pallier
...
413 3 Etienne Pallier
414 1 Etienne Pallier
$ ./manage.py inspectdb > models.py
415 1 Etienne Pallier
416 3 Etienne Pallier
=> YES !!!
417 44 Etienne Pallier
</pre>
418 3 Etienne Pallier
419 3 Etienne Pallier
420 7 Etienne Pallier
---
421 3 Etienne Pallier
422 48 Etienne Pallier
h3. Create a Django application pyrosapp
423 7 Etienne Pallier
424 3 Etienne Pallier
$ ./manage.py startapp pyrosapp
425 3 Etienne Pallier
426 3 Etienne Pallier
$ tree src
427 67 Etienne Pallier
<pre>
428 3 Etienne Pallier
src
429 3 Etienne Pallier
├── manage.py
430 3 Etienne Pallier
├── pyros
431 3 Etienne Pallier
│   ├── __init__.py
432 3 Etienne Pallier
│   ├── __pycache__
433 3 Etienne Pallier
│   │   ├── __init__.cpython-35.pyc
434 3 Etienne Pallier
│   │   ├── settings.cpython-35.pyc
435 3 Etienne Pallier
│   │   ├── urls.cpython-35.pyc
436 3 Etienne Pallier
│   │   └── wsgi.cpython-35.pyc
437 3 Etienne Pallier
│   ├── settings.py
438 3 Etienne Pallier
│   ├── urls.py
439 3 Etienne Pallier
│   └── wsgi.py
440 3 Etienne Pallier
└── pyrosapp
441 3 Etienne Pallier
    ├── __init__.py
442 1 Etienne Pallier
    ├── admin.py
443 3 Etienne Pallier
    ├── apps.py
444 1 Etienne Pallier
    ├── migrations
445 1 Etienne Pallier
    │   └── __init__.py
446 3 Etienne Pallier
    ├── models.py
447 3 Etienne Pallier
    ├── tests.py
448 1 Etienne Pallier
    └── views.py
449 67 Etienne Pallier
</pre>
450 1 Etienne Pallier
451 7 Etienne Pallier
---
452 1 Etienne Pallier
453 7 Etienne Pallier
h3. Replace the default pyrosapp models.py with the inspectdb generated one
454 7 Etienne Pallier
455 3 Etienne Pallier
$ mv models.py pyrosapp/
456 3 Etienne Pallier
457 3 Etienne Pallier
458 3 Etienne Pallier
459 3 Etienne Pallier
460 7 Etienne Pallier
461 1 Etienne Pallier
---
462 9 Etienne Pallier
463 47 Etienne Pallier
h3. *TODO: Fix and improve the inspectdb generated file models.py*
464 3 Etienne Pallier
465 3 Etienne Pallier
$ cd pyrosapp/
466 3 Etienne Pallier
467 8 Etienne Pallier
$ vi models.py