tag:blogger.com,1999:blog-38069032423995976852024-03-16T06:57:22.245+07:00Share to The WorldWawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.comBlogger240125tag:blogger.com,1999:blog-3806903242399597685.post-70741767647709083922024-02-21T06:20:00.001+07:002024-02-21T06:20:13.465+07:00Hapus Distro Linux di WSL dalam Windows 11<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKVG-bxCwPi4spKF4Va6FD8Gqz7lzcfeXHfshfw2ULM4j1Vvilat99QhdMiy3ATKcrC807wuaz0omAqyns_1lwKg-wMHGCoGtzL20o3f4Be8MbYoQxu5I-BW_PpxJAtHgZ5U9iwYFHO4q88EHumSXAUOhXD20TXCgkLuPWj8g6iYHnB9hUbJVxu8Q9bojn/s882/Screenshot%202024-02-21%20061933.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="618" data-original-width="882" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKVG-bxCwPi4spKF4Va6FD8Gqz7lzcfeXHfshfw2ULM4j1Vvilat99QhdMiy3ATKcrC807wuaz0omAqyns_1lwKg-wMHGCoGtzL20o3f4Be8MbYoQxu5I-BW_PpxJAtHgZ5U9iwYFHO4q88EHumSXAUOhXD20TXCgkLuPWj8g6iYHnB9hUbJVxu8Q9bojn/s320/Screenshot%202024-02-21%20061933.png" width="320" /></a></div><br /><p></p><p><span style="font-family: courier;">C:\Windows\System32><b>wsl -l -v</b></span></p><p><span style="font-family: courier;"> NAME STATE VERSION</span></p><p><span style="font-family: courier;">* Ubuntu Stopped 2</span></p><p><span style="font-family: courier;"><br /></span></p><p><span style="font-family: courier;">C:\Windows\System32><b>wsl -l -q</b></span></p><p><span style="font-family: courier;">Ubuntu</span></p><p><span style="font-family: courier;"><br /></span></p><p><span style="font-family: courier;">C:\Windows\System32><b>wsl --unregister Ubuntu</b></span></p><p><span style="font-family: courier;">Unregistering.</span></p><p><span style="font-family: courier;">The operation completed successfully.</span></p>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-87728528071550711752023-11-05T17:34:00.003+07:002023-11-05T17:34:35.924+07:00Download ebook Advanced Data Analytics Using Python. with machine learning,deep learning, and nlp examples<div class="separator" style="clear: both; text-align: center;"><a href="https://imgv2-1-f.scribdassets.com/img/document/381112722/original/a4df33c8ec/1583521334?v=1" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="800" data-original-width="600" height="400" src="https://imgv2-1-f.scribdassets.com/img/document/381112722/original/a4df33c8ec/1583521334?v=1" width="300" /></a></div><br /><p>Bagi yang membutuhkan ebook tentang Data Analytics dengan menggunakan Python, silahkan download <a href="https://github.com/yuanxiaosc/Machine_Learning_bookshelf/blob/master/book/Advanced%20Data%20Analytics%20Using%20Python.pdf" target="_blank">disini</a></p>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-52639867150332245412023-11-05T07:23:00.001+07:002023-11-05T07:23:06.142+07:00Download Ebook Latihan Test Bahasa Inggris Duolingo<div class="separator" style="clear: both; text-align: center;"><a href="https://cdn2.hubspot.net/hubfs/2249672/Imported_Blog_Media/duolingo_logo_highres_1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="800" data-original-width="800" height="400" src="https://cdn2.hubspot.net/hubfs/2249672/Imported_Blog_Media/duolingo_logo_highres_1.jpg" width="400" /></a></div><br /><p><br /></p><p>Bagi yang mau test Bahasa Inggris Duolingo dan membutuhkan ebook latihan testnya silahkan download link di bawah</p><p> <a href="https://drive.google.com/file/d/1QzKEusQRlkBOCT2KxDXrSxw4tuK1Dwet/view">11, YT, DET Sample Test_.pdf - Google Drive</a></p>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-1315102907499738632023-11-05T07:16:00.004+07:002023-11-05T07:17:39.212+07:00Download Ebook Practical Statistics for Data Scientists<p></p><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: center;"><a href="https://www.0textbooks.com/wp-content/uploads/2020/06/Practical-Statistics-for-Data-Scientists-50-Essential-Concepts-Using-R-and-Python-PDF-Textbook.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="648" data-original-width="494" height="400" src="https://www.0textbooks.com/wp-content/uploads/2020/06/Practical-Statistics-for-Data-Scientists-50-Essential-Concepts-Using-R-and-Python-PDF-Textbook.jpg" width="305" /></a></div><br /><br /></div><span face="-apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"" style="background-color: white; color: #222222; font-size: 20px; text-align: justify;">In the rapidly evolving landscape of data science, the significance of statistics cannot be overstated. With the exponential growth of data, the role of statistics has become increasingly crucial in extracting meaningful insights. Data scientists rely on practical statistics to decipher complex patterns and trends, facilitating informed decision-making processes and predictive modeling. Understanding the foundations of statistics is paramount for any data scientist aiming to derive valuable information from vast datasets.</span><p></p><p><span face="-apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"" style="background-color: white; color: #222222; font-size: 20px; text-align: justify;"><br /></span></p><p><span face="-apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"" style="background-color: white; color: #222222; font-size: 20px; text-align: justify;">Link download <b><a href="https://pyoflife.com/practical-statistics-for-data-scientists/#google_vignette" target="_blank">disini</a></b></span></p>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-13323440791781901722023-10-30T06:57:00.001+07:002023-10-30T06:57:01.984+07:00Download Ebook Introduction to Machine Learning with Python<div class="separator" style="clear: both; text-align: center;"><a href="https://pyoflife.com/wp-content/uploads/2023/09/Introduction-to-Machine-Learning-with-Python-640x1024.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="800" data-original-width="500" height="400" src="https://pyoflife.com/wp-content/uploads/2023/09/Introduction-to-Machine-Learning-with-Python-640x1024.jpeg" width="250" /></a></div><br /><p><span style="background-color: rgba(0, 0, 0, 0.03); color: #0f1419; font-family: TwitterChirp, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 15px; white-space-collapse: preserve;">Python sangat simple dengan banyak library serta disuport komunitas yang besar merupakan salah satu pilihan ideal dalam pemanfaatan Machine Leraning. Bagi yang membutuhkan tutorial Python bisa membaca ebook </span><span style="color: #0f1419; font-family: TwitterChirp, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif;"><span style="font-size: 15px; white-space-collapse: preserve;">Introduction to Machine Learning with Python.</span></span></p><p><span style="color: #0f1419; font-family: TwitterChirp, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif;"><span style="font-size: 15px; white-space-collapse: preserve;">Silahkan download <a href="https://pyoflife.com/introduction-to-machine-learning-with-python/" target="_blank">disini</a></span></span></p>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-88631742234285083172023-08-21T16:42:00.006+07:002023-08-21T16:48:31.569+07:00Google Earth Engine untuk Menampilkan SRTM dan Slope<div class="separator" style="clear: both; text-align: center;"><br /></div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSJghqvJ_WRZQkttUnnyuteI_beDYtXq1cqt7NfWsZpibKwFtLKB8I1i6QTq77v92-ce-k&usqp=CAU" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="186" data-original-width="271" height="186" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSJghqvJ_WRZQkttUnnyuteI_beDYtXq1cqt7NfWsZpibKwFtLKB8I1i6QTq77v92-ce-k&usqp=CAU" width="271" /></a></div><span style="font-family: helvetica;">Dengan menggunakan Google Earth Engine kita dengan mudah untuk menampilkan data SRTM dan dari SRTM tersebut bisa menampilkan data Slope.</span><div><span style="font-family: helvetica;"><br /></span></div><div><span style="font-family: helvetica;">Oke langkah yang dilakukan adalah:<br /></span><p></p><ul style="text-align: left;"><li><span style="font-family: helvetica;">Definisikan citra yang akan ditampilkan, dalam hal ini SRTM 30 meter</span></li></ul><p></p><span style="background-color: #fff2cc; font-family: courier;">//menampilkan citra srtm 30 m<br />var srtmIndramayu = ee.Image('USGS/SRTMGL1_003');</span><p></p><ul style="text-align: left;"><li><span style="font-family: helvetica;">Definisikan variabel slope dari srtm 30 meter yang sudah didefinisikan</span></li></ul><p></p><span style="background-color: #fff2cc; font-family: courier;">//membuat tampilan slope<br />var slope = ee.Terrain.slope(srtmIndramayu);</span><p></p><ul style="text-align: left;"><li><span style="font-family: helvetica;">Memotong tampilan/clip dengan daerah yang diinginkan, misal dalam hal ini saya sebelumnya import data di <b>asset </b>untuk batas Kabupaten Indramayu</span></li></ul><p></p><span style="background-color: #fff2cc; font-family: courier;">var clipSRTM = srtmIndramayu.clip(table);<br />var clipSlope= slope.clip(table);</span><p></p><ul style="text-align: left;"><li><span style="font-family: helvetica;">Sesuaikan tampilan tengah dari peta yang akan ditampilkan dan skalanya</span></li></ul><p></p><p><span style="background-color: #fff2cc; font-family: courier;">Map.setCenter(108.04636604969731, -6.531038850703211, 10);</span></p><p></p><ul style="text-align: left;"><li><span style="font-family: helvetica;">Definisikan parameter untuk tampilan peta termasuk palette warna, dan nilai min dan max</span></li></ul><p></p><span style="background-color: #fff2cc; font-family: courier;">var imageVisParam1 = {<br />'min': -2,<br />'max': 3128,<br />'opacity': 1,<br />'palette': ['3916ff', '10bdff', '10fff4', '14ff87', 'baff12', 'fbff12', 'ffc114', 'ff4218'],<br />};</span><div><br /></div><p></p><ul style="text-align: left;"><li><span style="font-family: helvetica;"> Tampilkan peta srtm dan slope</span></li></ul><p></p><p></p><p><span style="font-family: courier;">Map.addLayer(clipSRTM, imageVisParam1,'SRTM 30');</span></p><p><span style="font-family: courier;">Map.addLayer(clipSlope, {}, 'Slope');</span></p><p></p><ul style="text-align: left;"><li><span style="font-family: helvetica;">Kode keseluruhan</span></li></ul><p></p><span style="background-color: #fff2cc; font-family: courier;">//menampilkan citra srtm 30 m<br />var srtmIndramayu = ee.Image('USGS/SRTMGL1_003');<br />//slope <br />var slope = ee.Terrain.slope(srtmIndramayu);<br /> <br />var clipSRTM = srtmIndramayu.clip(table); <br /> <br />var clipSlope= slope.clip(table); <br /> <br />var imageVisParam1 = { <br /> 'min': -2, <br /> 'max': 3128, <br /> 'opacity': 1, <br /> 'palette': ['3916ff', '10bdff', '10fff4',</span></div><div><span style="background-color: #fff2cc; font-family: courier;"> '14ff87', 'baff12', 'fbff12', </span></div><div><span style="background-color: #fff2cc; font-family: courier;"> 'ffc114', 'ff4218'], <br /> }; <br /> <br />Map.setCenter(108.04636604969731, -6.531038850703211, 10);<br />Map.addLayer(clipSRTM, imageVisParam1,'SRTM 30');<br />Map.addLayer(clipSlope, {}, 'Slope');</span><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://drive.google.com/uc?export=view&id=1n_ZOwlhKYb_Dn6CFYLR4nePuHxg8_e3z" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="621" data-original-width="555" height="621" src="https://drive.google.com/uc?export=view&id=1n_ZOwlhKYb_Dn6CFYLR4nePuHxg8_e3z" width="555" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;"><span style="font-family: helvetica;">Terima kasih semoga bermanfaat. @wawanhn</span></div><br /><p><br /></p><p><span style="font-family: courier;"><br /></span></p></div>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-27481745013649626362023-08-17T19:56:00.001+07:002023-08-17T19:56:15.045+07:00Mengenal Google Earth Engine<p> </p><div class="separator" style="clear: both; text-align: center;"><a href="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSJghqvJ_WRZQkttUnnyuteI_beDYtXq1cqt7NfWsZpibKwFtLKB8I1i6QTq77v92-ce-k&usqp=CAU" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="186" data-original-width="271" height="186" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSJghqvJ_WRZQkttUnnyuteI_beDYtXq1cqt7NfWsZpibKwFtLKB8I1i6QTq77v92-ce-k&usqp=CAU" width="271" /></a></div><p></p><div class="separator" style="clear: both; text-align: left;"><b>Google Earth Engine: Platform Analisis Geospasial berbasis Cloud </b></div><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">Google Earth Engine adalah inovasi terkini dalam analisis data geospasial yang memberikan akses tak terbatas kepada peneliti, ilmuwan atau penguna lain untuk menjelajahi dan menganalisis fenomena bumi dalam skala global. Dengan memadukan kumpulan data citra satelit dan teknologi komputasi awan yang canggih, platform ini memberikan fasilitas untuk melakukan analisis mendalam tentang perubahan lingkungan, dinamika lahan, pemantauan iklim, keanekaragaman hayati, serta aspek topografi.</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">Melalui Google Earth Engine, praktisi dan akademisi memiliki akses terhadap beragam sumber data geospasial yang meliputi perekaman citra satelit dari berbagai sumber seperti Landsat, Sentinel, dan MODIS, Chirps. Dengan perangkat lunak ini, para pengguna mampu menjalankan berbagai analisis, mulai dari pemetaan perubahan spasial seiring waktu, hingga pemodelan dinamika lingkungan.</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">Keunggulan utama Google Earth Engine terletak pada kemampuannya untuk memproses data dalam skala global dengan kecepatan tinggi, mengeliminasi kebutuhan akan infrastruktur komputasi yang mahal. Ini menjadi alat yang sangat berharga bagi studi ilmiah dalam berbagai bidang, seperti geografi, ekologi, pengelolaan sumber daya alam, dan ilmu sosial.</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">Dalam konteks akademis, Google Earth Engine telah membuka jendela baru untuk penelitian yang lebih dalam dan luas. Pengguna dapat melakukan analisis spasial yang kompleks, membuat pemodelan prediktif yang tepat waktu, serta menghasilkan visualisasi yang informatif. Hal ini memfasilitasi proses pengambilan keputusan yang lebih baik berdasarkan informasi geospasial yang kaya dan mendalam.</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">Dalam kesimpulannya, Google Earth Engine telah memberikan sumbangan penting bagi dunia akademis dan riset ilmiah. Dengan membuka akses ke data geospasial global dan alat analisis berkecepatan tinggi, platform ini telah mendorong eksplorasi mendalam tentang dinamika planet kita, serta memberikan dasar bagi penelitian lanjutan dalam berbagai disiplin ilmu.</div></div><p><br /></p>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-39086268741508589092023-07-24T16:40:00.001+07:002023-07-24T16:40:07.226+07:00Download Buku Panduan Siswa untuk Pelajaran IPA Kelas XI Kurukulum Merdeka Terbaru<div class="separator" style="clear: both; text-align: center;"><a href="https://gurudikdas.kemdikbud.go.id/storage/users/3/Berita/PERAN%20GURU%20DALAM%20MENGHADAPI%20INOVASI%20MERDEKA%20BELAJAR.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="372" data-original-width="800" height="372" src="https://gurudikdas.kemdikbud.go.id/storage/users/3/Berita/PERAN%20GURU%20DALAM%20MENGHADAPI%20INOVASI%20MERDEKA%20BELAJAR.jpg" width="800" /></a></div><p>Saat ini kurikulum merdeka di tinkat Sekolah Menengah Atas sudah mulai semarak dilakukan di berbagai sekolah, bukan hanya sekolah penggerak atau perintis. Dengan kurikulum merdeka siswa diharapkan mampu belajar mandiri dan berkreasi supaya menjadi lebih maju, kreatif dan bisa berbagi.</p><p>Bagi siswa yang memerlukan buku untuk bahan pembelajaran Kurikulum Merdeka bidang IPA kelas XI, saya bagikan link buku dalam bentuk digital sebagai berikut:</p><p></p><ul><li><a href="https://www.mediafire.com/file/su4z9hdd7xu0ove/KM+Matematika-Tingkat-Lanjut-BS-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Matematika Lanjut</a></li><li><a href="https://www.mediafire.com/file/2sm5putepavszcd/KM+Matematika-BS-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Matematika</a></li><li><a href="https://www.mediafire.com/file/vis824h5npazdpt/KM+Fisika-BS-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Fisika</a></li><li><a href="https://www.mediafire.com/file/njsdeddk4mybyex/KM+Biologi-BS-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Biologi</a></li><li><a href="https://www.mediafire.com/file/tucgv1cay4gvapz/KM+Kimia-BS-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Kimia</a></li><li><a href="https://www.mediafire.com/file/8culwgan3ji0721/KM+Informatika-BS-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Informatika</a></li><li><a href="https://www.mediafire.com/file/bn9gl1dl5z2nwep/KM+Geografi-BS-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Geografi</a></li><li><a href="https://www.mediafire.com/file/1h87bbn7zvzt89r/KM+Bahasa-Inggris-Tingkat-Lanjut-BS-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Bahasa Ingris Lanjut</a></li><li><a href="https://www.mediafire.com/file/ymie6hbbdelsc8l/KM+Bahasa-Inggris-BS-KLS-XI-efc+[www.defantri.com].pdf/file" target="_blank">Bahasa Inggris</a></li><li><a href="https://www.mediafire.com/file/nuqn3eexgraz3to/KM+Bahasa-Indonesia-Tingkat-Lanjut-BS-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Bahasa Indonesia Lanjut</a></li><li><a href="https://www.mediafire.com/file/74uchhtksdlw3h9/KM+Bahasa-Indonesia-BS-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Bahasa Indonesia</a></li></ul><div>Terima kasih sudah berkunjung semoga mendapatkan manfaat dan semakin sukses. @wawanhn</div><div><br /></div><div>Referensi: https://www.defantri.com/2023/06/buku-kurikulum-merdeka-sma-11.html</div><p><br /></p><p></p>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-64262827020070579872023-07-24T16:23:00.003+07:002023-07-24T16:31:00.801+07:00Download Buku Panduan Guru untuk Pelajaran IPA Kelas XI Kurukulum Merdeka Terbaru<div class="separator" style="clear: both; text-align: center;"><a href="https://gurudikdas.kemdikbud.go.id/storage/users/3/Berita/PERAN%20GURU%20DALAM%20MENGHADAPI%20INOVASI%20MERDEKA%20BELAJAR.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="372" data-original-width="800" height="372" src="https://gurudikdas.kemdikbud.go.id/storage/users/3/Berita/PERAN%20GURU%20DALAM%20MENGHADAPI%20INOVASI%20MERDEKA%20BELAJAR.jpg" width="800" /></a></div><br /><p><br /></p><p>Saat ini kurikulum merdeka di tinkat Sekolah Menengah Atas sudah mulai semarak dilakukan di berbagai sekolah, bukan hanya sekolah penggerak atau perintis. Dengan kurikulum merdeka siswa diharapkan mampu belajar mandiri dan berkreasi supaya menjadi lebih maju, kreatif dan bisa berbagi.</p><p>Bagi guru yang memerlukan buku untuk bahan pembelajaran Kurikulum Merdeka bidang IPA kelas XI, saya bagikan link buku dalam bentuk digital sebagai berikut:</p><p></p><ul style="text-align: left;"><li><a href="https://www.mediafire.com/file/a2x2s2sy1s6pb6h/KM+Matematika-Tingkat-Lanjut-BG-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Matematika Lanjut</a></li><li><a href="https://www.mediafire.com/file/hjt9tflowbg70g7/KM+Matematika-BG-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Matematika</a></li><li><a href="https://www.mediafire.com/file/mtehc1eeybdytsv/KM+Fisika-BG-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Fisika</a></li><li><a href="https://www.mediafire.com/file/1ldg0g8htjml0es/KM+Biologi-BG-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Biologi</a></li><li><a href="https://www.mediafire.com/file/lvdo9pnuet4yjjh/KM+Kimia-BG-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Kimia</a></li><li><a href="https://www.mediafire.com/file/8j1ua0vbsm5bugz/KM+Informatika-BG-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Informatika</a></li><li><a href="https://www.mediafire.com/file/87mruzki92tpeac/KM+Geografi-BS-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Geografi</a></li><li><a href="https://www.mediafire.com/file/kppelhj3kbs3fg2/KM+Bahasa-Inggris-Tingkat-Lanjut-BG-KLS-XI+[www.defantri.com].pdf/file" target="_blank">Bahasa Ingris Lanjut</a></li><li><a href="https://www.mediafire.com/file/g2wxed2sh7gdg2q/KM+Bahasa-Inggris-BG-KLS-XI-efc+[www.defantri.com].pdf/file" target="_blank">Bahasa Inggris</a></li></ul><div>Terima kasih sudah berkunjung semoga mendapatkan manfaat dan semakin sukses. @wawanhn</div><div><br /></div><div>Referensi: https://www.defantri.com/2023/06/buku-kurikulum-merdeka-sma-11.html</div><p></p><p><br /></p>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-87752376111830940732023-07-08T21:22:00.003+07:002023-07-08T23:16:50.548+07:00Install PostgreSQL 14 di Linux berbasis Ubuntu<p> </p><h2 class="wp-block-heading" style="background-color: white; box-sizing: border-box; color: #279e21; cursor: auto; font-family: Roboto, sans-serif; font-size: 27px; font-weight: 400; line-height: 38px; margin: 30px 0px 20px; user-select: text;">Step 1 – Install PostgreSQL 14 on Debian 11 | Debian 10</h2><p style="background-color: white; box-sizing: border-box; color: #222222; cursor: auto; font-family: "open sans"; font-size: 17px; line-height: 31px; margin-bottom: 26px; margin-top: 0px; overflow-wrap: break-word; user-select: text;">PostgreSQL is available in the default Debian repositories but the available versions are not up to date. Check the available versions using the command:</p><pre class="wp-block-code" style="background-color: #051e30; border-color: rgb(40, 159, 244); border-image: initial; border-radius: 0px; border-style: solid; border-width: 1px 1px 1px 4px; box-sizing: border-box; color: white; font-family: monospace, monospace; font-size: 17px; margin-top: 24px; overflow-wrap: break-word; overflow: auto; padding: 4px 10px;"><code style="border: none; box-sizing: border-box; display: block; font-family: inherit; font-size: 1em; overflow-wrap: break-word; padding: 0px 0px 6px; position: relative; top: -1px; white-space: inherit;">sudo apt-cache search postgresql | grep postgresql</code></pre><span class="ezoic-autoinsert-video ezoic-mid_content" style="background-color: white; box-sizing: border-box; color: #222222; font-family: "open sans"; font-size: 17px; user-select: text;"></span><p style="background-color: white; box-sizing: border-box; color: #222222; cursor: auto; font-family: "open sans"; font-size: 17px; line-height: 31px; margin-bottom: 26px; margin-top: 0px; overflow-wrap: break-word; user-select: text;">In this guide, we are interested in PostgreSQL 14 which is not provided in the default repositories. Therefore, we are required to add a repository that provides the package.</p><pre class="wp-block-code" style="background-color: #051e30; border-color: rgb(40, 159, 244); border-image: initial; border-radius: 0px; border-style: solid; border-width: 1px 1px 1px 4px; box-sizing: border-box; color: white; font-family: monospace, monospace; font-size: 17px; margin-top: 24px; overflow-wrap: break-word; overflow: auto; padding: 4px 10px;"><code style="border: none; box-sizing: border-box; display: block; font-family: inherit; font-size: 1em; overflow-wrap: break-word; padding: 0px 0px 6px; position: relative; top: -1px; white-space: inherit;">sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'</code></pre><p style="background-color: white; box-sizing: border-box; color: #222222; cursor: auto; font-family: "open sans"; font-size: 17px; line-height: 31px; margin-bottom: 26px; margin-top: 0px; overflow-wrap: break-word; user-select: text;">Import the GPG key for the added repository.</p><pre class="wp-block-code" style="background-color: #051e30; border-color: rgb(40, 159, 244); border-image: initial; border-radius: 0px; border-style: solid; border-width: 1px 1px 1px 4px; box-sizing: border-box; color: white; font-family: monospace, monospace; font-size: 17px; margin-top: 24px; overflow-wrap: break-word; overflow: auto; padding: 4px 10px;"><code style="border: none; box-sizing: border-box; display: block; font-family: inherit; font-size: 1em; overflow-wrap: break-word; padding: 0px 0px 6px; position: relative; top: -1px; white-space: inherit;">wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -</code></pre><p style="background-color: white; box-sizing: border-box; color: #222222; cursor: auto; font-family: "open sans"; font-size: 17px; line-height: 31px; margin-bottom: 26px; margin-top: 0px; overflow-wrap: break-word; user-select: text;">Next, update your APT package index.</p><pre class="wp-block-code" style="background-color: #051e30; border-color: rgb(40, 159, 244); border-image: initial; border-radius: 0px; border-style: solid; border-width: 1px 1px 1px 4px; box-sizing: border-box; color: white; font-family: monospace, monospace; font-size: 17px; margin-top: 24px; overflow-wrap: break-word; overflow: auto; padding: 4px 10px;"><code style="border: none; box-sizing: border-box; display: block; font-family: inherit; font-size: 1em; overflow-wrap: break-word; padding: 0px 0px 6px; position: relative; top: -1px; white-space: inherit;">sudo apt -y update</code></pre><p style="background-color: white; box-sizing: border-box; color: #222222; cursor: auto; font-family: "open sans"; font-size: 17px; line-height: 31px; margin-bottom: 26px; margin-top: 0px; overflow-wrap: break-word; user-select: text;">Tulisan ini saya copy dari sumber website: <a href="https://computingforgeeks.com/how-to-install-postgresql-14-on-debian/">https://computingforgeeks.com/how-to-install-postgresql-14-on-debian/</a></p><p style="background-color: white; box-sizing: border-box; color: #222222; cursor: auto; font-family: "open sans"; font-size: 17px; line-height: 31px; margin-bottom: 26px; margin-top: 0px; overflow-wrap: break-word; user-select: text;">Langkah yang dilakukan adalah sebagai berikut:</p><p style="background-color: white; box-sizing: border-box; color: #222222; cursor: auto; font-family: "open sans"; font-size: 17px; line-height: 31px; margin-bottom: 26px; margin-top: 0px; overflow-wrap: break-word; user-select: text;">Now install PostgreSQL 14 on Debian 11/Debian 10 using the command below.</p><pre class="wp-block-code" style="background-color: #051e30; border-color: rgb(40, 159, 244); border-image: initial; border-radius: 0px; border-style: solid; border-width: 1px 1px 1px 4px; box-sizing: border-box; color: white; font-family: monospace, monospace; font-size: 17px; margin-top: 24px; overflow-wrap: break-word; overflow: auto; padding: 4px 10px;"><code style="border: none; box-sizing: border-box; display: block; font-family: inherit; font-size: 1em; overflow-wrap: break-word; padding: 0px 0px 6px; position: relative; top: -1px; white-space: inherit;">sudo apt install postgresql-14</code></pre><p style="background-color: white; box-sizing: border-box; color: #222222; cursor: auto; font-family: "open sans"; font-size: 17px; line-height: 31px; margin-bottom: 26px; margin-top: 0px; overflow-wrap: break-word; user-select: text;">Verify your PostgreSQL 14 installation as below.<span class="ezoic-adpicker-ad" id="ezoic-pub-ad-placeholder-169" style="box-sizing: border-box; user-select: text;"></span></p><span class="ezoic-autoinsert-video ezoic-long_content" style="background-color: white; box-sizing: border-box; color: #222222; font-family: "open sans"; font-size: 17px; user-select: text;"></span><pre class="wp-block-code" style="background-color: #051e30; border-color: rgb(40, 159, 244); border-image: initial; border-radius: 0px; border-style: solid; border-width: 1px 1px 1px 4px; box-sizing: border-box; color: white; font-family: monospace, monospace; font-size: 17px; margin-top: 24px; overflow-wrap: break-word; overflow: auto; padding: 4px 10px;"><code style="border: none; box-sizing: border-box; display: block; font-family: inherit; font-size: 1em; overflow-wrap: break-word; padding: 0px 0px 6px; position: relative; top: -1px; white-space: inherit;">$ <mark class="has-inline-color has-pale-pink-color" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; box-sizing: border-box;">sudo -u postgres psql -c "SELECT version();"</mark>
version
-----------------------------------------------------------------------------------------------------------------------------
PostgreSQL 14.8 (Debian 14.8-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit</code></pre><p style="background-color: white; box-sizing: border-box; color: #222222; cursor: auto; font-family: "open sans"; font-size: 17px; line-height: 31px; margin-bottom: 26px; margin-top: 0px; overflow-wrap: break-word; user-select: text;">With a complete installation, PostgreSQL 14 will be initialized. Check the status of the service as below. </p><p style="background-color: white; box-sizing: border-box; color: #222222; cursor: auto; font-family: "open sans"; font-size: 17px; line-height: 31px; margin-bottom: 26px; margin-top: 0px; overflow-wrap: break-word; user-select: text;"><span style="background-color: #051e30; color: white; font-family: monospace, monospace; white-space: pre;">$ </span><mark class="has-inline-color has-pale-pink-color" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; box-sizing: border-box; font-family: monospace, monospace; white-space: pre;">systemctl status postgresql </mark></p><p style="background-color: white; box-sizing: border-box; cursor: auto; line-height: 31px; margin-bottom: 26px; margin-top: 0px; overflow-wrap: break-word; user-select: text;"><span style="color: #222222; font-family: open sans;"><span style="font-size: 17px;">Referensi:</span></span></p><p style="background-color: white; box-sizing: border-box; cursor: auto; line-height: 31px; margin-bottom: 26px; margin-top: 0px; overflow-wrap: break-word; user-select: text;"><span style="color: #222222; font-family: open sans;"><span style="font-size: 17px;">https://computingforgeeks.com/best-books-to-learn-postgresql-database/</span></span></p><p style="background-color: white; box-sizing: border-box; cursor: auto; line-height: 31px; margin-bottom: 26px; margin-top: 0px; overflow-wrap: break-word; user-select: text;"><span style="color: #222222; font-family: open sans;"><span style="font-size: 17px;">https://computingforgeeks.com/how-to-install-postgis-on-ubuntu-linux/</span></span></p><p style="background-color: white; box-sizing: border-box; cursor: auto; line-height: 31px; margin-bottom: 26px; margin-top: 0px; overflow-wrap: break-word; user-select: text;"><span style="color: #222222; font-family: open sans;"><span style="font-size: 17px;">https://zonabiner.com/install-postgresql-ubuntu-20-04</span></span></p><p style="background-color: white; box-sizing: border-box; cursor: auto; line-height: 31px; margin-bottom: 26px; margin-top: 0px; overflow-wrap: break-word; user-select: text;"><span><span style="color: #222222; font-family: open sans; font-size: 17px;">https://askubuntu.com/questions/1010442/how-to-uninstall-the-postgresql</span></span></p><p style="background-color: white; box-sizing: border-box; color: #222222; cursor: auto; font-family: "open sans"; font-size: 17px; line-height: 31px; margin-bottom: 26px; margin-top: 0px; overflow-wrap: break-word; user-select: text;"><br /></p><pre class="wp-block-code" style="background-color: #051e30; border-color: rgb(40, 159, 244); border-image: initial; border-radius: 0px; border-style: solid; border-width: 1px 1px 1px 4px; box-sizing: border-box; color: white; font-family: monospace, monospace; font-size: 17px; margin-top: 24px; overflow-wrap: break-word; overflow: auto; padding: 4px 10px;"><code style="border: none; box-sizing: border-box; display: block; font-family: inherit; font-size: 1em; overflow-wrap: break-word; padding: 0px 0px 6px; position: relative; top: -1px; white-space: inherit;"><mark class="has-inline-color has-pale-pink-color" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; box-sizing: border-box;"></mark></code></pre>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-13747671811497117272023-02-17T07:25:00.000+07:002023-02-17T07:25:07.681+07:00Mengambil teks tertentu dari field di QGIS<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNAEVXjjW2Y6Jl2SjAfukW2bKXnRlri4x_NWXXQzwo4kyVxeLoIwqPuFRc50JH-2qFa6oxgiKWBNHziEMIdz_BuXnwGtJa8nAhHiPxZgHtpgCkmohgh5C8IWU6xhIWrqYSsO72YkWCVWf9EWmrxvCjkiCwGo7kYvqKl6z-5y2iK49gVbHlk729Q782Jw/s271/GIS-python.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="183" data-original-width="271" height="183" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNAEVXjjW2Y6Jl2SjAfukW2bKXnRlri4x_NWXXQzwo4kyVxeLoIwqPuFRc50JH-2qFa6oxgiKWBNHziEMIdz_BuXnwGtJa8nAhHiPxZgHtpgCkmohgh5C8IWU6xhIWrqYSsO72YkWCVWf9EWmrxvCjkiCwGo7kYvqKl6z-5y2iK49gVbHlk729Q782Jw/s1600/GIS-python.png" width="271" /></a></div><br /><p>Saat bekerja dengan string di atribut tabel QGIS dan ingin mengambil teks tertentu dalam suatu kolom atau field di atibut QGIS kita bisa memanfaatkan banyak fungsi <b>string </b>salah satunya <b>substr.</b></p><p>Sebagai contoh saya ingin melakukan join antara file excel/csv tentang data desa dengan menggunakan kode des BPS 1608010001 dengan 10 digit kode. Dan saya mendapatkan file shp untuk batas desa dari BIG dimana terdapat field dengan atribut 16.08.01.0001. Maka untuk melakukan join saya harus merubah kode kolom dari BIG menjadi seperti kode BPS.</p><p>Langkah yang di lakukan dengan menggunakan <b>Open Field Calculator </b>masukan kode</p><p><i><span style="font-family: courier;">substr("field_BIG", 0,2) + substr("field_BIG", 4,2) + substr("field_BIG", 7,2) + substr("field_BIG", 10,4)</span></i></p><p>Terima kasih sudah menyimak, smeoga bermanfaat. @wawanhn </p>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-87923600576784886122022-10-18T18:39:00.007+07:002022-10-21T13:13:40.548+07:00Mengkoneksikan PostgreSQL di Droplet Digital Ocean dengan PgAdmin<div><br /></div><div style="text-align: center;"><b><span style="font-size: x-large;"><span style="color: #2b00fe;">D</span>igital <span style="color: #20124d;">O</span>cean</span></b></div><div style="text-align: center;"><b><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9qZKzvP_w-2H_Ty2-kBLk1HiGNGG9h14FDEMMx1fIQQyLweFNo7OMVnf1S7iICGtf5KU_nDZ6J6COVJRhOloC6W2LendEO5QOflNoiqGoAAX_YfgnXQL1-JZhKhoDyTNDwwQZY3R71vrY/s200/postgresql_logo-555px.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="200" data-original-width="180" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9qZKzvP_w-2H_Ty2-kBLk1HiGNGG9h14FDEMMx1fIQQyLweFNo7OMVnf1S7iICGtf5KU_nDZ6J6COVJRhOloC6W2LendEO5QOflNoiqGoAAX_YfgnXQL1-JZhKhoDyTNDwwQZY3R71vrY/s200/postgresql_logo-555px.png" width="180" /></a></div><br /><span style="font-size: x-large;"><br /></span></b></div><ol style="text-align: left;"><li>Buat Droplet</li></ol><div><h1 class="post-title entry-title" style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-family: Ubuntu, sans-serif; font-size: 27px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; text-align: center; text-transform: capitalize; user-select: text; vertical-align: baseline; z-index: 0;"><a href="https://www.wawanhn.com/2022/10/deploy-aplikasi-django-menggunakan.html" target="_blank">Deploy Aplikasi Django Menggunakan Droplet Di DigitalOcean Bagian 1</a></h1></div><ol style="text-align: left;"><li>Koneksi ke Droplet</li></ol><div><span style="background-color: #04ff00; font-family: courier;">sudo apt update</span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><span style="background-color: #04ff00; font-family: courier;">apt install postgresql postgresql-contrib</span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><span style="background-color: #04ff00; font-family: courier;">update-rc.d postgresql enable</span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><span style="background-color: #04ff00; font-family: courier;">service postgresql start</span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><span style="background-color: #04ff00; font-family: courier;">service postgresql status</span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><span style="background-color: #04ff00; font-family: courier;"><div><b>Output:</b></div><div>● postgresql.service - PostgreSQL RDBMS</div><div> Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)</div><div> Active: active (exited) since Tue 2022-10-18 10:09:53 UTC; 2min 7s ago</div><div> Main PID: 4320 (code=exited, status=0/SUCCESS)</div><div> CPU: 1ms</div></span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><span style="background-color: #04ff00; font-family: courier;">cd ../etc/postgresql</span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><span style="background-color: #04ff00; font-family: courier;">ls</span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><span style="background-color: #04ff00; font-family: courier;">cd 14/main/</span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><span style="font-family: courier;"><span style="background-color: #04ff00;">ls</span></span></div><div><span style="font-family: courier;"><span style="background-color: #04ff00;"><br /></span></span></div><div><b style="font-family: courier;">Output:</b><span style="font-family: courier;"> </span></div><div><span style="font-family: courier;">conf.d environment pg_ctl.conf pg_hba.conf pg_ident.conf postgresql.conf start.conf</span></div><div><span style="font-family: courier;"><span style="background-color: #04ff00;"><br /></span></span></div><div><span style="background-color: #04ff00; font-family: courier;">ls -la</span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><span style="background-color: #04ff00; font-family: courier;"><div><b>Output:</b></div><div>drwxr-xr-x 3 postgres postgres 4096 Oct 18 10:09 .</div><div>drwxr-xr-x 3 postgres postgres 4096 Oct 18 10:09 ..</div><div>drwxr-xr-x 2 postgres postgres 4096 Oct 18 10:09 conf.d</div><div>-rw-r--r-- 1 postgres postgres 315 Oct 18 10:09 environment</div><div>-rw-r--r-- 1 postgres postgres 143 Oct 18 10:09 pg_ctl.conf</div><div>-rw-r----- 1 postgres postgres 5002 Oct 18 10:09 pg_hba.conf</div><div>-rw-r----- 1 postgres postgres 1636 Oct 18 10:09 pg_ident.conf</div><div>-rw-r--r-- 1 postgres postgres 29032 Oct 18 10:09 postgresql.conf</div><div>-rw-r--r-- 1 postgres postgres 317 Oct 18 10:09 start.conf</div></span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><span style="background-color: #04ff00; font-family: courier;">sudo nano pg_hba.conf</span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><span style="background-color: white; font-family: courier;"><b>Kemudian masukan pada baris paling akhir:</b></span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><div style="font-family: courier;"><span style="background-color: white;">host all all 0.0.0.0/0 trust</span></div><div style="font-family: courier;"><span style="background-color: white;">host all all ::/0 trust</span></div><div style="font-family: courier;"><span style="background-color: white;"><br /></span></div><div style="background-color: #04ff00; font-family: courier;">sudo nano postgresql.conf</div><div style="font-family: courier;"><span style="background-color: white;"><br /></span></div><div style="font-family: courier;"><span style="background-color: white;"><b>Edit baris ini, hilangkan komentar:</b></span></div><div style="font-family: courier;"><span style="background-color: white;"><br /></span></div><div style="font-family: courier;">listen_addresses = '*' # what IP address(es) to listen on;</div><div style="font-family: courier;"><br /></div><div style="font-family: courier;"><span style="background-color: #04ff00;">service postgresql restart</span></div><div style="font-family: courier;"><span style="background-color: #04ff00;"><br /></span></div><div><span style="font-family: arial; font-size: medium;"><b style="background-color: white;">Koneksi dengan PgAdmin4</b></span></div><div style="font-family: courier;"><br /></div><div><ol style="font-family: courier; text-align: left;"><li>Buka PgAdmin4, lalu di bagian menu kiri klik kanan Create Server</li><li>Pada Tab General masukan nama koneksi</li><li>Pada Tab Connection, masukan Host dengan IP dari Droplet DigitalOcean</li><li>Kemudian masukan port 5432, maintenance database postgres, dan Username postgres lalu klik Save.</li><li>Maka berhasil koneksi ke database PostgreSQL di Droplet DigitalOcean.</li></ol><div style="font-family: courier;">Silahkan buat database dan mebuat tabel.</div><div style="font-family: courier;"><br /></div><div><span style="font-family: arial; font-size: medium;"><b>Install extensi postgis</b></span></div><div style="font-family: courier;"><br /></div><div style="font-family: courier;"><span style="background-color: #04ff00;">sudo apt install postgis postgresql-14-postgis-3</span></div><div style="font-family: courier;"><br /></div><div><span style="font-family: arial; font-size: medium;"><b>Misal buat database dan user</b></span></div><div style="font-family: courier;"><br /></div><div style="font-family: courier;"><span style="background-color: #04ff00;">sudo -i -u postgres</span></div><div style="font-family: courier;"><br /></div><div style="font-family: courier;">lalu masuk ke postgrsql</div><div style="font-family: courier;"><br /></div><div style="font-family: courier;"><span style="background-color: #04ff00;">createuser user123</span></div><div style="font-family: courier;"><br /></div><div style="font-family: courier;"><span style="background-color: #04ff00;">createdb db_xxx -O user123</span></div><div style="font-family: courier;"><br /></div><div style="font-family: courier;"><span style="background-color: #04ff00;">psql -d db_xxx</span></div><div style="font-family: courier;"><span style="background-color: #04ff00;"><br /></span></div><div style="font-family: courier;">Menambahkan/menggati password untuk user1</div><div style="font-family: courier;"><br /></div><div><span style="font-family: courier;">ALTER USER user123 WITH PASSWORD password_baru</span></div><div style="font-family: courier;"><br /></div><div style="font-family: courier;"><span style="background-color: #04ff00;">CREATE EXTENSION postgis;</span></div><div style="font-family: courier;"><span style="background-color: #04ff00;"><br /></span></div><div style="font-family: courier;">Melihat List Database</div><div style="font-family: courier;"><br /></div><div style="font-family: courier;"><span style="background-color: #04ff00;">\l</span></div><div style="font-family: courier;"><br /></div><div style="font-family: courier;">Pindah database</div><div style="font-family: courier;"><br /></div><div style="font-family: courier;"><span style="background-color: #04ff00;">\c <nama_database></span></div><div style="font-family: courier;"><br /></div><div style="font-family: courier;">List Table</div><div style="font-family: courier;"><br /></div><div style="font-family: courier;"><span style="background-color: #04ff00;">\dt</span></div><div style="font-family: courier;"><br /></div><div style="font-family: courier;">Membuka port untuk Postgresql</div><div style="font-family: courier;"><br /></div><div style="font-family: courier;"><span style="background-color: #04ff00;">sudo ufw allow <port></span></div><div style="font-family: courier;"><span style="background-color: #04ff00;"><br /></span></div><div style="font-family: courier;"><span style="background-color: white;">Restart PostgreSQL</span></div><div style="font-family: courier;"><span style="background-color: white;"><br /></span></div><div><span style="background-color: #04ff00; font-family: courier;">service postgresql restart</span></div><div style="font-family: courier;"><span style="background-color: white;"><br /></span></div><div style="font-family: courier;"><br /></div><div style="font-family: courier;"><br /></div><div style="font-family: courier;">Referensi:</div><div><span style="font-family: courier;">https://computingforgeeks.com/how-to-install-postgis-on-ubuntu-linux/</span></div><div><span style="font-family: courier;"><br /></span></div><div><span style="font-family: courier;">https://docs.digitalocean.com/products/databases/postgresql/how-to/connect/</span></div></div></div><div><span style="font-family: courier;"><br /></span></div><div><span style="font-family: courier;">https://www.bigbinary.com/blog/configure-postgresql-to-allow-remote-connection</span></div><div><span style="font-family: courier;"><br /></span></div><div><span style="font-family: courier;">https://chartio.com/resources/tutorials/how-to-list-databases-and-tables-in-postgresql-using-psql/</span></div>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-86559562023601690292022-10-11T14:28:00.006+07:002022-10-11T14:30:07.212+07:00Cara Embeding Gambar di Google Drive dengan Tag HTML<p><span face="Muli, sans-serif" style="background-color: white; color: #444444; font-size: 15px;">Dalam membuat website atau blog salah satu cara untuk membuat tampilan lebih menarik dan lebih memberikan informasi yang jelas adalah dengan menampilkan gambar. Dengan pertimbangan keamanan dan efisiensi ukuran penyimpan untuk gambar bisa menggunakan layanan cloud. Dalam hal ini salah satunya menggunakan Google Drive sebaga penyedia cloud untuk penyimpanan data. Misal kita simpan gambar-gambar untuk blog atau web kita kemudian kita link kan gambar tersebut dengan memanggil menggunakan tag html <b>img.</b></span></p><p><span face="Muli, sans-serif" style="background-color: white; color: #444444; font-size: 15px;">Jika langsung dengan melinkan alamat gambar dari Google Drive maka gambar tersebut tidak akan langsung tampil. Sehingga untuk bisa menampilkan gambar tersebut perlu dilakukan langkah-langkah yaitu:</span></p><p></p><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Buka Google Drive,</span></span></li></ul><div><span face="Muli, sans-serif" style="color: #444444;"><span style="font-size: 15px;"><br /></span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Upload gambar,</span></span></li></ul><div><span face="Muli, sans-serif" style="color: #444444;"><span style="font-size: 15px;"><br /></span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Klik kanan pada gambar pilih <b>share </b>atau <b>bagikan,</b></span></span></li></ul><div><span face="Muli, sans-serif" style="color: #444444;"><span style="font-size: 15px;"><b><br /></b></span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Setelah tampil, rubah seting Akses Umum menjadi Siapa saja yang memiliki link,</span></span></li></ul><div><span face="Muli, sans-serif" style="color: #444444;"><div class="separator" style="clear: both; text-align: center;"><a href="https://drive.google.com/uc?export=view&id=1huTfLaQQVrusrwK-US_T1VRFW10pHJ4G" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="461" data-original-width="517" height="461" src="https://drive.google.com/uc?export=view&id=1huTfLaQQVrusrwK-US_T1VRFW10pHJ4G" width="517" /></a></div><br /><span style="font-size: 15px;"><br /></span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif"><span style="background-color: white; color: #444444; font-size: 15px;">Salin Link, misal kita dapat link: </span></span><span style="font-family: courier;">https://drive.google.com/file/d/<u>1huTfLaQQVrusrwK-US_T1VRFW10pHJ4G</u>/view</span></li></ul><div><span face="Muli, sans-serif" style="color: #444444;"><span style="font-size: 15px;"><br /></span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Masukan kode ke tag <b>img</b> dengan menambahkan kode </span></span>https://drive.google.com/uc?export=view&id=[id_image]</li></ul><div><br /></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Dan ganti [id_image] dengan id image di Google drive dalam hal ini </span></span><span style="font-family: courier;"><b>1huTfLaQQVrusrwK-US_T1VRFW10pHJ4G</b></span></li></ul><div><span style="font-family: courier;"><b><img src="https://drive.google.com/uc?export=view&id="1huTfLaQQVrusrwK-US_T1VRFW10pHJ4G"></b></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Dan akhirnya kita bisa menampilkan gambar di Google Drive.</span></span></li></ul><div><span face="Muli, sans-serif" style="color: #444444;"><span style="font-size: 15px;">Terima kasih sudah menyimak tutorial sederhana namun sangat bermanfaat. @wawanhn</span></span></div><div><span face="Muli, sans-serif" style="color: #444444;"><span style="font-size: 15px;"><br /></span></span></div><div><span face="Muli, sans-serif" style="color: #444444; font-size: x-small;">Referensi:</span></div><div><span face="Muli, sans-serif" style="color: #444444; font-size: x-small;">https://stackoverflow.com/questions/15557392/how-do-i-display-images-from-google-drive-on-a-website</span></div><div><span face="Muli, sans-serif" style="color: #444444; font-size: x-small;">https://dev.to/temmietope/embedding-a-google-drive-image-in-html-3mm9</span></div><p></p>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-22119077716956989532022-10-09T19:52:00.031+07:002022-10-21T14:28:37.541+07:00Membuat Aplikasi Django dan PostgreSQL dengan menggunakan Docker cara 2<p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://img1.pngdownload.id/20180629/kz/kisspng-docker-logo-kubernetes-software-deployment-engineer-logo-5b3616d6abce13.6733351915302714467037.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="260" data-original-width="260" height="260" src="https://img1.pngdownload.id/20180629/kz/kisspng-docker-logo-kubernetes-software-deployment-engineer-logo-5b3616d6abce13.6733351915302714467037.jpg" width="260" /></a></div><span face="Muli, sans-serif" style="background-color: white; color: #444444; font-size: 15px;">Setelah sebelumnya membuat aplikasi Django dan PostgreSQL di </span><p></p><h1 class="post-title entry-title" style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-family: Ubuntu, sans-serif; font-size: 27px; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; text-align: left; text-transform: capitalize; user-select: text; vertical-align: baseline; z-index: 0;"><a href="https://www.wawanhn.com/2022/10/membuat-aplikasi-django-dan-postgresql.html" target="_blank">Membuat Aplikasi Django Dan PostgreSQL Dengan Menggunakan Docker Cara 1</a></h1><p><span face="Muli, sans-serif" style="background-color: white; color: #444444; font-size: 15px;">Sekarang dengan sedikit perbedaan akan membuat aplikasi Django dan PostgreSQL di Windows.</span></p><p><span face="Muli, sans-serif" style="background-color: white; color: #444444; font-size: 15px;">Langkah yang dilakukan adalah dengan membuat virtual environment terlebih dahulu kemudian baru membuat kontainer dengan Docker. Hal ini dilakukan untuk lebih memahami persamaan dan perbedaan DOcker dengan virtual environment yang biasa dilakukan dalam pengembangan aplikasi Django. </span></p><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-family: Ubuntu, sans-serif; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; text-align: left; text-transform: capitalize; user-select: text; vertical-align: baseline; z-index: 0;"><span style="font-size: medium;">Membuat Virtual Environment</span></h3><div><span style="font-size: medium;"><br /></span></div><div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="background-color: white; color: #444444; font-size: 15px;">Buka command prompt dan buat direktori kerja</span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">mkdir dockertest</span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Masuk ke folder direktori kerja</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">cd dockertest</span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Buat virtual environment, misal dengan nama <b>venv</b></span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">python -m venv venv</span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Aktifkan virtual environment</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">cd venv/scripts</span></span></div><div><span face="Muli, sans-serif" style="color: #444444;"><span style="font-size: 15px;"><br /></span></span></div><div><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: #04ff00; font-size: 15px;">activate</span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Setelah virtual environment active dengan ditandai di promt <b>(venv)</b>... Install Djanggo versi terakhir 4,</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">python -m pip install Django~=4.0.0</span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Install psycopg2-binary</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">python -m pip install psycopg2-binary==2.9.3</span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Buat project Django, misal dengan nama django_project</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">django-admin startproject django_project .</span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Lakukan migrate</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">python manage.py migrate</span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Jalankan server</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">python manage.py runserver</span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Cek di browser dengan alamat http:127.0.0.1:8000, jika berhasil menampilkan halama aplikasi Djanggo maka langkah yang dilakukan berhasil.</span></span></li><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Buat file requirements.txt yang berisi paket yang dibutuhkan dari aplikasi Django yang sudah dibuat</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">pip freeze > requirements.txt</span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Selanjutnya akan membuat kontainer dengan docker, maka matikan virtual environment.</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">deactivate</span></span></div><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;"><br /></span></span></div><div><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-family: Ubuntu, sans-serif; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; text-transform: capitalize; user-select: text; vertical-align: baseline; z-index: 0;"><span style="font-size: medium;">Membuat Docker</span></h3></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Buat file Dockerfile, masukan kode:</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">vim Dokerfile</span></span></div><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;"><br /></span></span></div><div><ul><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Masukan kode kedalam dile Dockerfile:</span></span></li></ul></div><div><span face="Muli, sans-serif" style="color: #444444;"><span style="font-size: 15px;"><br /></span></span></div><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div style="line-height: 19px;"><div><span style="color: #6a9955;">#Pull base image</span></div><div><span style="color: #c586c0;">FROM</span> <span style="color: #4ec9b0;">python</span>:<span style="color: #9cdcfe;">3.9</span></div><br /><div><span style="color: #6a9955;">#SEt environment variable</span></div><div><span style="color: #c586c0;">ENV</span> <span style="color: #9cdcfe;">PIP_DISABLE_PIP_VERSION_CHECK</span> <span style="color: #9cdcfe;">1</span></div><div><span style="color: #c586c0;">ENV</span> <span style="color: #9cdcfe;">PYTHONDONTBYTECODE</span> <span style="color: #9cdcfe;">1</span></div><div><span style="color: #c586c0;">ENV</span> <span style="color: #9cdcfe;">PYTHONUNBUFFERED</span> <span style="color: #9cdcfe;">1</span></div><br /><div><span style="color: #6a9955;">#Set work directory</span></div><div><span style="color: #c586c0;">WORKDIR</span> <span style="color: #9cdcfe;">/code</span></div><br /><div><span style="color: #6a9955;">#Install dependecies</span></div><div><span style="color: #c586c0;">COPY</span> <span style="color: #9cdcfe;">./requirements.txt</span> <span style="color: #9cdcfe;">.</span></div><div><span style="color: #c586c0;">RUN</span> <span style="color: #9cdcfe;">pip</span> <span style="color: #9cdcfe;">install</span> <span style="color: #9cdcfe;">-r</span> <span style="color: #9cdcfe;">requirements.txt</span></div><br /><div><span style="color: #6a9955;">#Copy project</span></div><div><span style="color: #c586c0;">COPY</span> <span style="color: #9cdcfe;">.</span> <span style="color: #9cdcfe;">.</span></div></div></div></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Sebelum membangun image, buat file .dockerignore</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">vim .dockerignore</span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Masukan kode:</span></span></li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div>.venv</div><div>.git</div><div>.gitignore</div></div></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Membangun docker,</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">docker build .</span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Membuat file docker-compose.yml</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">vim docker-compose.yml</span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Masukan kode, </span></span>dengan catatan buat dulu database di PostgreSQL dan tentukan user dan password untuk akses ke database:</li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div style="line-height: 19px;"><div><span style="color: #569cd6;">version</span>: <span style="color: #ce9178;">"3.9"</span></div><br /><div><span style="color: #569cd6;">services</span>:</div><div> <span style="color: #569cd6;">db</span>:</div><div> <span style="color: #569cd6;">image</span>: <span style="color: #ce9178;">postgres</span></div><div> <span style="color: #569cd6;">volumes</span>:</div><div> - <span style="color: #ce9178;">postgres_data:/var/lib/postgresql/data/</span></div><div> <span style="color: #569cd6;">environment</span>:</div><div> - <span style="color: #ce9178;">POSTGRES_DB=postgres</span></div><div> - <span style="color: #ce9178;">POSTGRES_USER=postgres</span></div><div> - <span style="color: #ce9178;">POSTGRES_PASSWORD=password</span></div><br /><div> <span style="color: #569cd6;">web</span>:</div><div> <span style="color: #569cd6;">build</span>: <span style="color: #b5cea8;">.</span></div><div> <span style="color: #569cd6;">command</span>: <span style="color: #ce9178;">python manage.py runserver 0.0.0.0:8000</span></div><div> <span style="color: #569cd6;">volumes</span>:</div><div> - <span style="color: #ce9178;">.:/code</span></div><div> <span style="color: #569cd6;">ports</span>:</div><div> - <span style="color: #ce9178;">"8000:8000"</span></div><div> <span style="color: #569cd6;">depends_on</span>:</div><div> - <span style="color: #ce9178;">db</span> </div><br /><div><span style="color: #569cd6;">volumes</span>:</div><div> <span style="color: #569cd6;">postgres_data</span>:</div></div></div></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Lakukan konfigurasi untuk seting database di file docker_project/settings.py</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">vim docker_project/settings.py</span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Masukin kode skrip di bagian DATABASES:</span></span></li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div>DATABASES ={</div><div> <span style="color: #ce9178;">'default'</span>: {</div><div> <span style="color: #ce9178;">'ENGINE'</span>: <span style="color: #ce9178;">'django.db.backends.postgresql'</span>,</div><div> <span style="color: #ce9178;">'NAME'</span>: <span style="color: #ce9178;">'postgres'</span>,</div><div> <span style="color: #ce9178;">'USER'</span>: <span style="color: #ce9178;">'postgres'</span>,</div><div> <span style="color: #ce9178;">'PASSWORD'</span>: <span style="color: #ce9178;">'password'</span>,</div><div> <span style="color: #ce9178;">'HOST'</span>: <span style="color: #ce9178;">'db'</span>,</div><div> <span style="color: #ce9178;">'PORT'</span>: <span style="color: #ce9178;">'5432'</span>,</div><div> }</div><div>}</div></div></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Menjalankan Docker</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">docker-compose up</span></span></div><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Setelah proses selesai, silahkan cek server di browser dengan memasukan alamat http://127.0.0.1:8000. Jika berhasil menampilkan tampilan halaman aplikasi Django maka langkah-langkah yang dilakukan berhasil.</span></span></li><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px;">Atau dengan cara lain dapat dilakukan dengan mengabung perintah build dan docker-compose up dengan cara:</span></span></li></ul><div><span style="background-color: #04ff00; color: #444444; font-family: courier; font-size: 15px;">docker-compose up -d --build</span></div><ul style="text-align: left;"><li><span style="color: #444444;"><span style="background-color: white; font-size: 15px;">Setelah dicek server berlajan, untuk keluar dari tampilan service docker dengan cara tekan <b>Ctrl + C</b></span></span></li><li><span style="color: #444444;"><span style="background-color: white; font-size: 15px;">Selanjutnya akan membuat aplikasi dengan nama <b><i>accounts</i></b>, untuk membuat aplikasi untuk pengguna.</span></span></li></ul></div><div><div><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-family: Ubuntu, sans-serif; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; text-transform: capitalize; user-select: text; vertical-align: baseline; z-index: 0;"><span style="font-size: medium;">Membuat Apps <span style="color: white;">a</span>accounts</span></h3></div></div><div><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; user-select: text; vertical-align: baseline; z-index: 0;"><ul style="text-align: left;"><li><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px; font-weight: 400;">Membuat App dengan nama </span><span style="background-color: white; font-size: 15px;">accounts</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px; font-weight: normal;">docker-compose run web python manage.py startapp accounts</span></span></div><div><span style="color: #444444;"><span style="font-size: 15px;"><br /></span></span></div><div><span style="color: #444444;"><span style="font-size: 15px;">atau</span></span></div><div><span style="color: #444444;"><span style="font-size: 15px;"><br /></span></span></div><div><span style="background-color: #04ff00; color: #444444; font-size: 15px;"><span style="font-family: courier;">docker-compose exec web python manage.py startapp accounts</span></span></div><ul style="text-align: left;"><li><span style="color: #444444; font-size: 15px; font-weight: normal;">Membuat CustomUser dengan menggunakan AbstractUser, edit file #accounts/models.py </span></li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;"><div><span style="color: #569cd6;">from</span> django.db <span style="color: #569cd6;">import</span> models</div><div><span style="color: #569cd6;">from</span> django.contrib.auth.models <span style="color: #569cd6;">import</span> AbstractUser</div><br /><div><span style="color: #6a9955;"># Create your models here.</span></div><div><span style="color: #569cd6;">class</span> CustomUser(AbstractUser):</div><div> <span style="color: #569cd6;">pass</span></div><br /></div></div><ul style="text-align: left;"><li><span style="color: #444444;"><span style="background-color: white; font-size: 15px; font-weight: 400;">Tambahkan App accounts di bagian INSTALLED_APPS pada </span></span><span style="font-weight: normal;"><span style="font-size: small;">file #django_project/settings.py</span></span></li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;"><div>INSTALLED_APPS = [</div><div> <span style="color: #ce9178;">'django.contrib.admin'</span>,</div><div> <span style="color: #ce9178;">'django.contrib.auth'</span>,</div><div> <span style="color: #ce9178;">'django.contrib.contenttypes'</span>,</div><div> <span style="color: #ce9178;">'django.contrib.sessions'</span>,</div><div> <span style="color: #ce9178;">'django.contrib.messages'</span>,</div><div> <span style="color: #ce9178;">'django.contrib.staticfiles'</span>,</div><div> <span style="color: #6a9955;">#local</span></div><div> <span style="color: #ce9178;">'accounts.apps.AccountsConfig'</span>, #tambahkan</div><div>]</div></div></div><ul style="text-align: left;"><li><span style="color: #444444;"><span style="background-color: white; font-size: 15px; font-weight: 400;">Tambahkan juga di bagian bawah file #django_project/settings.py</span></span></li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;"><div style="line-height: 19px;">AUTH_USER_MODEL = <span style="color: #ce9178;">'accounts.CustomUser'</span></div></div></div></h3><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; user-select: text; vertical-align: baseline; z-index: 0;"><ul style="text-align: left;"><li><span style="background-color: white; color: #444444; font-size: 15px; font-weight: 400;">Lakukan makemigrations</span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px; font-weight: 400;">docker-compose exec web python manage.py makemigrations accounts</span></span></div></h3><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; user-select: text; vertical-align: baseline; z-index: 0;"><span style="font-weight: normal;">output:</span></h3><div style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; text-align: left; user-select: text; vertical-align: baseline; z-index: 0;"><span style="font-family: courier; font-size: small;">Migrations for 'accounts':<br /></span><span style="font-family: courier; font-size: small;"> accounts/migrations/0001_initial.py<br /></span><span style="font-family: courier; font-size: small;"> - Create model CustomUser</span></div><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; user-select: text; vertical-align: baseline; z-index: 0;"><ul style="text-align: left;"><li><span style="color: #444444;"><span style="background-color: white; font-size: 15px; font-weight: 400;">Lakukan migrate</span></span></li></ul><div><span style="color: #444444;"><span style="font-size: 15px; font-weight: 400;"><div><span style="background-color: #04ff00;"><span style="font-family: courier;">docker-compose exec web python manage.py migrate</span></span></div></span></span></div></h3><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; user-select: text; vertical-align: baseline; z-index: 0;"><span style="font-weight: normal;">output:</span></h3><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; user-select: text; vertical-align: baseline; z-index: 0;"><div><span style="color: #444444; font-family: courier;"><span style="font-size: 15px; font-weight: 400;"><div></div><div>Operations to perform:</div><div> Apply all migrations: accounts, admin, auth, contenttypes, sessions</div><div>Running migrations:</div><div> Applying contenttypes.0001_initial... OK</div><div> Applying contenttypes.0002_remove_content_type_name... OK</div><div> Applying auth.0001_initial... OK</div><div> Applying auth.0002_alter_permission_name_max_length... OK</div><div> Applying auth.0003_alter_user_email_max_length... OK</div><div> Applying auth.0004_alter_user_username_opts... OK</div><div> Applying auth.0005_alter_user_last_login_null... OK</div><div> Applying auth.0006_require_contenttypes_0002... OK</div><div> Applying auth.0007_alter_validators_add_error_messages... OK</div><div> Applying auth.0008_alter_user_username_max_length... OK</div><div> Applying auth.0009_alter_user_last_name_max_length... OK</div><div> Applying auth.0010_alter_group_name_max_length... OK</div><div> Applying auth.0011_update_proxy_permissions... OK</div><div> Applying auth.0012_alter_user_first_name_max_length... OK</div><div> Applying accounts.0001_initial... OK</div><div> Applying admin.0001_initial... OK</div><div> Applying admin.0002_logentry_remove_auto_add... OK</div><div> Applying admin.0003_logentry_add_action_flag_choices... OK</div><div> Applying sessions.0001_initial... OK</div></span></span></div><ul style="text-align: left;"><li><span style="color: #444444;"><span style="background-color: white; font-size: 15px; font-weight: 400;">Edit file #accounts/forms.py:</span></span></li></ul><div><span style="color: #444444;"><span style="font-size: 15px; font-weight: 400;"><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div><span style="color: #6a9955;">#accounts/forms.py</span></div><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">contrib</span>.<span style="color: #4ec9b0;">auth</span> <span style="color: #c586c0;">import</span> <span style="color: #dcdcaa;">get_user_model</span></div><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">contrib</span>.<span style="color: #4ec9b0;">auth</span>.<span style="color: #4ec9b0;">forms</span> <span style="color: #c586c0;">import</span> <span style="color: #4ec9b0;">UserCreationForm</span>, <span style="color: #4ec9b0;">UserChangeForm</span></div><br /><div><span style="color: #569cd6;">class</span> <span style="color: #4ec9b0;">CustomUserCreationForm</span>(<span style="color: #4ec9b0;">UserCreationForm</span>):</div><div> <span style="color: #569cd6;">class</span> <span style="color: #4ec9b0;">Meta</span>:</div><div> <span style="color: #9cdcfe;">model</span> = <span style="color: #dcdcaa;">get_user_model</span>()</div><div> <span style="color: #9cdcfe;">fields</span> = (<span style="color: #ce9178;">"email"</span>, <span style="color: #ce9178;">"username"</span>,)</div><br /><br /><div><span style="color: #569cd6;">class</span> <span style="color: #4ec9b0;">CustomUserChangeForm</span>(<span style="color: #4ec9b0;">UserChangeForm</span>):</div><div> <span style="color: #569cd6;">class</span> <span style="color: #4ec9b0;">Meta</span>:</div><div> <span style="color: #9cdcfe;">model</span> = <span style="color: #dcdcaa;">get_user_model</span>()</div><div> <span style="color: #9cdcfe;">fields</span> = (<span style="color: #ce9178;">"email"</span>, <span style="color: #ce9178;">"username"</span>,)</div><br /></div></span></span></div><ul style="text-align: left;"><li><span style="color: #444444;"><span style="background-color: white; font-size: 15px; font-weight: 400;">Edit file #accounts/admin.py</span></span></li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; font-weight: normal; line-height: 19px; white-space: pre;"><div><span style="color: #6a9955;">#accounts/admin.py</span></div><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">contrib</span> <span style="color: #c586c0;">import</span> <span style="color: #4ec9b0;">admin</span></div><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">contrib</span>.<span style="color: #4ec9b0;">auth</span> <span style="color: #c586c0;">import</span> <span style="color: #dcdcaa;">get_user_model</span></div><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">contrib</span>.<span style="color: #4ec9b0;">auth</span>.<span style="color: #4ec9b0;">admin</span> <span style="color: #c586c0;">import</span> <span style="color: #4ec9b0;">UserAdmin</span></div><br /><div><span style="color: #c586c0;">from</span> .<span style="color: #4ec9b0;">forms</span> <span style="color: #c586c0;">import</span> CustomUserCreationForm, <span style="color: #4ec9b0;">CustomUserChangeForm</span></div><br /><div><span style="color: #6a9955;"># Register your models here.</span></div><div><span style="color: #9cdcfe;">CustomUser</span> = <span style="color: #dcdcaa;">get_user_model</span>()</div><br /><div><span style="color: #569cd6;">class</span> <span style="color: #4ec9b0;">CustomUserAdmin</span>(<span style="color: #4ec9b0;">UserAdmin</span>):</div><div> <span style="color: #9cdcfe;">add_form</span> = CustomUserCreationForm</div><div> <span style="color: #9cdcfe;">form</span> = <span style="color: #4ec9b0;">CustomUserChangeForm</span></div><div> <span style="color: #9cdcfe;">model</span> = <span style="color: #9cdcfe;">CustomUser</span></div><br /><div> <span style="color: #9cdcfe;">list_display</span> = [</div><div> <span style="color: #ce9178;">"email"</span>, </div><div> <span style="color: #ce9178;">"username"</span>, </div><div> <span style="color: #ce9178;">"is_superuser"</span>, </div><div> ]</div><br /><div><span style="color: #4ec9b0;">admin</span>.<span style="color: #9cdcfe;">site</span>.register(<span style="color: #9cdcfe;">CustomUser</span>, <span style="color: #4ec9b0;">CustomUserAdmin</span>)</div></div></div><ul style="text-align: left;"><li><span style="color: #444444;"><span style="background-color: white; font-size: small; font-weight: normal;">Buat superuser untuk admin, misal dengan username: postgresqladmin, email: postgresqladmin@email.com, dan password: testpass123.</span></span></li></ul><ul style="text-align: left;"><div style="font-size: medium; font-weight: 400;"><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">docker-compose exec web python manage.py createsuperuser</span></span></div></ul><ul style="text-align: left;"><li><span style="color: #444444;"><span style="background-color: white; font-size: 15px; font-weight: 400;">Lalu coba di browser alamat admin http://127.0.0.1:8000/admin, login dengan user yang tadi dibuat.</span></span></li></ul><div><span style="color: #444444;"><div class="separator" style="clear: both; text-align: center;"><a href="https://drive.google.com/uc?export=view&id=1a-ZpzmwkSYQ6-CRchjLHJo4bIJO5oZjl" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="536" data-original-width="800" height="429" src="https://drive.google.com/uc?export=view&id=1a-ZpzmwkSYQ6-CRchjLHJo4bIJO5oZjl" width="640" /></a></div></span></div><ul style="text-align: left;"><li><span style="background-color: white; color: #444444; font-size: 15px; font-weight: 400;">Silahkan klik di menu </span><span style="background-color: white; color: #444444; font-size: 15px;">ACCOUNTS/</span><span style="background-color: white; color: #444444; font-size: 15px;">Users, <span style="font-weight: normal;">dengan menu tersebut bisa melihat, merubah user dengan menampilkan inputan username dan password serta kemudian menambahkan email dan status user. Silahkan dicoba-coba.</span></span></li></ul><div></div></h3><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-family: Ubuntu, sans-serif; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; text-transform: capitalize; user-select: text; vertical-align: baseline; z-index: 0;"><span style="font-size: medium;">Melakukan test Aplikasi</span></h3><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; user-select: text; vertical-align: baseline; z-index: 0;"><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px; font-weight: 400;">Setelah dibuat fungsional baru pada aplikasi accounts, selanjutnya dilakukan testing dengan menggunakna unit testing dari framework Django. Testing dilakukan karena meupakan hal penting yang harus dilakukan seperti yang disampaikan oleh pendiri Django yaitu Jacob Kaplan-Moss bahwa "Kode program tanpa dilakukan test adalah sebuah kerusakan dalam desain". Dalam Django terdapat dua tipe test yaitu:</span></span></h3><div><ul style="text-align: left;"><li><span style="color: #444444;"><span style="background-color: white; font-size: 15px;">Unit test kecil, cepat, dan terisolasi untuk sebagian fungsi dalam aplikasi.</span></span></li><li><span style="color: #444444;"><span style="background-color: white; font-size: 15px;">Test yang terintegrasi dimana besar, lambat, dan unit test dilakukan pada keseluruhan aplikasi. </span></span></li></ul></div><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; user-select: text; vertical-align: baseline; z-index: 0;"><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px; font-weight: 400;">Dalam contoh ini dilakukan unit test sekala kecil pada bagian fungsi yang baru dibuat. Langkah yang dilakukan adalah:</span></span></h3><div><ul style="text-align: left;"><li><span style="color: #444444;"><span style="background-color: white; font-size: 15px;">Edit file #accounts/test.py </span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">vim accounts/tests.py</span></span></div><ul style="text-align: left;"><li><span style="background-color: white; color: #444444; font-size: 15px;">Dan masukan kode di file #accounts/test.py:</span></li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div><span style="color: #6a9955;">#accounts/test.py</span></div><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">contrib</span>.<span style="color: #4ec9b0;">auth</span> <span style="color: #c586c0;">import</span> <span style="color: #dcdcaa;">get_user_model</span></div><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">test</span> <span style="color: #c586c0;">import</span> <span style="color: #4ec9b0;">TestCase</span></div><br /><div><span style="color: #569cd6;">class</span> <span style="color: #4ec9b0;">CustomUserTests</span>(<span style="color: #4ec9b0;">TestCase</span>):</div><div> <span style="color: #569cd6;">def</span> <span style="color: #dcdcaa;">test_create_user</span>(<span style="color: #9cdcfe;">self</span>):</div><div> <span style="color: #9cdcfe;">User</span> = <span style="color: #dcdcaa;">get_user_model</span>()</div><div> <span style="color: #9cdcfe;">user</span> = <span style="color: #9cdcfe;">User</span>.<span style="color: #9cdcfe;">objects</span>.create_user(<span style="color: #9cdcfe;">username</span>=<span style="color: #ce9178;">"wawanhn"</span>, <span style="color: #9cdcfe;">email</span>=<span style="color: #ce9178;">"wawanhn@email.com"</span>, <span style="color: #9cdcfe;">password</span>=<span style="color: #ce9178;">"testpass123"</span>)</div><br /><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertEqual</span>(<span style="color: #9cdcfe;">user</span>.username, <span style="color: #ce9178;">"wawanhn"</span>)</div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertEqual</span>(<span style="color: #9cdcfe;">user</span>.email, <span style="color: #ce9178;">"wawanhn@email.com"</span>)</div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertTrue</span>(<span style="color: #9cdcfe;">user</span>.is_active)</div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertFalse</span>(<span style="color: #9cdcfe;">user</span>.is_staff)</div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertFalse</span>(<span style="color: #9cdcfe;">user</span>.is_superuser)</div><br /><div> <span style="color: #569cd6;">def</span> <span style="color: #dcdcaa;">test_create_superuser</span>(<span style="color: #9cdcfe;">self</span>):</div><div> <span style="color: #9cdcfe;">User</span> = <span style="color: #dcdcaa;">get_user_model</span>()</div><div> <span style="color: #9cdcfe;">admin_user</span> = <span style="color: #9cdcfe;">User</span>.<span style="color: #9cdcfe;">objects</span>.create_superuser(<span style="color: #9cdcfe;">username</span>=<span style="color: #ce9178;">"superadmin"</span>, <span style="color: #9cdcfe;">email</span>=<span style="color: #ce9178;">"superadmin@email.com"</span>, <span style="color: #9cdcfe;">password</span>=<span style="color: #ce9178;">"testpass123"</span>)</div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertEqual</span>(<span style="color: #9cdcfe;">admin_user</span>.username, <span style="color: #ce9178;">"superadmin"</span>)</div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertEqual</span>(<span style="color: #9cdcfe;">admin_user</span>.email, <span style="color: #ce9178;">"superadmin@email.com"</span>)</div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertTrue</span>(<span style="color: #9cdcfe;">admin_user</span>.is_active)</div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertTrue</span>(<span style="color: #9cdcfe;">admin_user</span>.is_staff)</div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertTrue</span>(<span style="color: #9cdcfe;">admin_user</span>.is_superuser)</div></div></div><ul style="text-align: left;"><li><span style="color: #444444;"><span style="background-color: white; font-size: 15px;">Lakukan test</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">docker-compose exec web python manage.py test</span></span></div><ul style="text-align: left;"><li><span style="color: #444444;"><span style="background-color: white; font-size: 15px;">Jika berhasil maka akan menghasilkan output:</span></span></li></ul><div><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; user-select: text; vertical-align: baseline; z-index: 0;"><span style="font-weight: normal;">output:</span></h3></div><div><span style="font-family: courier;"><div>Found 2 test(s).</div><div>Creating test database for alias 'default'...</div><div>System check identified no issues (0 silenced).</div><div>..</div><div>----------------------------------------------------------------------</div><div>Ran 2 tests in 0.494s</div><div><br /></div><div>OK</div><div>Destroying test database for alias 'default'...</div><div><br /></div><div><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-family: Ubuntu, sans-serif; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; text-transform: capitalize; user-select: text; vertical-align: baseline; z-index: 0;"><span style="font-size: medium;">Membuat Homepage Aplikasi</span></h3></div></span></div><ul style="text-align: left;"><li><span style="color: #444444;"><span style="background-color: white; font-size: 15px;">Buat aplikasi pages</span></span></li></ul><div><span style="color: #444444; font-family: courier;"><span style="background-color: #04ff00; font-size: 15px;">docker-compose exec web python manage.py startapp pages</span></span></div><ul style="text-align: left;"><li><span style="color: #444444;"><span style="background-color: white; font-size: 15px;">Tambahkan pages di file #django_project/settings.py</span></span></li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div><span style="color: #4fc1ff;">INSTALLED_APPS</span> = [</div><div> <span style="color: #ce9178;">'django.contrib.admin'</span>,</div><div> <span style="color: #ce9178;">'django.contrib.auth'</span>,</div><div> <span style="color: #ce9178;">'django.contrib.contenttypes'</span>,</div><div> <span style="color: #ce9178;">'django.contrib.sessions'</span>,</div><div> <span style="color: #ce9178;">'django.contrib.messages'</span>,</div><div> <span style="color: #ce9178;">'django.contrib.staticfiles'</span>,</div><div> <span style="color: #ce9178;">'accounts.apps.AccountsConfig'</span>,</div><div> <span style="color: #ce9178;">'pages.apps.PagesConfig'</span>, #tambahan baru</div><div>]</div></div></div><ul style="text-align: left;"><li><span style="color: #444444;"><span style="background-color: white; font-size: 15px;">Tentukan BASE Directory dan templates di </span></span>file #django_project/settings.py</li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div><span style="color: #4fc1ff;">TEMPLATES</span> = [</div><div> {</div><div><span style="color: #9cdcfe;"> </span><span style="color: #ce9178;">'BACKEND'</span>: <span style="color: #ce9178;">'django.template.backends.django.DjangoTemplates'</span>,</div><div><span style="color: #9cdcfe;"> </span><span style="color: #ce9178;">'DIRS'</span>: [<span style="color: #4fc1ff;">BASE_DIR</span>/<span style="color: #ce9178;">'templates'</span>], #tambahkan di baris ini</div><div><span style="color: #9cdcfe;"> </span><span style="color: #ce9178;">'APP_DIRS'</span>: <span style="color: #569cd6;">True</span>,</div><div><span style="color: #9cdcfe;"> </span><span style="color: #ce9178;">'OPTIONS'</span>: {</div><div><span style="color: #9cdcfe;"> </span><span style="color: #ce9178;">'context_processors'</span>: [</div><div> <span style="color: #ce9178;">'django.template.context_processors.debug'</span>,</div><div> <span style="color: #ce9178;">'django.template.context_processors.request'</span>,</div><div> <span style="color: #ce9178;">'django.contrib.auth.context_processors.auth'</span>,</div><div> <span style="color: #ce9178;">'django.contrib.messages.context_processors.messages'</span>,</div><div> ],</div><div> },</div><div> },</div><div>]</div></div></div><ul style="text-align: left;"><li>Buat folder templates di Direktory kerja dengan nama templates</li></ul><div><span style="background-color: #04ff00; font-family: courier;">mkdir templates</span></div><ul style="text-align: left;"><li>Buat file html di folder templates dengan nama _base.html dan home.html</li></ul><div><span style="background-color: #04ff00; font-family: courier;">vim templates/_base.html</span></div><div><span style="background-color: #04ff00; font-family: courier;">vim templates/home.html</span></div><ul style="text-align: left;"><li>File _base.html cara penulisan didepan kata base ada underscore ini hanya merupakan kebiasaan yang menunjukan bahwa file ini akan digunakan/extends untuk file html di seluruh aplikasi (diwariskan). Buat kerangka standar file html untuk file #templates/_base.html</li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div><span style="color: #6a9955;"><!-- templates/_base.html --></span></div><div><span style="color: grey;"><!</span>DOCTYPE html<span style="color: grey;">></span></div><div><span style="color: grey;"><</span><span style="color: #569cd6;">html</span><span style="color: grey;">></span></div><div> <span style="color: grey;"><</span><span style="color: #569cd6;">head</span><span style="color: grey;">></span></div><div> <span style="color: grey;"><</span><span style="color: #569cd6;">meta</span> <span style="color: #9cdcfe;">charset</span>=<span style="color: #ce9178;">'utf-8'</span><span style="color: grey;">></span></div><div> <span style="color: grey;"><</span><span style="color: #569cd6;">title</span><span style="color: grey;">></span><span style="color: #569cd6;">{% </span><span style="color: #c586c0;">block</span><span style="color: #569cd6;"> </span><span style="color: #ce9178;">title</span><span style="color: #569cd6;"> %}</span> Toko Buku <span style="color: #569cd6;">{% </span><span style="color: #c586c0;">endblock</span><span style="color: #569cd6;"> </span><span style="color: #ce9178;">title</span><span style="color: #569cd6;"> %}</span><span style="color: grey;"></</span><span style="color: #569cd6;">title</span><span style="color: grey;">></span></div><div> <span style="color: grey;"></</span><span style="color: #569cd6;">head</span><span style="color: grey;">></span></div><div> <span style="color: grey;"><</span><span style="color: #569cd6;">body</span><span style="color: grey;">></span></div><div> <span style="color: grey;"><</span><span style="color: #569cd6;">div</span> <span style="color: #9cdcfe;">class</span>=<span style="color: #ce9178;">'container'</span><span style="color: grey;">></span></div><div> <span style="color: #569cd6;">{% </span><span style="color: #c586c0;">block</span><span style="color: #569cd6;"> </span><span style="color: #ce9178;">content</span><span style="color: #569cd6;"> %}</span></div><br /><div> <span style="color: #569cd6;">{% </span><span style="color: #c586c0;">endblock</span><span style="color: #569cd6;"> </span><span style="color: #ce9178;">content</span><span style="color: #569cd6;"> %}</span></div><div> <span style="color: grey;"></</span><span style="color: #569cd6;">div</span><span style="color: grey;">></span></div><div> <span style="color: grey;"></</span><span style="color: #569cd6;">body</span><span style="color: grey;">></span></div><div><span style="color: grey;"></</span><span style="color: #569cd6;">html</span><span style="color: grey;">></span></div><br /></div></div><ul style="text-align: left;"><li>Masukan kode program pada file #templates/home.html</li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div><span style="color: #6a9955;"><!-- templates/home.html --></span></div><div><span style="color: #569cd6;">{% </span><span style="color: #c586c0;">extends</span><span style="color: #569cd6;"> </span><span style="color: #ce9178;">'_base.html'</span><span style="color: #569cd6;"> %}</span></div><br /><div><span style="color: #569cd6;">{% </span><span style="color: #c586c0;">block</span><span style="color: #569cd6;"> </span><span style="color: #ce9178;">title</span><span style="color: #569cd6;"> %}</span> Home <span style="color: #569cd6;">{% </span><span style="color: #c586c0;">endblock</span><span style="color: #569cd6;"> </span><span style="color: #ce9178;">title</span><span style="color: #569cd6;"> %}</span></div><br /><div><span style="color: #569cd6;">{% </span><span style="color: #c586c0;">block</span><span style="color: #569cd6;"> </span><span style="color: #ce9178;">content</span><span style="color: #569cd6;"> %}</span></div><div> <span style="color: grey;"><</span><span style="color: #569cd6;">h1</span><span style="color: grey;">></span>Tihs is our home page.<span style="color: grey;"></</span><span style="color: #569cd6;">h1</span><span style="color: grey;">></span></div><div><span style="color: #569cd6;">{% </span><span style="color: #c586c0;">endblock</span><span style="color: #569cd6;"> </span><span style="color: #ce9178;">content</span><span style="color: #569cd6;"> %}</span></div><br /></div></div><ul style="text-align: left;"><li>Selanjutnya buat routing alamat web index atau link ke halaman saat pertama kali aplikasi dibuka, tambahkan navigasi ke halaman utama dengan mengedit file #django_project/urls.py</li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">contrib</span> <span style="color: #c586c0;">import</span> <span style="color: #4ec9b0;">admin</span></div><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">urls</span> <span style="color: #c586c0;">import</span> <span style="color: #dcdcaa;">path</span>, <span style="color: #dcdcaa;">include </span><span style="color: #6a9955;">#tambahkan ini</span></div><br /><div><span style="color: #9cdcfe;">urlpatterns</span> = [</div><div> <span style="color: #dcdcaa;">path</span>(<span style="color: #ce9178;">'admin/'</span>, <span style="color: #4ec9b0;">admin</span>.<span style="color: #9cdcfe;">site</span>.urls),</div><div> <span style="color: #dcdcaa;">path</span>(<span style="color: #ce9178;">''</span>, include(<span style="color: #ce9178;">'pages.urls'</span>)), <span style="color: #6a9955;">#tambahkan ini</span></div><div>]</div></div></div><ul style="text-align: left;"><li>Buat routing di aplikasi pages, yaitu file #pages/urls.py</li></ul><div><span style="background-color: #04ff00; font-family: courier;">vim pages/urls.py</span></div><ul style="text-align: left;"><li>Tambahkan kode:</li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div><span style="color: #6a9955;">#pages/urls.py</span></div><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">urls</span> <span style="color: #c586c0;">import</span> <span style="color: #dcdcaa;">path</span></div><div><span style="color: #c586c0;">from</span> .<span style="color: #4ec9b0;">views</span> <span style="color: #c586c0;">import</span> HomePageView</div><br /><div><span style="color: #9cdcfe;">urlpatterns</span> = [</div><div> <span style="color: #dcdcaa;">path</span>(<span style="color: #ce9178;">''</span>, HomePageView.as_view(), <span style="color: #9cdcfe;">name</span>=<span style="color: #ce9178;">'home'</span>),</div><div> ]</div></div></div><ul style="text-align: left;"><li>Edit tampilan view di file #pages/views.py</li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div><span style="color: #6a9955;">#pages/views.py</span></div><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">shortcuts</span> <span style="color: #c586c0;">import</span> <span style="color: #dcdcaa;">render</span></div><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">views</span>.<span style="color: #4ec9b0;">generic</span> <span style="color: #c586c0;">import</span> <span style="color: #4ec9b0;">TemplateView</span></div><br /><div><span style="color: #6a9955;"># Create your views here.</span></div><div><span style="color: #569cd6;">class</span> <span style="color: #4ec9b0;">HomePageView</span>(<span style="color: #4ec9b0;">TemplateView</span>):</div><div> <span style="color: #9cdcfe;">template_name</span> = <span style="color: #ce9178;">'home.html'</span></div></div></div><ul style="text-align: left;"><li>Untuk melihat perubahan karena sudah menambahkan app pages dan routing, matikan docker dan jalankan lagi</li></ul><div><span style="background-color: #04ff00; font-family: courier;">docker-compose down</span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><span style="background-color: #04ff00; font-family: courier;">docker compose up -d </span></div><div><br /></div><ul style="text-align: left;"><li>Buka alamat http://127.0.0.1:8000/ maka akan menampilkan tampilan halaman home.html</li></ul><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/QhvvLfnez1rwMsCIYYZlcaR58ZoTDqD9FJ90R4Tcax94aKpx8t_Afr_Yxuaa1QBrexjRM19DybTOAnk=s400" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="318" data-original-width="400" height="318" src="https://1.bp.blogspot.com/QhvvLfnez1rwMsCIYYZlcaR58ZoTDqD9FJ90R4Tcax94aKpx8t_Afr_Yxuaa1QBrexjRM19DybTOAnk=w400-h318" width="400" /></a></div><br /><div><br /></div><div><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-family: Ubuntu, sans-serif; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; text-transform: capitalize; user-select: text; vertical-align: baseline; z-index: 0;"><span style="font-size: medium;">Membuat Test untuk app pages</span></h3></div><div><span style="font-size: medium;"><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-family: Ubuntu, sans-serif; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; text-transform: capitalize; user-select: text; vertical-align: baseline; z-index: 0;"><span style="font-size: medium;">Test Untuk Homepages</span></h3></span></div><ul style="text-align: left;"><li>Lakukan test dengan menggunakna Django SimpleTest</li></ul><div><span style="background-color: #04ff00; font-family: courier;">vim pages/tests.py</span></div><ul style="text-align: left;"><li>Buka file #pages/test.py dan masukan kode:</li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div><span style="color: #6a9955;">#pages/tests.py</span></div><div><span style="color: #6a9955;">#from django.test import TestCase</span></div><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">test</span> <span style="color: #c586c0;">import</span> <span style="color: #4ec9b0;">SimpleTestCase</span></div><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">urls</span> <span style="color: #c586c0;">import</span> <span style="color: #dcdcaa;">reverse</span></div><br /><div><span style="color: #6a9955;"># Create your tests here.</span></div><div><span style="color: #569cd6;">class</span> <span style="color: #4ec9b0;">HomepageTests</span>(<span style="color: #4ec9b0;">SimpleTestCase</span>):</div><div> <span style="color: #569cd6;">def</span> <span style="color: #dcdcaa;">test_url_exists_at_correct_location</span>(<span style="color: #9cdcfe;">self</span>):</div><div> <span style="color: #9cdcfe;">response</span> = <span style="color: #9cdcfe;">self</span>.<span style="color: #9cdcfe;">client</span>.<span style="color: #dcdcaa;">get</span>(<span style="color: #ce9178;">'/'</span>) </div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertEqual</span>(<span style="color: #9cdcfe;">response</span>.<span style="color: #9cdcfe;">status_code</span>, <span style="color: #b5cea8;">200</span>)</div><br /><div> <span style="color: #569cd6;">def</span> <span style="color: #dcdcaa;">test_homepage_url_name</span>(<span style="color: #9cdcfe;">self</span>):</div><div> <span style="color: #9cdcfe;">response</span> = <span style="color: #9cdcfe;">self</span>.<span style="color: #9cdcfe;">client</span>.<span style="color: #dcdcaa;">get</span>(<span style="color: #dcdcaa;">reverse</span>(<span style="color: #ce9178;">'home'</span>)) </div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertEqual</span>(<span style="color: #9cdcfe;">response</span>.<span style="color: #9cdcfe;">status_code</span>, <span style="color: #b5cea8;">200</span>)</div></div></div><ul style="text-align: left;"><li>Lakukan simpletest, dengan kode:</li></ul><div><span style="background-color: #04ff00; font-family: courier;">docker-compose exec web python manage.py test</span></div><ul style="text-align: left;"><li>jika berhasil maka akan menghasilkan output:</li></ul><div><div><span style="font-family: courier;">Found 4 test(s).</span></div><div><span style="font-family: courier;">Creating test database for alias 'default'...</span></div><div><span style="font-family: courier;">System check identified no issues (0 silenced).</span></div><div><span style="font-family: courier;">....</span></div><div><span style="font-family: courier;">----------------------------------------------------------------------</span></div><div><span style="font-family: courier;">Ran 4 tests in 0.554s</span></div><div><span style="font-family: courier;"><br /></span></div><div><span style="font-family: courier;">OK</span></div><div><span style="font-family: courier;">Destroying test database for alias 'default'...</span></div></div><ul style="text-align: left;"><li>Dari info diatas dilakukan 4 tes karena terdapat 2 tes sebelumnya untuk Custom User Model. Dan jika menginginkan test hanya untuk untuk aplikasi pages maka perintahnya:</li></ul><div><span style="background-color: #04ff00; font-family: courier;">docker-compose exec web python manage.py test pages</span></div><ul style="text-align: left;"><li>Dan hasil dari perintah tersebut:</li></ul><div><div><span style="font-family: courier;">Found 2 test(s).</span></div><div><span style="font-family: courier;">System check identified no issues (0 silenced).</span></div><div><span style="font-family: courier;">..</span></div><div><span style="font-family: courier;">----------------------------------------------------------------------</span></div><div><span style="font-family: courier;">Ran 2 tests in 0.025s</span></div><div><span style="font-family: courier;"><br /></span></div><div><span style="font-family: courier;">OK</span></div></div><ul style="text-align: left;"><li>Dari hasil test diatas tidak melibatkan akses ke database.</li></ul><div><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-family: Ubuntu, sans-serif; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; text-transform: capitalize; user-select: text; vertical-align: baseline; z-index: 0;"><span style="font-size: medium;">Test Untuk Templates</span></h3></div><ul style="text-align: left;"><li>Untuk test template menggunakan fungsi <span style="background-color: #fcff01; font-family: Consolas, "Courier New", monospace; font-size: 14px; white-space: pre;">assertTemplateUsed</span> tambahkan kode di file #pages/tests.py</li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div><span style="color: #6a9955;">#pages/tests.py</span></div><div><span style="color: #6a9955;">#from django.test import TestCase</span></div><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">test</span> <span style="color: #c586c0;">import</span> <span style="color: #4ec9b0;">SimpleTestCase</span></div><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">urls</span> <span style="color: #c586c0;">import</span> <span style="color: #dcdcaa;">reverse</span></div><br /><div><span style="color: #6a9955;"># Create your tests here.</span></div><div><span style="color: #569cd6;">class</span> <span style="color: #4ec9b0;">HomepageTests</span>(<span style="color: #4ec9b0;">SimpleTestCase</span>):</div><div> <span style="color: #569cd6;">def</span> <span style="color: #dcdcaa;">test_url_exists_at_correct_location</span>(<span style="color: #9cdcfe;">self</span>):</div><div> <span style="color: #9cdcfe;">response</span> = <span style="color: #9cdcfe;">self</span>.<span style="color: #9cdcfe;">client</span>.<span style="color: #dcdcaa;">get</span>(<span style="color: #ce9178;">'/'</span>) </div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertEqual</span>(<span style="color: #9cdcfe;">response</span>.<span style="color: #9cdcfe;">status_code</span>, <span style="color: #b5cea8;">200</span>)</div><br /><div> <span style="color: #569cd6;">def</span> <span style="color: #dcdcaa;">test_homepage_url_name</span>(<span style="color: #9cdcfe;">self</span>):</div><div> <span style="color: #9cdcfe;">response</span> = <span style="color: #9cdcfe;">self</span>.<span style="color: #9cdcfe;">client</span>.<span style="color: #dcdcaa;">get</span>(<span style="color: #dcdcaa;">reverse</span>(<span style="color: #ce9178;">'home'</span>)) </div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertEqual</span>(<span style="color: #9cdcfe;">response</span>.<span style="color: #9cdcfe;">status_code</span>, <span style="color: #b5cea8;">200</span>)</div><br /><div> <span style="color: #569cd6;">def</span> <span style="color: #dcdcaa;">test_homepage_template</span>(<span style="color: #9cdcfe;">self</span>): #tambahan baru</div><div> <span style="color: #9cdcfe;">response</span> = <span style="color: #9cdcfe;">self</span>.<span style="color: #9cdcfe;">client</span>.<span style="color: #dcdcaa;">get</span>(<span style="color: #ce9178;">'/'</span>)</div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertTemplateUsed</span>(<span style="color: #9cdcfe;">response</span>, <span style="color: #ce9178;">'home.html'</span>)</div></div></div><ul style="text-align: left;"><li>Lakukan test, dan jika berhasil akan menghasilkan ouput <b>Found 3 test</b> dan <b>no issues</b></li></ul><div><span style="background-color: #04ff00; font-family: courier;">docker-compose exec web python manage.py test pages</span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-family: Ubuntu, sans-serif; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; text-transform: capitalize; user-select: text; vertical-align: baseline; z-index: 0;"><span style="font-size: medium;">Test Untuk Html, dll</span></h3></div><ul style="text-align: left;"><li>Keseluruhan kode test app page di file #pages/tests.py</li></ul><div><div style="background-color: #1e1e1e; color: #d4d4d4; font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;"><div><span style="color: #6a9955;">#pages/tests.py</span></div><div><span style="color: #6a9955;">#from django.test import TestCase</span></div><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">test</span> <span style="color: #c586c0;">import</span> <span style="color: #4ec9b0;">SimpleTestCase</span></div><div><span style="color: #c586c0;">from</span> <span style="color: #4ec9b0;">django</span>.<span style="color: #4ec9b0;">urls</span> <span style="color: #c586c0;">import</span> <span style="color: #dcdcaa;">reverse</span>, <span style="color: #dcdcaa;">resolve</span></div><div><span style="color: #c586c0;">from</span> .<span style="color: #4ec9b0;">views</span> <span style="color: #c586c0;">import</span> <span style="color: #4ec9b0;">HomePageView</span></div><br /><div><span style="color: #6a9955;"># Create your tests here.</span></div><div><span style="color: #569cd6;">class</span> <span style="color: #4ec9b0;">HomepageTests</span>(<span style="color: #4ec9b0;">SimpleTestCase</span>):</div><div> <span style="color: #569cd6;">def</span> <span style="color: #dcdcaa;">setUp</span>(<span style="color: #9cdcfe;">self</span>):</div><div> <span style="color: #9cdcfe;">url</span> = <span style="color: #dcdcaa;">reverse</span>(<span style="color: #ce9178;">'home'</span>)</div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #9cdcfe;">response</span> = <span style="color: #9cdcfe;">self</span>.<span style="color: #9cdcfe;">client</span>.<span style="color: #dcdcaa;">get</span>(<span style="color: #9cdcfe;">url</span>)</div><br /><div> <span style="color: #569cd6;">def</span> <span style="color: #dcdcaa;">test_url_exists_at_correct_location</span>(<span style="color: #9cdcfe;">self</span>):</div><div> <span style="color: #6a9955;">#response = self.client.get('/') </span></div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertEqual</span>(<span style="color: #9cdcfe;">self</span>.<span style="color: #9cdcfe;">response</span>.<span style="color: #9cdcfe;">status_code</span>, <span style="color: #b5cea8;">200</span>)</div><br /><div> <span style="color: #569cd6;">def</span> <span style="color: #dcdcaa;">test_homepage_url_name</span>(<span style="color: #9cdcfe;">self</span>):</div><div> <span style="color: #9cdcfe;">response</span> = <span style="color: #9cdcfe;">self</span>.<span style="color: #9cdcfe;">client</span>.<span style="color: #dcdcaa;">get</span>(<span style="color: #dcdcaa;">reverse</span>(<span style="color: #ce9178;">'home'</span>)) </div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertEqual</span>(<span style="color: #9cdcfe;">response</span>.<span style="color: #9cdcfe;">status_code</span>, <span style="color: #b5cea8;">200</span>)</div><br /><div> <span style="color: #569cd6;">def</span> <span style="color: #dcdcaa;">test_homepage_template</span>(<span style="color: #9cdcfe;">self</span>):</div><div> <span style="color: #6a9955;">#response = self.client.get('/')</span></div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertTemplateUsed</span>(<span style="color: #9cdcfe;">self</span>.<span style="color: #9cdcfe;">response</span>, <span style="color: #ce9178;">'home.html'</span>)</div><br /><div> <span style="color: #569cd6;">def</span> <span style="color: #dcdcaa;">test_homepage_contains_correct_html</span>(<span style="color: #9cdcfe;">self</span>):</div><div> <span style="color: #6a9955;">#response = self.client.get('/')</span></div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertContains</span>(<span style="color: #9cdcfe;">self</span>.<span style="color: #9cdcfe;">response</span>, <span style="color: #ce9178;">'home page'</span>)</div><br /><div> <span style="color: #569cd6;">def</span> <span style="color: #dcdcaa;">test_homepage_does_not_contain_incorect_html</span>(<span style="color: #9cdcfe;">self</span>):</div><div> <span style="color: #6a9955;">#response = self.client.get('/')</span></div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertNotContains</span>(<span style="color: #9cdcfe;">self</span>.<span style="color: #9cdcfe;">response</span>,<span style="color: #ce9178;">'Hi there! Should not be on the page.'</span>)</div><br /><div> <span style="color: #569cd6;">def</span> <span style="color: #dcdcaa;">test_homepage_url_resolves_homepageview</span>(<span style="color: #9cdcfe;">self</span>):</div><div> <span style="color: #9cdcfe;">view</span> = <span style="color: #dcdcaa;">resolve</span>(<span style="color: #ce9178;">'/'</span>)</div><div> <span style="color: #9cdcfe;">self</span>.<span style="color: #dcdcaa;">assertEqual</span>(<span style="color: #9cdcfe;">view</span>.<span style="color: #9cdcfe;">func</span>.<span style="color: #9cdcfe;">__name__</span>,<span style="color: #4ec9b0;">HomePageView</span>.<span style="color: #dcdcaa;">as_view</span>().__name__)</div><br /></div></div><ul style="text-align: left;"><li>Lakukan test:</li></ul><div><span style="background-color: #04ff00; font-family: courier;">docker-compose exec web python manage.py test pages</span></div><ul style="text-align: left;"><li>Jika berhasil tidak ada error maka akan menghasilkan output</li></ul><div><div><span style="font-family: courier;">Found 6 test(s).</span></div><div><span style="font-family: courier;">System check identified no issues (0 silenced).</span></div><div><span style="font-family: courier;">......</span></div><div><span style="font-family: courier;">----------------------------------------------------------------------</span></div><div><span style="font-family: courier;">Ran 6 tests in 0.037s</span></div><div><span style="font-family: courier;"><br /></span></div><div><span style="font-family: courier;">OK</span></div></div><ul style="text-align: left;"><li>asda</li><li>asdas</li><li>s</li></ul></div><h3 style="border-bottom-color: rgb(238, 238, 238); border-image: initial; border-left-color: initial; border-right-color: initial; border-style: none none solid; border-top-color: initial; border-width: 0px 0px 1px; cursor: auto; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: 1.3; margin: 0px; padding: 15px; position: relative; user-select: text; vertical-align: baseline; z-index: 0;"><span face="Muli, sans-serif" style="color: #444444;"><span style="background-color: white; font-size: 15px; font-weight: 400;">Demkian langkah-langkah membuat aplikasi Django dan PostgreSQL dengan menggunakan Docker sederhana, semoga menambah pengetahuan. @wawanhn</span></span></h3></div>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-75609621618971354772022-10-09T14:08:00.007+07:002022-10-09T21:43:08.983+07:00Membuat Aplikasi Django dan PostgreSQL dengan menggunakan Docker cara 1<p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://img1.pngdownload.id/20180629/kz/kisspng-docker-logo-kubernetes-software-deployment-engineer-logo-5b3616d6abce13.6733351915302714467037.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="260" data-original-width="260" height="260" src="https://img1.pngdownload.id/20180629/kz/kisspng-docker-logo-kubernetes-software-deployment-engineer-logo-5b3616d6abce13.6733351915302714467037.jpg" width="260" /></a></div><span face=""Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif" style="background-color: white; color: #555555;">Docker adalah layanan yang menyediakan kemampuan untuk mengemas dan menjalankan sebuah aplikasi dalam sebuah lingkungan terisolasi yang disebut dengan container. Dengan adanya isolasi dan keamanan yang memadai memungkinkan kamu untuk menjalankan banyak container di waktu yang bersamaan pada host tertentu. </span><p></p><p><span face="Muli, sans-serif" style="background-color: white; color: #1d1e20; letter-spacing: 0.3px;">Docker adalah software open-source yang digunakan untuk meluncurkan (deploy) aplikasi di dalam container virtual. Dengan container virtual ini (containerization), aplikasi bisa dijalankan secara terisolasi di environment yang kompleks sehingga tidak menimbulkan masalah pada environment lainnya.</span></p><p style="background-color: white; box-sizing: border-box; color: #555555; cursor: auto; font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif; line-height: 1.6em; margin: 0px 0px 1.6em; user-select: text;"><span style="box-sizing: border-box; user-select: text;">Docker ini diperkenalkan pada tahun 2013 oleh Solomon Hykes pada acara PyCon. Beberapa bulan setelahnya docker secara resmi diluncurkan, tepatnya pada tahun 2014.</span></p><h2 id="h-cara-kerja-docker" style="box-sizing: border-box; color: #2f1c6a; cursor: auto; font-family: Muli, sans-serif; line-height: 52.8px; margin-bottom: 30px; margin-top: 40px; user-select: text; word-break: break-word;"><span style="font-size: small;">Cara Kerja Docker<span class="ez-toc-section-end" style="box-sizing: border-box; user-select: text;"></span></span></h2><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">Cara kerja Docker adalah dengan menciptakan sebuah ruang isolasi untuk meluncurkan aplikasi atau layanan. Ruang isolasi ini disebut Container, seperti ‘wadah’ yang akan menampung suatu benda agar tidak tumpah ke area lain.</p><h3 id="h-penjelasan-singkat-tentang-container-docker" style="box-sizing: border-box; color: #2f1c6a; cursor: auto; font-family: Muli, sans-serif; line-height: 38.4px; margin-bottom: 15px; margin-top: 25px; user-select: text; word-break: break-word;"><span style="font-size: small;">Penjelasan Singkat tentang Container Docker</span></h3><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;"><a data-wpel-link="internal" href="https://www.hostinger.co.id/tutorial/docker-container" style="box-sizing: border-box; color: #6747c7; font-weight: 700; text-decoration: unset; user-select: text;">Docker container adalah</a> sebuah paket software yang berisi semua dependensi yang diperlukan untuk menjalankan aplikasi tertentu. Semua konfigurasi dan instruksi untuk memulai atau menghentikan container diperintahkan oleh sebuah komponen yang disebut ‘image Docker’.</p><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">Container ini menghindarkan user dari masalah kompatibilitas yang mungkin terjadi ketika menjalankan aplikasi di beberapa sistem yang berbeda. Sebab, dengan container ini, software akan berjalan dengan cara yang sama di environment mana pun.</p><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">Kapan pun image dijalankan user, container baru akan dibuat.</p><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">Pengelolaan container juga mudah berkat bantuan Docker <a data-wpel-link="internal" href="https://www.hostinger.co.id/tutorial/api-adalah" style="box-sizing: border-box; color: #6747c7; font-weight: 700; text-decoration: unset; user-select: text;">API</a> atau command line interface (CLI). Apabila beberapa container diperlukan, user bisa mengontrolnya dengan Docker compose tool.</p><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">Selain container yang baru saja dibahas, arsitektur Docker terdiri dari empat komponen utama, yaitu:</p><ul style="box-sizing: border-box; color: #36344d; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 20px; margin-left: 4rem; margin-top: 0px; padding-left: 0px;"><li style="box-sizing: border-box; letter-spacing: 0.3px; line-height: 32px; list-style-type: inherit; margin-bottom: 8px;"><strong style="box-sizing: border-box;">Client Docker</strong> – komponen utama untuk membuat, mengelola, dan menjalankan aplikasi dalam container. Client Docker adalah metode utama untuk mengontrol server Docker melalui CLI seperti Command Prompt (Windows) atau Terminal (macOS, Linux).</li><li style="box-sizing: border-box; letter-spacing: 0.3px; line-height: 32px; list-style-type: inherit; margin-bottom: 8px;"><strong style="box-sizing: border-box;">Server <strong style="box-sizing: border-box;">Docker</strong></strong> – juga disebut daemon Docker. Server Docker menunggu permintaan REST API yang dibuat oleh client Docker serta mengelola image dan container.</li><li style="box-sizing: border-box; letter-spacing: 0.3px; line-height: 32px; list-style-type: inherit; margin-bottom: 8px;"><strong style="box-sizing: border-box;">Image <strong style="box-sizing: border-box;">Docker</strong></strong> – komponen yang memerintahkan server Docker terkait persyaratan tentang cara container Docker dibuat. Image bisa didownload dari website seperti <a data-wpel-link="external" href="https://hub.docker.com/" rel="noreferrer noopener nofollow external" style="box-sizing: border-box; color: #6747c7; font-weight: 700; text-decoration: unset; user-select: text;" target="_blank">Docker Hub</a>. Anda juga bisa membuat custom image, yaitu dengan membuat Dockerfile dan meneruskannya ke server. Perlu diketahui bahwa Docker tidak menghapus image yang tidak digunakan, jadi user harus menghapus data image sendiri agar tidak menumpuk.</li><li style="box-sizing: border-box; letter-spacing: 0.3px; line-height: 32px; list-style-type: inherit; margin-bottom: 8px;"><strong style="box-sizing: border-box;">Registry</strong> <strong style="box-sizing: border-box;">Docker </strong>– aplikasi sisi server open-source yang digunakan untuk menghosting dan mendistribusikan image Docker. Registry sangat berguna untuk menyimpan image secara lokal dan mengelolanya sepenuhnya. Atau, user bisa mengakses Docker Hub yang tadi disebutkan, yang merupakan repositori image Docker terbesar di dunia.</li></ul><h2 style="box-sizing: border-box; color: #2f1c6a; cursor: auto; font-family: Muli, sans-serif; line-height: 52.8px; margin-bottom: 30px; margin-top: 40px; user-select: text; word-break: break-word;"><span style="font-size: small;"><span class="ez-toc-section" id="Fungsi_Docker" style="box-sizing: border-box; user-select: text;"></span>Fungsi Docker<span class="ez-toc-section-end" style="box-sizing: border-box; user-select: text;"></span></span></h2><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">Docker memiliki banyak fungsi untuk berbagai contoh penerapan. Di bagian ini, kami akan membahas fungsi Docker dan tiga contoh umum penggunaannya.</p><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;"><strong style="box-sizing: border-box;">Mencoba Software Baru</strong></p><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">Dengan Docker, Anda bisa mencoba software baru tanpa harus menginstalnya secara manual. Docker juga berguna kalau Anda memerlukan software yang harus disiapkan cepat.</p><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">Sebagai contoh, proses setup server MySQL bisa memakan waktu lama. Nah, dengan Docker, Anda hanya memerlukan satu perintah melalui CLI untuk melakukannya.</p><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;"><strong style="box-sizing: border-box;">Mempelajari CLI</strong></p><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">Meskipun bisa berjalan pada semua jenis perangkat, tadinya Docker dirancang khusus untuk Linux. Jadi, kami menyarankan agar Anda mengonfigurasinya pada sistem yang berbasis Linux.</p><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">Dengan begitu, Anda pun bisa mempelajari administrasi sistem, command line interface, dan scripting lebih lanjut dengan lebih baik.</p><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;"><strong style="box-sizing: border-box;">Mengurangi Risiko Insiden</strong></p><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">Apabila terjadi kegagalan hardware, user bisa segera mengembalikan perubahan apa pun yang dibuat kalau tersedia image Docker.</p><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">User hanya perlu mengimpor backup image ke perangkat baru, lalu Docker akan membereskan sisanya. Backup image Docker juga berguna saat developer ingin melakukan rollback ke versi lama software tertentu karena adanya bug atau masalah kompatibilitas.</p><h2 style="box-sizing: border-box; color: #2f1c6a; cursor: auto; font-family: Muli, sans-serif; line-height: 52.8px; margin-bottom: 30px; margin-top: 40px; user-select: text; word-break: break-word;"><span style="font-size: small;"><span class="ez-toc-section" id="Kelebihan_dan_Kekurangan_Docker" style="box-sizing: border-box; user-select: text;"></span>Kelebihan dan Kekurangan Docker<span class="ez-toc-section-end" style="box-sizing: border-box; user-select: text;"></span></span></h2><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">Nah, setelah Anda memahami apa itu Docker dan fungsinya, sebaiknya cari tahu juga kelebihan dan kekurangannya. Meskipun memiliki banyak manfaat, Docker juga memiliki kelemahan dalam beberapa aspek. Di bagian ini, kami akan membahas kelebihan dan kekurangan software ini.</p><h3 style="box-sizing: border-box; color: #2f1c6a; cursor: auto; font-family: Muli, sans-serif; line-height: 38.4px; margin-bottom: 15px; margin-top: 25px; user-select: text; word-break: break-word;"><span style="font-size: small;"><span class="ez-toc-section" id="Kelebihan_Docker" style="box-sizing: border-box; user-select: text;"></span>Kelebihan Docker<span class="ez-toc-section-end" style="box-sizing: border-box; user-select: text;"></span></span></h3><ul style="box-sizing: border-box; color: #36344d; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 20px; margin-left: 4rem; margin-top: 0px; padding-left: 0px;"><li style="box-sizing: border-box; letter-spacing: 0.3px; line-height: 32px; list-style-type: inherit; margin-bottom: 8px;"><strong style="box-sizing: border-box;">Portabilitas</strong> – daya tarik utama Docker adalah portabilitasnya. Docker memungkinkan user membuat atau menginstal aplikasi kompleks di perangkat, dan aplikasi tersebut dijamin bisa berjalan. Docker container memiliki semua yang dibutuhkan aplikasi, hanya dengan sedikit atau bahkan tanpa input dari user.</li><li style="box-sizing: border-box; letter-spacing: 0.3px; line-height: 32px; list-style-type: inherit; margin-bottom: 8px;"><strong style="box-sizing: border-box;">Automasi</strong> – dengan bantuan <a data-wpel-link="internal" href="https://www.hostinger.co.id/tutorial/cron-job" style="box-sizing: border-box; color: #6747c7; font-weight: 700; text-decoration: unset; user-select: text;">cron job</a> dan Docker container, user bisa mengotomatiskan pekerjaan dengan mudah. Automasi membantu developer menghindari tugas yang membosankan dan repetitif, serta menghemat waktu.</li><li style="box-sizing: border-box; letter-spacing: 0.3px; line-height: 32px; list-style-type: inherit; margin-bottom: 8px;"><strong style="box-sizing: border-box;">Komunitas</strong> – Docker memiliki channel Slack khusus, forum komunitas, dan ribuan kontributor di website developer seperti StackOverflow. Terlebih lagi, ada lebih dari 9 juta image container yang dihosting di Docker Hub.</li></ul><h3 id="h-kekurangan-docker" style="box-sizing: border-box; color: #2f1c6a; cursor: auto; font-family: Muli, sans-serif; line-height: 38.4px; margin-bottom: 15px; margin-top: 25px; user-select: text; word-break: break-word;"><span style="font-size: small;"><span class="ez-toc-section" id="Kekurangan_Docker" style="box-sizing: border-box; user-select: text;"></span>Kekurangan Docker<span class="ez-toc-section-end" style="box-sizing: border-box; user-select: text;"></span></span></h3><ul style="box-sizing: border-box; color: #36344d; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 20px; margin-left: 4rem; margin-top: 0px; padding-left: 0px;"><li style="box-sizing: border-box; letter-spacing: 0.3px; line-height: 32px; list-style-type: inherit; margin-bottom: 8px;"><strong style="box-sizing: border-box;">Kecepatan</strong> – meskipun akan lebih cepat untuk menjalankan aplikasi melalui Docker container daripada di VM, Docker masih lebih lambat dibandingkan dengan menjalankan aplikasi secara native pada server fisik.</li><li style="box-sizing: border-box; letter-spacing: 0.3px; line-height: 32px; list-style-type: inherit; margin-bottom: 8px;"><strong style="box-sizing: border-box;">Kemudahan penggunaan</strong> – Docker tidak dimaksudkan untuk menjalankan aplikasi yang memerlukan Graphical User Interface (GUI). Artinya, user harus familiar dengan baris perintah/command line, dan melakukan semua tindakan di sana. Alur belajar yang rumit, keterbatasan OS tertentu, dan frekuensi update yang lumayan menjadikan Docker sulit untuk dipahami. Bahkan, ketika Anda merasa sudah memahami Docker luar dalam, masih ada orkestrasi yang perlu dipertimbangkan, yang menjadikannya makin kompleks.</li><li style="box-sizing: border-box; letter-spacing: 0.3px; line-height: 32px; list-style-type: inherit; margin-bottom: 8px;"><strong style="box-sizing: border-box;">Keamanan</strong> – Docker berjalan pada sistem operasi host, yang berarti software berbahaya apa pun yang bersembunyi di balik containernya bisa sampai ke mesin host.</li></ul><h2 id="h-docker-vs-virtual-machine" style="box-sizing: border-box; color: #2f1c6a; cursor: auto; font-family: Muli, sans-serif; line-height: 52.8px; margin-bottom: 30px; margin-top: 40px; user-select: text; word-break: break-word;"><span style="font-size: small;"><span class="ez-toc-section" id="Docker_vs_Virtual_Machine" style="box-sizing: border-box; user-select: text;"></span>Docker vs Virtual Machine<span class="ez-toc-section-end" style="box-sizing: border-box; user-select: text;"></span></span></h2><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">Meski Docker dan Virtual Machine (VM) memiliki fungsi yang serupa, ada perbedaan dari keduanya dalam hal performa, dukungan OS, dan portabilitas.</p><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">Perbedaan Docker dan Virtual Machine adalah, container Docker menggunakan OS yang sama dengan host, sedangkan VM memiliki OS tamu yang berjalan dari sistem host. Metode operasi ini memengaruhi performa, kebutuhan hardware, dan dukungan OS.</p><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">Agar lebih mudah, simak detail perbandingannya pada tabel di bawah ini.</p><figure class="wp-block-table" style="border-radius: 5px; border: 1px solid rgb(197, 205, 233); box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 10px 0px; box-sizing: border-box; color: #2f1c6a; font-family: Muli, sans-serif; height: auto; margin: 0px 0px 1em; max-width: 100%; overflow-x: auto; padding: 30px 0px 30px 10px;"><table style="border-spacing: 20px 10px; display: table-footer-group; padding: 20px; width: 718px;"><tbody style="box-sizing: border-box;"><tr style="box-sizing: border-box;"><td style="box-sizing: border-box; padding-bottom: 10px;"></td><td style="border-bottom: 1px solid rgb(244, 244, 244); box-sizing: border-box; padding-bottom: 10px;"><strong style="box-sizing: border-box;">Docker</strong></td><td style="border-bottom: 1px solid rgb(244, 244, 244); box-sizing: border-box; padding-bottom: 10px;"><strong style="box-sizing: border-box;">Virtual Machine</strong></td></tr><tr style="box-sizing: border-box;"><td style="box-sizing: border-box; padding-bottom: 10px;">OS</td><td style="border-bottom: 1px solid rgb(244, 244, 244); box-sizing: border-box; padding-bottom: 10px;">Menggunakan OS yang sama antar-container</td><td style="border-bottom: 1px solid rgb(244, 244, 244); box-sizing: border-box; padding-bottom: 10px;">OS baru untuk setiap VM</td></tr><tr style="box-sizing: border-box;"><td style="box-sizing: border-box; padding-bottom: 10px;">Keamanan</td><td style="border-bottom: 1px solid rgb(244, 244, 244); box-sizing: border-box; padding-bottom: 10px;">Kurang aman karena OS dan kernel digunakan bersama</td><td style="border-bottom: 1px solid rgb(244, 244, 244); box-sizing: border-box; padding-bottom: 10px;">Lebih aman karena VM tidak berbagi sistem operasi</td></tr><tr style="box-sizing: border-box;"><td style="box-sizing: border-box; padding-bottom: 10px;">Performa</td><td style="border-bottom: 1px solid rgb(244, 244, 244); box-sizing: border-box; padding-bottom: 10px;">Performa cepat bahkan dengan beberapa container</td><td style="border-bottom: 1px solid rgb(244, 244, 244); box-sizing: border-box; padding-bottom: 10px;">Makin banyak VM, performa makin kurang stabil</td></tr><tr style="box-sizing: border-box;"><td style="box-sizing: border-box; padding-bottom: 10px;">Waktu booting</td><td style="border-bottom: 1px solid rgb(244, 244, 244); box-sizing: border-box; padding-bottom: 10px;">Cepat (dalam hitungan detik)</td><td style="border-bottom: 1px solid rgb(244, 244, 244); box-sizing: border-box; padding-bottom: 10px;">Lambat (dalam hitungan menit)</td></tr><tr style="box-sizing: border-box;"><td style="box-sizing: border-box; padding-bottom: 10px;">Memori</td><td style="border-bottom: 1px solid rgb(244, 244, 244); box-sizing: border-box; padding-bottom: 10px;">Ringan</td><td style="border-bottom: 1px solid rgb(244, 244, 244); box-sizing: border-box; padding-bottom: 10px;">Memerlukan banyak memori</td></tr><tr style="box-sizing: border-box;"><td style="box-sizing: border-box; padding-bottom: 10px;">Kebutuhan ruang penyimpanan</td><td style="border-bottom: 1px solid rgb(244, 244, 244); box-sizing: border-box; padding-bottom: 10px;">Biasanya dalam ukuran megabyte</td><td style="border-bottom: 1px solid rgb(244, 244, 244); box-sizing: border-box; padding-bottom: 10px;">Biasanya dalam ukuran gigabyte</td></tr><tr style="box-sizing: border-box;"><td style="box-sizing: border-box; padding-bottom: 10px;">Portabilitas</td><td style="box-sizing: border-box; padding-bottom: 10px;">Mudah diluncurkan di berbagai lingkungan</td><td style="box-sizing: border-box; padding-bottom: 10px;">VM sulit di-port ke sistem lain</td></tr></tbody></table></figure><p style="background-color: white; box-sizing: border-box; color: #555555; cursor: auto; font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif; line-height: 1.6em; margin: 0px 0px 1.6em; user-select: text;"><span style="box-sizing: border-box; user-select: text;"></span></p><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">Meskipun teknologi container Docker lebih unggul pada hampir semua aspek, VM lebih aman karena sistem operasinya tetap terpisah (independen) dari hardware.</p><p style="box-sizing: border-box; color: #36344d; cursor: auto; font-family: Muli, sans-serif; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;">Oke kali ini kit acoba akan membuat aplikasi Django dan PostgreSQL di Windows dengan menggunakan Docker, langkah-langkahnya sebagai berikut:</p><p style="box-sizing: border-box; color: #36344d; cursor: auto; letter-spacing: 0.3px; line-height: 32px; margin-bottom: 0px; margin-top: 0px; padding-bottom: 20px; padding-left: 0px; user-select: text;"></p><ul style="font-family: Muli, sans-serif; text-align: left;"><li>Download aplikasi Docker <a href="https://docs.docker.com/desktop/install/windows-install/" target="_blank"><span style="font-size: large;">disini</span></a></li><li>Buka command prompt dan tempatkan di direktori yang telah ditentukan</li><li>Buat direktori kerja, misal dengan nama djangodockertest. Di command promt masukan perintah:</li></ul><div><span style="background-color: #04ff00; font-family: courier;">mkdir djangodockertest</span><br /></div><ul style="font-family: Muli, sans-serif; text-align: left;"><li>Masuk ke direktori kerja yang tadi dibuat</li></ul><div><span style="background-color: #04ff00; font-family: courier;">cd djangodockertest</span><br /></div><ul style="font-family: Muli, sans-serif; text-align: left;"><li>Buat file baru dengan nama requirements.txt untuk menyimpan daftar library atau paket aplikasi yang akan diinstal yang dibutuhkan Django. Misal dalam contoh ini saya menggunakan <b>vim </b> sebagai editor teks seperti yang ada di Linux atau Mac. Untuk mendonload aplikasi silahkan dapatkan <a href="https://www.vim.org/download.php#pc" target="_blank"><span style="font-size: large;">disini</span></a></li></ul><div><span style="background-color: #04ff00; font-family: courier;">vim requirements.txt</span><br /></div><ul style="font-family: Muli, sans-serif; text-align: left;"><li>Masukan daftar aplikasi</li></ul><div><span style="color: #fcff01; font-family: courier;"><span style="background-color: #674ea7;">Django~=4.0.0</span><br /></span></div><div><span style="color: #fcff01; font-family: courier;"><span style="background-color: #674ea7;">psycopg2-binary==2.9.3</span></span><br /></div><ul style="font-family: Muli, sans-serif; text-align: left;"><li>Buat file dengan nama Dockerfile</li></ul><div><span style="background-color: #04ff00; font-family: courier;">vim Dockerfile</span><br /></div><ul style="font-family: Muli, sans-serif; text-align: left;"><li>Masukan kode berikut</li></ul><div><span style="color: #fcff01; font-family: courier;"><span style="background-color: #674ea7;">FROM python:3</span></span></div><div><span style="color: #fcff01; font-family: courier;"><span style="background-color: #674ea7;">ENV PYTHONUNBUFFERED 1</span></span></div><div><span style="color: #fcff01; font-family: courier;"><span style="background-color: #674ea7;">WORKDIR /code/</span></span></div><div><span style="color: #fcff01; font-family: courier;"><span style="background-color: #674ea7;">COPY requirements.txt /code/</span></span></div><div><span style="color: #fcff01; font-family: courier;"><span style="background-color: #674ea7;">RUN pip install -r requirements.txt</span></span></div><div><span style="color: #fcff01; font-family: courier;"><span style="background-color: #674ea7;">COPY . /code/</span></span></div><ul style="font-family: Muli, sans-serif; text-align: left;"><li>Buat file dengan nama docker-compose.yml</li></ul><div><span style="background-color: #04ff00; font-family: courier;">vim docker-compose.yml</span><br /></div><ul style="font-family: Muli, sans-serif; text-align: left;"><li>Masukan kode</li></ul><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;">version: "3.9"</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"><br /></span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;">services:</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> db:</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> image: postgres</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> volumes:</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> - ./data/db:/var/lib/postgresql/data</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> environment:</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> - POSTGRES_DB=postgres</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> - POSTGRES_USER=postgres</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> - POSTGRES_PASSWORD=password</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> web:</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> build: .</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> command: python manage.py runserver 0.0.0.0:8000</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> volumes:</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> - .:/code</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> ports:</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> - "8000:8000"</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> depends_on:</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> - db</span></div><div><br /></div><ul style="font-family: Muli, sans-serif; text-align: left;"><li>Buat project baru Django, misal dengan nama djangodockertest</li></ul><div><span face="Muli, sans-serif"> </span><span style="background-color: #04ff00; font-family: courier;">vim docker-compose run web django-admin startproject djangodockertest</span><br /></div><ul style="font-family: Muli, sans-serif; text-align: left;"><li>Ubah setingan Database di file settings.py yang terdapat di folder djangoprojecttest. dengan catatan di komputer lkal sudah diinstal PostgreSQL dan buat database tertentu.</li></ul><div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;">DATABASES = {</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> 'default': {</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> 'ENGINE': 'django.db.backends.postgresql',</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> 'NAME': 'postgres', #sesuaikan</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> 'USER': 'postgres', </span><span style="background-color: #674ea7; color: #fcff01; font-family: courier;">#sesuaikan</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> 'PASSWORD': 'password', </span><span style="background-color: #674ea7; color: #fcff01; font-family: courier;">#sesuaikan</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> 'HOST': 'db', #sesuai setingan di docker-compose.yml</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> 'PORT': 5432,</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;"> }</span></div><div><span style="background-color: #674ea7; color: #fcff01; font-family: courier;">}</span></div></div><ul style="font-family: Muli, sans-serif; text-align: left;"><li>Buat makemigrations</li></ul><div><span style="background-color: #04ff00; font-family: courier;">docker-compose run web python manage.py makemigrations</span></div><ul style="font-family: Muli, sans-serif; text-align: left;"><li>Lakukan migrasi</li></ul><div><span style="background-color: #04ff00; font-family: courier;">docker-compose run web python manage.py migrate</span></div><ul style="font-family: Muli, sans-serif; text-align: left;"><li>Jalankan perintah docker-compose up</li></ul><div><span style="background-color: #04ff00; font-family: courier;">docker-compose up</span></div><ul style="font-family: Muli, sans-serif; text-align: left;"><li>Test buka server dengan buka di browser dan masuk ke 127.0.0.1:8000, jika berhasil maka akan tampil halaman awal aplikasi Django.</li></ul><ul style="font-family: Muli, sans-serif; text-align: left;"><li>Selanjutnya, lakukan langkah-langkah untuk membuat user admin dan lain sebagainya. </li><li>Jika ingin mematikan service Docker, maka ketikan perintah: </li></ul><div><span style="background-color: #04ff00; font-family: courier;">docker-compose down</span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><span style="background-color: #04ff00; font-family: courier;"><br /></span></div><div><span face="Muli, sans-serif"><br /></span></div><div><span face="Muli, sans-serif">Demikian contoh sederhana cara menggunakan Docker untuk membuat aplikasi Django dan PostgreSQL, semoga bermanfaat. @wawanhn</span></div><p></p><br /><br />Sumber:<br />https://www.hostinger.co.id/tutorial/apa-itu-docker?<br />https://www.dicoding.com/blog/apa-itu-docker/Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-9655388037801121202022-10-06T22:22:00.005+07:002022-10-18T17:42:14.846+07:00Deploy Aplikasi Django menggunakan Droplet di DigitalOcean Bagian 1<p style="text-align: center;"><span style="font-size: x-large;"><b><span style="color: #2b00fe;">D</span></b><span style="color: #0b5394;">igital</span> <b><span style="color: #2b00fe;">O</span></b><span style="color: #0b5394;">cean</span></span></p><p>Bagi yang bekerja dalam dunia cloud pasti sudah sering mendengan Digital Ocean sebagai perusahaan yang menyediakan layanan berbasis cloud salah satunya untuk infrastruktur website. Digital Ocean merupakan server cloud yang menggunakan SSD sebagai penyimpanan sehingga mempercepat akses data. Dengan menggunakan cloud juga kita bisa dengan mudah melakukan upgrade untuk menaikan spek layanan ataupun downgrade untuk menurunkan layanan dengan cepat dan mudah.</p><p>Digital Ocean menyediakan layanan VPS dengan paket yang murah dan user friendly. Perusahaan ini menurut sya dalam layanan cloud VPS hampir sebanding dengan layanan Amazon Web Service. Beberapa alasan untuk memilih menggunakan VPS dari Digital Ocean adalah sebagai berikut:</p><p></p><ul style="text-align: left;"><li>Control Panel yang sederhana,</li><li>Komunitas developer yang banyak tersedia,</li><li>Harga cukup terjangkau dari mulai $5 untuk hosting VPS</li><li>Kemudahan dalam instalasi</li></ul><div>Dalam tulisan ini saya akan berbagi bagaimana melakukan deploy aplikasi Django menggunakan Digital Ocean. Dengan catatan sebelumnya kita harus mendaftar terlebih dahulu akun digital ocean dengan membayar $5 dengan paypal atau kartu kredit.</div><div><br /></div><div><h2 id="step-2-creating-the-postgresql-database-and-user" style="box-sizing: border-box; color: #4d5b7c; font-family: Epilogue, sans-serif; margin: 1em 0px;">Step 1 — Membuat Droplet </h2></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Untuk mebuat Droplet silahkan login ke web <a href="https://www.digitalocean.com/" target="_blank">Digital Ocean</a> dan create Droplet dengan memilih jenis sistem operasi dan fitur atau spek VPS yang diinginkan. </span></div><div><h2 id="step-2-creating-the-postgresql-database-and-user" style="box-sizing: border-box; color: #4d5b7c; font-family: Epilogue, sans-serif; margin: 1em 0px;">Step 2 — Koneksi ke VPS menggunakan MobaXterm</h2></div><div style="text-align: left;"><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Download aplikasi MobaXterm </span><a href="https://mobaxterm.mobatek.net/download-home-edition.html" style="font-family: Inter, sans-serif; font-size: 16px;" target="_blank"><span style="color: red;">download disini</span></a></div><div><h2 id="step-2-creating-the-postgresql-database-and-user" style="box-sizing: border-box; color: #4d5b7c; font-family: Epilogue, sans-serif; margin: 1em 0px;">Step 3 — Konfigurasi Server</h2></div><div>Berikut beberapa skrip untuk konfigurasi dan persiapan library yang dibutuhkan untuk aplikasi Django</div><div><br /></div><div><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; margin: 0px; padding: 0px; text-shadow: none;"><span class="token function" style="background-attachment: initial; background-clip: initial; background-color: #674ea7; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; background: none rgb(103, 78, 167); border-radius: 0px; box-sizing: border-box; display: inline; font-size: 14px; margin: 0px; padding: 0px; text-shadow: none; white-space: pre;"><span style="font-family: courier;"><span style="color: white;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# </span><span style="color: #04ff00;">sudo apt update</span></span></span></span></div><div><span class="token function" style="background: none rgb(8, 27, 75); border-radius: 0px; box-sizing: border-box; display: inline; margin: 0px; padding: 0px; text-shadow: none;"><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; font-size: 14px; margin: 0px; padding: 0px; text-shadow: none; white-space: pre;"><span style="color: #ff4084; font-family: courier;"><br /></span></span></span></div><div><span style="background-color: #674ea7; font-family: courier;"><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; margin: 0px; padding: 0px; text-shadow: none;"><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; font-size: 14px; margin: 0px; padding: 0px; text-shadow: none; white-space: pre;"><span style="color: white;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# </span></span></span><span style="color: #04ff00;"><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; font-size: 14px; margin: 0px; padding: 0px; text-shadow: none; white-space: pre;">sudo</span><span style="font-size: 14px; white-space: pre;"> </span><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; font-size: 14px; margin: 0px; padding: 0px; text-shadow: none; white-space: pre;">apt</span><span style="font-size: 14px; white-space: pre;"> </span><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; font-size: 14px; margin: 0px; padding: 0px; text-shadow: none; white-space: pre;">install</span><span style="font-size: 14px; white-space: pre;"> python3-pi</span><span style="font-size: 14px; white-space: pre;">p</span></span></span></div><div><span style="color: #ea9999; font-family: courier;"><span style="background-color: #081b4b; font-size: 14px; white-space: pre;"><br /></span></span></div><div><span style="background-color: #674ea7; font-family: courier;"><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; margin: 0px; padding: 0px; text-shadow: none;"><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; font-size: 14px; margin: 0px; padding: 0px; text-shadow: none; white-space: pre;"><span style="color: white;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# </span></span></span><span style="color: #04ff00;"><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; font-size: 14px; margin: 0px; padding: 0px; text-shadow: none; white-space: pre;">sudo</span><span style="font-size: 14px; white-space: pre;"> </span><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; font-size: 14px; margin: 0px; padding: 0px; text-shadow: none; white-space: pre;">apt</span><span style="font-size: 14px; white-space: pre;"> install python3-dev</span></span></span></div><div><span style="color: #ea9999; font-family: courier;"><span style="background-color: #081b4b; font-size: 14px; white-space: pre;"><br /></span></span></div><div><span style="background-color: #674ea7; font-family: courier;"><span style="color: white; font-size: 14px; white-space: pre;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# </span><span style="color: #04ff00;"><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; font-size: 14px; margin: 0px; padding: 0px; text-shadow: none; white-space: pre;">sudo</span><span style="font-size: 14px; white-space: pre;"> </span><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; font-size: 14px; margin: 0px; padding: 0px; text-shadow: none; white-space: pre;">apt</span><span style="font-size: 14px; white-space: pre;"> </span><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; font-size: 14px; margin: 0px; padding: 0px; text-shadow: none; white-space: pre;">install</span><span style="font-size: 14px; white-space: pre;"> libpq-dev</span></span></span></div><div><span style="color: #ea9999; font-family: courier;"><span style="background-color: #081b4b; font-size: 14px; white-space: pre;"><br /></span></span></div><div><span style="background-color: #674ea7; font-family: courier;"><span style="color: white; font-size: 14px; white-space: pre;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# </span><span style="color: #04ff00;"><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; font-size: 14px; margin: 0px; padding: 0px; text-shadow: none; white-space: pre;">sudo</span><span style="font-size: 14px; white-space: pre;"> </span><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; font-size: 14px; margin: 0px; padding: 0px; text-shadow: none; white-space: pre;">apt</span><span style="font-size: 14px; white-space: pre;"> </span><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; font-size: 14px; margin: 0px; padding: 0px; text-shadow: none; white-space: pre;">install</span><span style="font-size: 14px; white-space: pre;"> postgresql</span></span></span></div><div><span style="color: #ea9999; font-family: courier;"><span style="background-color: #081b4b; font-size: 14px; white-space: pre;"><br /></span></span></div><div><span style="background-color: #674ea7; font-family: courier;"><span style="color: white; font-size: 14px; white-space: pre;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# </span><span style="color: #04ff00;"><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; font-size: 14px; margin: 0px; padding: 0px; text-shadow: none; white-space: pre;">sudo</span><span style="font-size: 14px; white-space: pre;"> </span><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; font-size: 14px; margin: 0px; padding: 0px; text-shadow: none; white-space: pre;">apt install </span><span style="font-size: 14px; white-space: pre;">postgresql-contrib</span></span></span></div><div><span style="color: #ea9999; font-family: courier;"><span style="background-color: #081b4b; font-size: 14px; white-space: pre;"><br /></span></span></div><div><span style="background-color: #674ea7; font-family: courier;"><span style="color: white; font-size: 14px; white-space: pre;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# </span><span style="color: #04ff00;"><span style="font-size: 14px; white-space: pre;">sudo apt install </span><span style="font-size: 14px; white-space: pre;">curl</span></span></span></div><div><br /></div><div><span style="background-color: #674ea7;"><span style="color: white; font-family: courier; font-size: 14px; white-space: pre;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# </span><span style="color: #04ff00; font-family: courier;"><span style="font-size: 14px; white-space: pre;">sudo apt install </span><span style="font-size: 14px; white-space: pre;">nginx</span></span></span></div><div><h2 id="step-2-creating-the-postgresql-database-and-user" style="box-sizing: border-box; color: #4d5b7c; font-family: Epilogue, sans-serif; margin: 1em 0px;">Step 4 — Creating the PostgreSQL Database and User</h2></div><div><p style="box-sizing: border-box; color: #4d5b7c; font-family: Inter, sans-serif; font-size: 16px; line-height: 1.5; margin: 1em 0px;">Dalam langkah ini akan membuat sebuah database dan user database untuk aplikasi Django dengan menggunakan aplikasi RDBMS PostgrSQL dan ekstensi Postgres untuk mengolah data spasial.</p><p style="box-sizing: border-box; color: #4d5b7c; font-family: Inter, sans-serif; font-size: 16px; line-height: 1.5; margin: 1em 0px;">Secara standarnya user Postgres digunakan sebagai sebuah skema autentifikasi yang dinamakan <i>peer authentication </i>untuk dalam koneksi lokal. Artinya jika user pengguna sistem operasi sesuai dengan username Postgres maka user dapat login tanpa autentifikasi lebih lanjut.</p><p style="box-sizing: border-box; color: #4d5b7c; font-family: Inter, sans-serif; font-size: 16px; line-height: 1.5; margin: 1em 0px;">Selama proses instalasi Postgres, sebuah username dengan nama <span style="background-color: #04ff00;">postgres</span><span style="background-color: white;"> dibuat sebagai user </span><span style="background-color: #04ff00;">postgres</span><span style="background-color: white;"> PostgreSQL. User ini akan dapat digunakan untuk melakukan operasi administrasi database. Untuk bisa login ke sesi interkatif Postgres digunakan sudo dan memasukan </span><span style="background-color: #04ff00;">username</span><span style="background-color: white;"> dengan menuliskan perintah opsi </span><span style="background-color: #04ff00;">-u</span><span style="background-color: white;">:</span></p><p style="box-sizing: border-box; font-size: 16px; line-height: 1.5; margin: 1em 0px;"><span style="background-color: #674ea7; font-family: courier;"><span style="color: white; font-size: 14px; white-space: pre;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# </span><span style="color: #04ff00;"><span style="font-size: 14px; white-space: pre;">sudo </span><span style="font-size: 14px; white-space: pre;"><span>-u postgres psql</span></span></span></span></p><p style="box-sizing: border-box; line-height: 1.5; margin: 1em 0px;"><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Perintah diatas akan menampilkan prompt PostgreSQL untuk setup kebutuhan dalam mebuat projek database. Pertama buat database baru dengan nama <span style="background-color: #04ff00;">myproject</span>.</span></p><p style="box-sizing: border-box; line-height: 1.5; margin: 1em 0px;"><span style="background-color: #674ea7; font-family: courier;"><span style="color: white;"><span style="font-size: 14px; white-space: pre;">postgres=# </span></span><span style="font-size: 14px; white-space: pre;"><span style="color: #04ff00;">CREATE DATABASE myproject;</span></span></span></p><p style="box-sizing: border-box; line-height: 1.5; margin: 1em 0px;"><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Selanjutnya, buat user untuk database tersebut dan tentukan password yang aman:</span></p><p style="box-sizing: border-box; line-height: 1.5; margin: 1em 0px;"><span style="background-color: #674ea7; font-family: courier;"><span style="color: white; font-size: 14px; white-space: pre;">postgres=# </span><span style="font-size: 14px; white-space: pre;"><span style="color: #04ff00;">CREATE USER myprojectuser WITH PASSWORD 'password';</span></span></span></p><p style="box-sizing: border-box; color: #4d5b7c; font-family: Inter, sans-serif; font-size: 16px; line-height: 1.5; margin: 1em 0px;">Kemudian, lakukan sedikit modifikasi paramter koneksi untuk user yang sudah dibuat. Hal ini akan mempercepat operasi database sehingga nilai yang tepat tidak akan ditanyakan dan disetel setiap koneksi tersambung. </p><p style="box-sizing: border-box; color: #4d5b7c; font-family: Inter, sans-serif; font-size: 16px; line-height: 1.5; margin: 1em 0px;">Set nilai encoding ke <span style="background-color: #04ff00;">UTF-8</span>, yang diharapkan aplikasi Django.</p><p style="box-sizing: border-box; line-height: 1.5; margin: 1em 0px;"><span style="background-color: #674ea7; font-size: small;"><span style="font-family: courier;"><span style="color: white;">postgres=# </span><span style="color: #04ff00;">ALTER ROLE myprojectuser SET client_encoding TO 'utf8';</span></span></span></p><p style="box-sizing: border-box; line-height: 1.5; margin: 1em 0px;"><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Kemudian set skema standar isolasi transaksi menjadi </span><code style="background-color: #04ff00; border-radius: 8px; box-sizing: border-box; color: #24335a; font-family: monospace, monospace; font-size: 14px; line-height: 1.4em; padding: 3px;">read committed</code><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"> untuk membaca commit dan mencegah pembacaan dari transaksi <i>uncommitted</i>:</span></p><p style="box-sizing: border-box; line-height: 1.5; margin: 1em 0px;"><span style="background-color: #674ea7; font-size: 14px; white-space: pre;"><span style="font-family: courier;"><span style="color: white;">postgres=# </span><span style="color: #04ff00;">ALTER ROLE myprojectuser SET default_transaction_isolation TO 'read committed';</span></span></span></p></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Project Django secara standar akan di set menggunakan </span><code style="background-color: #04ff00; border-radius: 8px; box-sizing: border-box; color: #24335a; font-family: monospace, monospace; font-size: 14px; line-height: 1.4em; padding: 3px;">UTC</code><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">, set zona waktu yang relevan:</span></div><div><br /></div><div><div><span style="font-family: courier;"><span style="background-color: #674ea7; color: white;">postgres=# </span><span style="background-color: #674ea7; color: #04ff00;">ALTER ROLE myprojectuser SET timezone TO 'UTC';</span></span></div></div><div><br /></div><div><p style="box-sizing: border-box; color: #4d5b7c; font-family: Inter, sans-serif; font-size: 16px; line-height: 1.5; margin: 1em 0px;">Langkah-langkah diatas merupakan hal yang direkomendasikan dalam sebuah aplikasi Django. Sekarang berikan akes user yang dibuat ke datase yang ditentukan:</p><p style="box-sizing: border-box; line-height: 1.5; margin: 1em 0px;"><span style="font-family: courier;"><span style="background-color: #674ea7; color: white; font-size: x-small;">postgres=# </span><span style="background-color: #674ea7; color: #04ff00; font-size: x-small;">GRANT ALL PRIVILEGES ON DATABASE myproject TO myprojectuser;</span></span></p><p style="box-sizing: border-box; line-height: 1.5; margin: 1em 0px;"><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Jika langkah-langkah tersebut sudah selesai, untuk keluar dari prompt PostgreSQL gunakan perintah berikut:</span></p><p style="box-sizing: border-box; line-height: 1.5; margin: 1em 0px;"><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"></span></p><p style="box-sizing: border-box; line-height: 1.5; margin: 1em 0px;"><span style="background-color: #674ea7; color: white; font-family: courier; font-size: x-small;">postgres-# </span><span style="background-color: #674ea7; color: #04ff00; font-family: courier; font-size: x-small;">\q</span></p><h2 id="step-3-creating-a-python-virtual-environment-for-your-project" style="box-sizing: border-box; color: #4d5b7c; font-family: Epilogue, sans-serif; margin: 1em 0px;">Step 5 — Membuat User di VPS</h2><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Untuk membuat user dalam VPS Droplet menggunakan perintah add <namauser>. Selanjutnya masukan password dan data lainnya.</span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"><br /></span></div><div><div><span style="background-color: #674ea7; color: white; font-family: courier;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# </span><span style="background-color: #674ea7; color: #04ff00; font-family: courier;">adduser user1</span></div></div><div><span style="background-color: #20124d; color: white;"><br /></span></div><div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Untuk membuat user dalam VPS Droplet menggunakan perintah add <namauser>. Selanjutnya masukan password dan data lainnya. Dan gunakan perintah usermod untuk merubah user yang dibuat menjadi admin. </span></div></div><div><br /></div><div><div><span style="background-color: #674ea7; color: white; font-family: courier;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# </span><span style="background-color: #674ea7; color: #04ff00; font-family: courier;">usermod -aG sudo user1</span></div></div><div><br /></div><div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Selanjutnya pindah ke direktori user yang sudah dibuat. </span></div><div><br /></div></div><div><div><span style="background-color: #674ea7; color: white; font-family: courier;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# </span><span style="background-color: #674ea7; color: #04ff00; font-family: courier;">cd /home/user1</span></div></div><div><br /></div><h2 id="step-3-creating-a-python-virtual-environment-for-your-project" style="box-sizing: border-box; color: #4d5b7c; font-family: Epilogue, sans-serif; margin: 1em 0px;">Step 6 — Membuat Virtual Environment untuk Project Python</h2><div><p style="box-sizing: border-box; color: #4d5b7c; font-family: Inter, sans-serif; font-size: 16px; line-height: 1.5; margin: 1em 0px;">Setelah selesai membuat database, selanjutnya siap untuk mempersiapkan proyek aplikasi Django. Untuk membuat aplikasi Django sebaiknya menggunakan sebuah virtual environment untuk efiensi managemen paket library yang digunakan. Menginstal Django dalam sebuah virtual environment memungkinkan sebuah proyek aplikasi Django terpisah dari aplikasi lain yang secara khusus menggunakan library-library versi terntentu. Dengan virtual environment dalam sebuah sistem operasi memungkinkan membuat beragam aplikasi Django dalam berbagai versi yang membutuhkan tipe atau versi library yang berbeda-beda sesuai kebutuhan dari aplikasi Django.</p><p style="box-sizing: border-box; color: #4d5b7c; font-family: Inter, sans-serif; font-size: 16px; line-height: 1.5; margin: 1em 0px;">Untuk melakukan ini, dibutuhkan untuk library <code style="background-color: #04ff00; border-radius: 8px; box-sizing: border-box; color: #24335a; font-family: monospace, monospace; font-size: 14px; line-height: 1.4em; padding: 3px;">virtualenv</code> menggunakan <code style="background-color: #04ff00; border-radius: 8px; box-sizing: border-box; color: #24335a; font-family: monospace, monospace; font-size: 14px; line-height: 1.4em; padding: 3px;">pip</code>:</p><p style="box-sizing: border-box; color: #4d5b7c; font-family: Inter, sans-serif; font-size: 16px; line-height: 1.5; margin: 1em 0px;">Upgrade pip:</p><p style="box-sizing: border-box; line-height: 1.5; margin: 1em 0px;"><span style="background-color: #674ea7; color: white; font-family: courier;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:~# </span><span style="background-color: #674ea7; color: #04ff00; font-family: courier;">sudo -H pip3 install --upgrade pip</span></p><p style="box-sizing: border-box; line-height: 1.5; margin: 1em 0px;"><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Instal paket virtulaenv:</span></p></div><div><div><span style="background-color: #674ea7; color: white; font-family: courier;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:/home/user1# </span><span style="background-color: #674ea7; color: #04ff00; font-family: courier;">sudo -H pip3 install virtualenv</span></div></div><div><br /></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Buat folder direktori proyek misal <span style="background-color: #04ff00;">myprojectdir</span>:</span></div><div><span face="Inter, sans-serif" style="background-color: #20124d; font-size: 16px;"><span style="color: white;"><br /></span></span></div><div><div><span style="background-color: #674ea7; color: white; font-family: courier;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:/home/user1# </span><span style="background-color: #674ea7; color: #04ff00; font-family: courier;">mkdir myprojectdir</span></div><div><span face="Inter, sans-serif" style="background-color: #20124d; color: white;"><br /></span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Pindah ke folder </span><span face="Inter, sans-serif" style="background-color: #04ff00; color: #4d5b7c; font-size: 16px;">myprojectdir</span><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">:</span></div><div><br /></div><div style="font-family: Inter, sans-serif; font-size: 16px;"><span style="background-color: #674ea7; color: white; font-family: courier; font-size: medium;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:/home/user1# </span><span style="background-color: #674ea7; font-family: courier; font-size: medium;"><span style="color: #04ff00;">cd myprojectdir</span></span></div></div><div style="font-family: Inter, sans-serif; font-size: 16px;"><div style="color: black; font-family: "Times New Roman"; font-size: medium;"><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"><br /></span></div><div style="color: black; font-family: "Times New Roman"; font-size: medium;"><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Buat virtualenv misal dengan nama </span><span face="Inter, sans-serif" style="background-color: #04ff00; color: #4d5b7c; font-size: 16px;">myprojectenv</span><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">:</span></div><div style="color: black; font-family: "Times New Roman"; font-size: medium;"><br /></div><div><span style="background-color: #674ea7; color: white; font-family: courier; font-size: medium;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:/home/user1/myprojectdir# </span><span style="background-color: #674ea7; font-family: courier; font-size: medium;"><span style="color: #04ff00;">virtualenv myprojectenv</span></span></div><div style="color: #4d5b7c;"><span style="background-color: #20124d; color: white; font-family: courier; font-size: medium;"><br /></span></div></div><div><div style="color: black; font-family: "Times New Roman"; font-size: medium;"><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Aktifkan virtual environment </span><span face="Inter, sans-serif" style="background-color: #04ff00; color: #4d5b7c; font-size: 16px;">myprojectenv</span><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">:</span></div><div style="color: black; font-family: "Times New Roman"; font-size: medium;"><br /></div><div style="font-family: Inter, sans-serif; font-size: 16px;"><span style="background-color: #674ea7; color: white; font-family: courier; font-size: medium;">root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:/home/user1/myprojectdir# </span><span style="background-color: #674ea7; font-family: courier; font-size: medium;"><span style="color: #04ff00;">source myprojectenv/bin/activate</span></span></div><div style="color: #4d5b7c; font-family: Inter, sans-serif; font-size: 16px;"><span style="background-color: #20124d; color: white; font-family: courier; font-size: medium;"><br /></span></div><div><div><span style="background-color: white;"><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Hasilnya virtual environment </span><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">myprojectenv</span><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"> aktif dan selajutnya library dan paket-paket yang dibutuhkan untuk membuat aplikasi Django secara terisolasi.Folder kerja terlihat seperti ini</span><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">:</span></span></div><div style="color: white; font-family: courier; font-size: medium;"><span face="Inter, sans-serif" style="background-color: white; color: #4d5b7c; font-size: 16px;"><br /></span></div><div style="color: white; font-family: courier; font-size: medium;"><span style="background-color: white;"><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"> </span><code style="border-radius: 8px; box-sizing: border-box; color: #24335a; font-family: monospace, monospace; font-size: 14px; line-height: 1.4em; padding: 3px;">(<mark style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">myprojectenv</mark>)<mark style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">user</mark>@<mark style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">host</mark>:~/<mark style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">myprojectdir</mark>$</code><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">.</span></span></div><div><p style="box-sizing: border-box; color: #4d5b7c; font-family: Inter, sans-serif; font-size: 16px; line-height: 1.5; margin: 1em 0px;"><span style="background-color: white;">Dengan aktifnya virtual environment selanjutnya install Django, Gunicorn, and the psycopg2 PostgreSQL adaptor:</span></p><span style="background-color: #674ea7;"><span style="color: white; font-family: courier;">(myprojectenv) root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:/home/user1/myprojectdir# </span><span style="color: #04ff00; font-family: courier;">pip3 install django</span></span><div><span style="background-color: white;"><br /></span></div><div><span style="background-color: white;"><br /></span></div><div><span style="background-color: #674ea7;"><span style="color: white; font-family: courier;">(myprojectenv) root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:/home/user1/myprojectdir# </span><span style="font-family: courier;"><span style="color: #04ff00;">pip3 install gunicorn</span></span></span></div><div><span style="background-color: #20124d; color: white; font-family: courier;"><br /></span></div></div></div></div><p style="box-sizing: border-box; line-height: 1.5; margin: 1em 0px;"><span style="background-color: #674ea7;"><span style="color: white; font-family: courier;">(myprojectenv) root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:/home/user1/myprojectdir# </span><span style="font-family: courier;"><span style="color: #04ff00;">pip3 install psycopg2-binary</span></span></span></p><div><br /></div><div><span face="Inter, sans-serif" style="background-color: white; color: #4d5b7c; font-size: 16px;">Selanjutnya buat project Django misal dengan nama myproject:</span></div><p style="box-sizing: border-box; color: #4d5b7c; font-family: Inter, sans-serif; font-size: 16px; line-height: 1.5; margin: 1em 0px;"><span style="background-color: white;"></span></p><p style="box-sizing: border-box; line-height: 1.5; margin: 1em 0px;"><span style="background-color: #674ea7; color: white; font-family: courier;">(myprojectenv) root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:/home/user1/myprojectdir# </span><span style="background-color: #674ea7; color: #04ff00; font-family: courier;">python3 -m django startproject myproject ../myprojectdir</span></p></div><div><span face="Inter, sans-serif" style="background-color: white; color: #4d5b7c; font-size: 16px;">Selanjutnya ubah file settings.py yang terdapat di folder myprojectdir/myproject. Pada bagian <b>ALLOWED_HOSTS </b>tentukan alamat server atau IP yang bisa mengakses ke aplikasi Django. Silahkan masukan alamat web atau ip dan localhost.</span></div><div><span face="Inter, sans-serif" style="background-color: white; color: #4d5b7c; font-size: 16px;"><br /></span></div><div><pre style="background: rgb(8, 27, 75); border-radius: 0px 0px 16px 16px; box-sizing: border-box; color: white; font-family: monospace, monospace; font-size: 14px; line-height: 1.4em; margin-bottom: 1em; margin-top: 0px; overflow-wrap: normal; overflow: auto; padding: 1em; white-space: normal;"><code style="background: 0px 50%; border-radius: 0px; box-sizing: border-box; color: inherit; font-family: monospace, monospace; line-height: 1.4em; padding: 0px; white-space: pre;"># ALLOWED_HOSTS = ['.example.com', '203.0.113.5']
ALLOWED_HOSTS = ['159.223.181.170','localhost']</code></pre></div><div><span face="Inter, sans-serif" style="background-color: white; color: #4d5b7c; font-size: 16px;">Kemudian setting pada bagian database.</span></div><div><div><br /></div><div style="background-color: white; color: #4d5b7c; font-family: Inter, sans-serif; font-size: 16px;"><pre style="background: rgb(8, 27, 75); border-radius: 0px 0px 16px 16px; box-sizing: border-box; color: white; font-family: monospace, monospace; font-size: 14px; line-height: 1.4em; margin-bottom: 1em; margin-top: 0px; overflow-wrap: normal; overflow: auto; padding: 1em; white-space: normal;"><code style="background: 0px 50%; border-radius: 0px; box-sizing: border-box; color: inherit; font-family: monospace, monospace; line-height: 1.4em; padding: 0px; white-space: pre;">. . .
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.<mark style="background: rgba(65, 255, 244, 0.35); border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">postgresql_psycopg2</mark>',
'NAME': '<mark style="background: rgba(65, 255, 244, 0.35); border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">myproject</mark>',
'USER': '<mark style="background: rgba(65, 255, 244, 0.35); border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">myprojectuser</mark>',
'PASSWORD': '<mark style="background: rgba(65, 255, 244, 0.35); border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">password</mark>',
'HOST': '<mark style="background: rgba(65, 255, 244, 0.35); border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">localhost</mark>',
'PORT': '5432',
}
}
. . .</code></pre></div></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Kemudian pada bagian bawah file settings.py yang menentukan dimana static files harus diletakan. </span><span face="Inter, sans-serif" style="color: #4d5b7c;">Ini diperlukan agar Nginx dapat menangani permintaan untuk item ini.</span></div><div><br /></div><div><pre style="background: rgb(8, 27, 75); border-radius: 0px 0px 16px 16px; box-sizing: border-box; color: white; font-family: monospace, monospace; font-size: 14px; line-height: 1.4em; margin-bottom: 1em; margin-top: 0px; overflow-wrap: normal; overflow: auto; padding: 1em; white-space: normal;"><code style="background: 0px 50%; border-radius: 0px; box-sizing: border-box; color: inherit; font-family: monospace, monospace; line-height: 1.4em; padding: 0px; white-space: pre;">. . .
STATIC_URL = '/static/'
<mark style="background: rgba(65, 255, 244, 0.35); border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">import os</mark>
<mark style="background: rgba(65, 255, 244, 0.35); border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">STATIC_ROOT = os.path.join(BASE_DIR, 'static/')</mark></code></pre></div><div><span style="font-size: small;"><br /></span></div><div><h2 id="step-5-completing-initial-project-setup" style="box-sizing: border-box; color: #4d5b7c; font-family: Epilogue, sans-serif; margin: 1em 0px;">Step 7 — Menyelesaikan Setup Initial Project</h2></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Langkah selanjutnya adalah melakukan migrasi inisialskema database ke database PostgreSQL menggunakan kode:</span></div><div><br /></div><div><div><span style="background-color: #674ea7; color: white; font-family: courier;">(myprojectenv) root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:/home/user1/myprojectdir# </span><span style="background-color: #674ea7; color: #04ff00; font-family: courier;">python manage.py makemigrations</span></div></div><div><span style="background-color: #674ea7; color: #04ff00; font-family: courier;"><br /></span></div><div><span style="background-color: #674ea7; color: #04ff00; font-family: courier;"><br /></span></div><div><span style="background-color: #674ea7; color: white; font-family: courier;">(myprojectenv) root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:/home/user1/myprojectdir# </span><span style="background-color: #674ea7; color: #04ff00; font-family: courier;">python manage.py migrate</span></div><div><br /></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Langkah selanjutnya adalam membuat user admin. misal admin</span></div><div><span style="font-size: small;"><br /></span></div><div><span style="background-color: #674ea7; color: white; font-family: courier;">(myprojectenv) root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:/home/user1/myprojectdir# </span><span style="background-color: #674ea7; color: #04ff00; font-family: courier;">python manage.py createsuperuser</span></div><div><span style="background-color: #674ea7; color: #04ff00; font-family: courier;"><br /></span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Lakukan Collect semua file static kedalam lokasi directori yang sudah ditentukan:</span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"><br /></span></div><div><span style="background-color: #674ea7; color: white; font-family: courier;">(myprojectenv) root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:/home/user1/myprojectdir# </span><span style="background-color: #674ea7; color: #04ff00; font-family: courier;">python manage.py collectstatic</span></div><div><span style="background-color: #674ea7; color: #04ff00; font-family: courier;"><br /></span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Kemudian buka akses port </span><code style="background-color: #e3e8f4; border-radius: 8px; box-sizing: border-box; color: #24335a; font-family: monospace, monospace; font-size: 14px; line-height: 1.4em; padding: 3px;">8000</code><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">:</span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"><br /></span></div><div><span style="background-color: #674ea7; color: white; font-family: courier;">(myprojectenv) root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:/home/user1/myprojectdir# </span><span style="background-color: #674ea7; color: #04ff00; font-family: courier;">sudo ufw allow 8000</span></div><div><span style="background-color: #674ea7; color: #04ff00; font-family: courier;"><br /></span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Terakhir, test project dengan menjalankan palikasi server Django dengan menggunakan perintah:</span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"><br /></span></div><div><span style="background-color: #674ea7; color: white; font-family: courier;">(myprojectenv) root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:/home/user1/myprojectdir# </span><span style="background-color: #674ea7; color: #04ff00; font-family: courier;">python manage.py runserver 0.0.0.0:8000</span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"><br /></span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Jika berhasil, buka alamat http://alamat_server atau IP:8000, maka hasilnya:</span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://assets.digitalocean.com/articles/django_gunicorn_nginx_1804/django_index.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="532" data-original-width="800" height="426" src="https://assets.digitalocean.com/articles/django_gunicorn_nginx_1804/django_index.png" width="640" /></a></div><br /><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"><br /></span></div><div><h2 id="step-6-testing-gunicorn-s-ability-to-serve-the-project" style="box-sizing: border-box; color: #4d5b7c; font-family: Epilogue, sans-serif; margin: 1em 0px;">Step 8 — Testing Gunicorn’s agar Aplikasi Django sebagai Server</h2></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Sebelum keluar dari </span><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">virtual environment, test Gdahulu unicorn untuk memastikanbahwa Gunicorn dapat melayani aplikasi. Masukan perintah di direktory myprojectdir:</span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"><br /></span></div><div><div><span style="background-color: #674ea7; color: white; font-family: courier;">(myprojectenv) root@ubuntu-s-1vcpu-1gb-intel-nyc1-01:/home/user1/myprojectdir# </span><span style="background-color: #674ea7; font-size: 16px;"><span style="color: #04ff00; font-family: courier;">gunicorn --bind 0.0.0.0:8000 myproject.wsgi</span></span></div></div><div><div style="color: #4d5b7c; font-family: Inter, sans-serif; font-size: 16px;"><br /></div></div><div style="color: #4d5b7c; font-family: Inter, sans-serif; font-size: 16px;"><div style="color: black; font-family: "Times New Roman"; font-size: medium;"><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Jalankan lagi aplikasi, buka alamat http://alamat_server atau IP:8000 hasilnya sama dengan gambar diatas.</span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"><br /></span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Jika ingin mematikan server ketik <b>Ctrl + C</b>. Dan jika akan keluar dari virtual environment, silahkan ketikan <b>deactivate.</b></span></div></div><div><h2 id="step-7-creating-systemd-socket-and-service-files-for-gunicorn" style="box-sizing: border-box; color: #4d5b7c; font-family: Epilogue, sans-serif; margin: 1em 0px;">Step 9 — Membuat File systemd Socket and Service untuk Gunicorn</h2></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Buat file gunicorn.socket di folder /etc/systemd/system/</span></div><div><br /></div><div><ol style="box-sizing: border-box; font-size: 14px; list-style: none; margin: 0px; padding: 0px;"><li data-prefix="$" style="box-sizing: border-box; margin: 0px; padding: 0px; white-space: pre;"><span style="background-color: #674ea7; font-family: courier;"><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; margin: 0px; padding: 0px; text-shadow: none;"><span style="color: white;">$ </span><span style="color: #04ff00;">sudo</span></span><span style="color: #04ff00;"> </span><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; color: #04ff00; display: inline; margin: 0px; padding: 0px; text-shadow: none;">nano</span><span style="color: #04ff00;"> /etc/systemd/system/gunicorn.socket</span></span></li></ol><div><span style="color: #04ff00; font-family: courier;"><span style="font-size: 14px; white-space: pre;"><br /></span></span></div></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Kemudian inputkan kode sebagai berikut.</span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"><br /></span></div><div><pre style="background: rgb(8, 27, 75); border-radius: 0px 0px 16px 16px; box-sizing: border-box; color: white; font-family: monospace, monospace; font-size: 14px; line-height: 1.4em; margin-bottom: 1em; margin-top: 0px; overflow-wrap: normal; overflow: auto; padding: 1em; white-space: normal;"><code style="background: 0px 50%; border-radius: 0px; box-sizing: border-box; color: inherit; font-family: monospace, monospace; line-height: 1.4em; padding: 0px; white-space: pre;">[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target</code></pre></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"><br /></span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Buat file gunicorn.service di folder /etc/systemd/system/</span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"><br /></span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Kemudian masukan kode sebagai berikut:</span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"><br /></span></div><div><pre style="background: rgb(8, 27, 75); border-radius: 0px 0px 16px 16px; box-sizing: border-box; color: white; font-family: monospace, monospace; font-size: 14px; line-height: 1.4em; margin-bottom: 1em; margin-top: 0px; overflow-wrap: normal; overflow: auto; padding: 1em; white-space: normal;"><code style="background: 0px 50%; border-radius: 0px; box-sizing: border-box; color: inherit; font-family: monospace, monospace; line-height: 1.4em; padding: 0px; white-space: pre;">[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=<mark style="background: rgba(65, 255, 244, 0.35); border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">user1</mark>
Group=www-data
WorkingDirectory=/home/<mark style="background: rgba(65, 255, 244, 0.35); border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">user1</mark>/<mark style="background: rgba(65, 255, 244, 0.35); border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">myprojectdir</mark>
ExecStart=/home/<mark style="background: rgba(65, 255, 244, 0.35); border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">user1</mark>/<mark style="background: rgba(65, 255, 244, 0.35); border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">myprojectdir</mark>/<mark style="background: rgba(65, 255, 244, 0.35); border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">myprojectenv</mark>/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
<mark style="background: rgba(65, 255, 244, 0.35); border-radius: 8px; box-sizing: border-box; display: inline; line-height: calc(1.4em + 1px); padding: 0px 2px;">myproject</mark>.wsgi:application
[Install]
WantedBy=multi-user.target</code></pre></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"><br /></span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">Buat file gunicorn.socket di folder /etc/systemd/system/</span></div><div><p style="box-sizing: border-box; color: #4d5b7c; font-family: Inter, sans-serif; font-size: 16px; line-height: 1.5; margin: 1em 0px;">Jalankan socket Gunicorn socket yang akan menghasilkan file socket di <code style="background-color: #e3e8f4; border-radius: 8px; box-sizing: border-box; color: #24335a; font-family: monospace, monospace; font-size: 14px; line-height: 1.4em; padding: 3px;">/run/gunicorn.sock</code>:</p><ol style="box-sizing: border-box; list-style: none; margin: 0px; padding: 0px;"><li data-prefix="$" style="box-sizing: border-box; margin: 0px; padding: 0px; white-space: pre;"><span style="background-color: #674ea7; font-family: courier;"><span style="color: white;"><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; margin: 0px; padding: 0px; text-shadow: none;">$ </span></span><span style="color: #04ff00;">sudo systemctl start gunicorn.socket</span></span></li></ol><div><span style="color: #04ff00; font-family: courier;"><span style="white-space: pre;"><br /></span></span></div><div><p style="box-sizing: border-box; color: #4d5b7c; font-family: Inter, sans-serif; font-size: 16px; line-height: 1.5; margin: 1em 0px;">Lalu enable gunicorn socket, systemd secara otomatis akan menjalankan <code style="background-color: #e3e8f4; border-radius: 8px; box-sizing: border-box; color: #24335a; font-family: monospace, monospace; font-size: 14px; line-height: 1.4em; padding: 3px;">gunicorn.service</code>:</p><ol style="box-sizing: border-box; list-style: none; margin: 0px; padding: 0px;"><li data-prefix="$" style="box-sizing: border-box; margin: 0px; padding: 0px; white-space: pre;"><span style="background-color: #674ea7; font-family: courier;"><span style="color: white;"><span class="token function" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; margin: 0px; padding: 0px; text-shadow: none;">$ </span></span><span style="color: #04ff00;">sudo systemctl <span class="token builtin class-name" style="background-attachment: initial; background-clip: initial; background-image: none; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; box-sizing: border-box; display: inline; margin: 0px; padding: 0px; text-shadow: none;">enable</span> gunicorn.socket</span></span></li></ol><div><span style="color: #04ff00; font-family: courier;"><span style="white-space: pre;"><br /></span></span></div><div><h2 id="step-8-checking-for-the-gunicorn-socket-file" style="box-sizing: border-box; color: #4d5b7c; font-family: Epilogue, sans-serif; margin: 1em 0px;">Step 10 — Checking for the Gunicorn Socket File</h2></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;">alu enab</span></div></div></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"><br /></span></div><div><span face="Inter, sans-serif" style="color: #4d5b7c; font-size: 16px;"><br /></span></div><div><span style="font-size: small;"><br /></span></div><div><span style="font-size: small;">Referensi:</span></div><div><ul style="text-align: left;"><li><span style="font-size: x-small;">https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04</span></li></ul></div><p></p>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-46975700437594237442022-08-22T04:17:00.003+07:002022-08-22T04:17:45.751+07:00Download Ebook Understanding Machine Learning: From Theory to Algorithms<div class="separator" style="clear: both; text-align: center;"><a href="https://imageio.forbes.com/specials-images/dam/imageserve/1129869424/960x0.jpg?format=jpg&width=960" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="600" data-original-width="800" height="240" src="https://imageio.forbes.com/specials-images/dam/imageserve/1129869424/960x0.jpg?format=jpg&width=960" width="320" /></a></div><br /><p><br /></p><p> Bagi yang tertarik mempelajari Machine Learning, berikut Link Ebook </p><h2 id="understandingmachinelearning:fromtheorytoalgorithms" style="-webkit-font-smoothing: antialiased; background-color: white; border-bottom: 1px solid rgb(204, 204, 204); cursor: text; font-family: Georgia, serif; font-size: 24px; margin: 15px; padding: 0px; position: relative;">Understanding Machine Learning: From Theory to Algorithms</h2><div>dalam format PDF yang bisa di download secara gratis di <a href="https://www.cs.huji.ac.il/w~shais/UnderstandingMachineLearning/copy.html" target="_blank">LINK ini</a></div><div><br /></div><div><h3 id="freeonlinecopy" style="-webkit-font-smoothing: antialiased; background-color: white; cursor: text; font-family: Georgia, serif; font-size: 18px; margin: 15px; padding: 0px; position: relative;">Free Online Copy</h3><p style="background-color: white; font-family: Georgia, serif; font-size: 16px; margin: 15px;">Understanding Machine Learning, © 2014 by Shai Shalev-Shwartz and Shai Ben-David</p><p style="background-color: white; font-family: Georgia, serif; font-size: 16px; margin: 15px;">Published 2014 by Cambridge University Press</p><p style="background-color: white; font-family: Georgia, serif; font-size: 16px; margin: 15px;">PDF of manuscript posted by permission of Cambridge University Press.</p><p style="background-color: white; font-family: Georgia, serif; font-size: 16px; margin: 15px;">Users may download a copy for personal use only.</p><p style="background-color: white; font-family: Georgia, serif; font-size: 16px; margin: 15px;">Not for distribution.</p></div><div><br /></div><div>Terima kasih. @wawanhn</div>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-81862810647154308182022-08-19T20:14:00.003+07:002022-08-23T21:39:07.870+07:00Membuka Web Browser dengan Python<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNmjUDLdUgwja87EUeKy0OeDlFIAR4QkzACgE5L-UESQSAx0c6v8hws614L71FIGDkKlzCzfbovdaA0q3EtxTQx_YmjTTl7nKparL4YqxWSBhQ5iv1cMgqAoMpVOBw6sYd9IZj9KmCE1sCP3UHU9FRdDdeeU9tbYEp2izqXzToJbRK-XfZz6I59a9yDQ/s1487/python-logo-master.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="645" data-original-width="1487" height="139" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNmjUDLdUgwja87EUeKy0OeDlFIAR4QkzACgE5L-UESQSAx0c6v8hws614L71FIGDkKlzCzfbovdaA0q3EtxTQx_YmjTTl7nKparL4YqxWSBhQ5iv1cMgqAoMpVOBw6sYd9IZj9KmCE1sCP3UHU9FRdDdeeU9tbYEp2izqXzToJbRK-XfZz6I59a9yDQ/s320/python-logo-master.png" width="320" /></a></div><br /><p><br /></p><p>Dengan menggunakan library webbrowser dapat membuat skrip untuk membuka halaman web dengan Python. Kode skrip yang digunakan adalah sebagai berikut (sangat simple):</p><p><br /></p><p><span style="font-family: courier;">import webbrowser</span></p><p><span style="font-family: courier;">url = input("Input URL: ")</span></p><p><span style="font-family: courier;">webbrowser.open(url)</span></p><p><span style="font-family: courier;"><br /></span></p><p><span style="font-family: inherit;">Import webbrowser memangggil library webbrowser yang menyediakan fungsi untuk membuka webbrowser. Kemudian dibuat variable url yang berisi input halaman web yang akan dibuka. Dan terkahir perintah webbroser.open adalah untuk membuka halaman web dengan menggunakan browser yang terdapat dalam komputer kita.</span></p><p><span style="font-family: inherit;">Oke demikian, sangat simpel dan semoga bermanfaat. @wawanhn</span></p><p><span style="font-family: inherit;"><br /></span></p><h4 style="text-align: left;"><span style="font-size: x-small;"><span style="font-family: courier;">Referensi:<br /> </span><span style="font-family: courier;">- www.clcoding.com<br /></span><span style="font-family: courier;">- https://twitter.com/clcoding/status/1561889221526269952</span></span></h4>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-9908480029638195592022-08-16T10:18:00.012+07:002022-08-16T10:25:15.779+07:00Konversi File Word ke PDF dengan Menggunakan Python<div class="separator" style="clear: both; text-align: justify;"><div class="separator" style="clear: both; text-align: center;"><a href="https://upload.wikimedia.org/wikipedia/commons/thumb/1/1d/PyCharm_Icon.svg/2048px-PyCharm_Icon.svg.png" style="margin-left: 1em; margin-right: 1em;"><img alt="PyCharm Logo" border="0" data-original-height="800" data-original-width="800" height="200" src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/1d/PyCharm_Icon.svg/2048px-PyCharm_Icon.svg.png" title="PyCharm" width="200" /></a></div><br /><span style="text-align: left;"><br /></span></div><div class="separator" style="clear: both; text-align: justify;"><span style="text-align: left;">Dengan menggunakan Python kita bisa dengan mudah melakukan konversi file dokumen word atau docx mejadi file dokumen pdf. Salah satu library atau package di Python yang bisa digunakan adalah </span><b style="text-align: left;">docx2pdf. </b><span style="text-align: left;">Namun hal yang harus di ingat dalam menggunakan ini adalah aplikasi microsoft word harus sudah terintall dalam sistem operasi kita. Dalam hal ini saya berhasil menggunakan Windows & Mac yang sudah terinstall aplikasi Microsoft Word. Saat menggunakan </span><a href="http://Kaggle.com" style="text-align: left;" target="_blank">Kaggle</a><span style="text-align: left;"> belum berhasil dijalankan karena dalam sistem tersebut belum terinstall aplikasi word. Warning error di </span><a href="http://Kaggle.com" style="text-align: left;" target="_blank">Kaggle</a><span style="text-align: left;"> adalah </span><span color="var(--jp-content-font-color1)" face="var(--jp-code-font-family)" style="font-size: var(--jp-code-font-size); text-align: left; white-space: pre-wrap;"><i><b>docx2pdf is not implemented for linux as it requires Microsoft Word to be installed.</b></i></span></div><p><span color="var(--jp-content-font-color1)" face="var(--jp-code-font-family)" style="font-size: var(--jp-code-font-size); white-space: pre-wrap;">Oke saat ini saya akan coba membuat aplikasi konversi file docx ke pdf dengan menggunakan <b><a href="https://www.jetbrains.com/pycharm/" target="_blank">PyCharm</a> </b>yang terdapat dalam sistem informasi Windows. Caranya adalah sebagai berikut:</span></p><p><span color="var(--jp-content-font-color1)" face="var(--jp-code-font-family)" style="font-size: var(--jp-code-font-size); white-space: pre-wrap;">- Buka aplikasi PyCharm, jika pertama kali maka kita buat working project baru.</span></p><p><span color="var(--jp-content-font-color1)" face="var(--jp-code-font-family)" style="font-size: var(--jp-code-font-size); white-space: pre-wrap;">- Kemudian klik menu <b>File -> Settings, </b>pada bagian <b>Project </b>pilih <b>Project Interpreter </b>lalu klik tanda <b>+ Install </b></span><b style="color: var(--jp-content-font-color1); font-family: var(--jp-code-font-family); font-size: var(--jp-code-font-size); white-space: pre-wrap;">Alt +Insert</b></p><p><span color="var(--jp-content-font-color1)" face="var(--jp-code-font-family)" style="font-size: var(--jp-code-font-size); white-space: pre-wrap;"><b></b></span></p><div class="separator" style="clear: both; text-align: center;"><b> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3ulF6DrW-bggLgt447lRQ4q-NuSHA7OigjWiSrOzJZ-iWfoxIYjolFPXzKixgfv0zn_GCj_Nh3HFkAswdT4lC_RYZjxN8ovgjZrW8rsD0Qr00m170OvXE3fmKz-a17n1hObAp_Vqba0DM89rm8aBVRgU27VWx5qoXV2vkzWVSsasFYMHOfLgJB8yyKg/s707/PyCharm1.png" style="font-family: var(--jp-code-font-family); font-size: var(--jp-code-font-size); margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="370" data-original-width="707" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3ulF6DrW-bggLgt447lRQ4q-NuSHA7OigjWiSrOzJZ-iWfoxIYjolFPXzKixgfv0zn_GCj_Nh3HFkAswdT4lC_RYZjxN8ovgjZrW8rsD0Qr00m170OvXE3fmKz-a17n1hObAp_Vqba0DM89rm8aBVRgU27VWx5qoXV2vkzWVSsasFYMHOfLgJB8yyKg/w400-h209/PyCharm1.png" width="400" /></a></b></div><br /><p></p><p><span color="var(--jp-content-font-color1)" face="var(--jp-code-font-family)" style="font-size: var(--jp-code-font-size); white-space: pre-wrap;"><b>- </b>Ketikan doxc2pdf, lalu pilih button <b>Install Package </b>pada bagian bawah, tunggu sampai proses instalasi selesai lalu klik <b>OK.</b></span></p><p><span color="var(--jp-content-font-color1)" face="var(--jp-code-font-family)" style="font-size: var(--jp-code-font-size); white-space: pre-wrap;"><b>- </b>Selanjutnya buat file python baru, dan masukan kode program sebagai berikut</span></p><p><span color="var(--jp-content-font-color1)" face="var(--jp-code-font-family)" style="font-size: var(--jp-code-font-size); white-space: pre-wrap;"><br /></span></p><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><span style="color: #cc7832;">from </span>docx2pdf <span style="color: #cc7832;">import </span>convert<br />doxc = <span style="color: #6a8759;">'Test File.docx'<br /></span>pdf = <span style="color: #6a8759;">'Test.pdf'<br /></span>convert(doxc<span style="color: #cc7832;">,</span>pdf)</pre><p><span color="var(--jp-content-font-color1)" face="var(--jp-code-font-family)" style="font-size: var(--jp-code-font-size); white-space: pre-wrap;"><br /></span></p><p><span color="var(--jp-content-font-color1)" face="var(--jp-code-font-family)" style="font-size: var(--jp-code-font-size); white-space: pre-wrap;">- Dengan catatan silahkan sesuai path dari file docx dan pdf hasil konversi.</span></p><p><span color="var(--jp-content-font-color1)" face="var(--jp-code-font-family)" style="font-size: var(--jp-code-font-size); white-space: pre-wrap;">- Kemudian run kode program, dan jika kode program kita benar maka akan dibuat satu file dokumen pdf dengan nama <b>Test.pdf </b>di komputer kita.</span></p><p><span color="var(--jp-content-font-color1)" face="var(--jp-code-font-family)" style="font-size: var(--jp-code-font-size); white-space: pre-wrap;">Cukup simpel dan m</span><span color="var(--jp-content-font-color1)" face="var(--jp-code-font-family)" style="font-size: var(--jp-code-font-size); white-space: pre-wrap;">udahkan? oke terima kasih sudah menyimak, semoga bermanfaat. @wawanhn</span></p><p><span style="white-space: pre-wrap;"><span style="font-size: x-small;">Referensi: </span></span></p><p><span style="white-space: pre-wrap;"><span style="font-size: x-small;">- </span></span><span style="font-size: x-small;"><span style="white-space: pre-wrap;">https://pypi.org/project/docx2pdf/</span></span><span style="font-size: small; white-space: pre-wrap;"> </span></p><p><span style="white-space: pre-wrap;"><span style="font-size: x-small;">- https://medium.com/@nutanbhogendrasharma/convert-word-file-to-pdf-html-and-pdf-to-jpg-png-in-python-2e5da4f6a2fb</span></span></p>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-58533776161180068422022-08-16T09:27:00.007+07:002022-08-16T10:26:48.057+07:00Konversi File Pdf ke Word dengan Menggunakan Python<div class="separator" style="clear: both; text-align: center;"><a href="https://upload.wikimedia.org/wikipedia/commons/7/7c/Kaggle_logo.png?20140912155123" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="258" data-original-width="668" height="123" src="https://upload.wikimedia.org/wikipedia/commons/7/7c/Kaggle_logo.png?20140912155123" width="320" /></a></div><br /><p>Dengan menggunakan bahasa Python kita bisa melakukan konversi dokumen pdf menjadi dokumen word dengan menggunakan library <b>pdf2docx. </b></p><p>Berikut cara membuat file file dokumen docx dari hasil konversi file format pdf. Dalam contoh ini saya gunakan notebook dari <a href="https://www.kaggle.com/" target="_blank">Kaggle</a>. Silahkan buka web <a href="https://www.kaggle.com/" target="_blank">Kaggle</a> kemudian buat notebook baru dengan cara klik menu <b>< >Code </b>disebelah kiri lalu klik <b>New Notebook </b>dan tuliskan kode perintah dalam cell sebagai berikut:</p><p><br /></p><p><span style="font-family: courier;">from pdf2docx import Converter</span></p><p><span style="font-family: courier;">pdf_file = '../input/file pdf.pdf'</span></p><p><span style="font-family: courier;">docx_file = './test.docx'</span></p><p><span style="font-family: courier;">cv = Converter(pdf_file)</span></p><p><span style="font-family: courier;">cv.convert(docx_file)</span></p><p><span style="font-family: courier;">cv.close()</span></p><p><span style="font-family: courier;"><br /></span></p><p>Kemudian <b>Run current cell </b>atau tekan <b>Ctrl</b> + <b>Enter </b>dan tunggu proses sampai konversi selesai dilakukan. Jika berhasil maka akan dibuat satu file <b>test.docx </b>di <b>Data </b>pada folder <b>Output/Working.</b></p><p>Jika terdapat error karena package pdf2docx belum terinstall maka lakukan instalasi package <i>pdf2docx </i>dengan menggunakan perintah:</p><p><br /></p><p><span style="font-family: courier;">!pip install pdf2docx</span></p><p><br /></p><p>Dengan catatan kita harus mengaktifkan atau <i>enable </i>Internet di bagian <i>Settings </i>di menu sebelah kanan. </p><p>Oke cukup simpel kan bagaimana konversi file pdf ke docx dengan menggunakan library/package <b>pdf2docx </b>di Python.</p><p>Terima kasih sudah menyimak semoga bermanfaat. @wawanhn</p><p><br /></p><p><span style="font-size: x-small;">Referensi:</span></p><p><span style="font-size: x-small;">https://www.clcoding.com/2022/08/day-83-convert-pdf-to-docx-using-python.html</span></p><p><b><br /></b></p><p><br /></p>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-28124881958831790622022-08-12T18:04:00.005+07:002022-08-12T18:32:42.225+07:00ArcGIS Online versi Full Free Trial<p> </p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogs.swarthmore.edu/its/wp-content/uploads/2020/04/ArcGIS-Online.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="421" data-original-width="800" height="168" src="https://blogs.swarthmore.edu/its/wp-content/uploads/2020/04/ArcGIS-Online.png" width="320" /></a></div><br />ArcGIS online merupakan perangkan lunak berbasis cloud untuk membuat dan membagiakan aplikasi web berbasis GIS yang interaktif. Dengan menggunakan layanan ArcGIS Online dapatkan perspektif baru dan interkaksi yang semakin nyata tentang data yang ditampilkan dalam bentuk peta yang dapat dilihat secara online oleh siapapun melalui internet. Dengan menggunakan ArcGIS Online data dapat ditampilkan kepada semua orang atau orang tertentu dan data tersebut bisa dikolaborasikan untuk dikerjakan secara bersama-sama.<p></p><p>Penampilan data yang menarik, analisis data yang semakin canggih dapat memberikan visualisasi yang menarik dan dapat dengan mudah memberikan <i>insight</i> dari suatu data tertentu. Sangat banyak kemampuan yang dimiliki oleh ArcGIS Online dalam manajemen, analisis dan menyajikan data spasial.</p><p><b>Membuat Peta Interaktif</b></p><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: center;"><a href="http://www.geomapik.com/wp-content/uploads/2020/04/logos_productos_esri.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="685" data-original-width="538" height="400" src="http://www.geomapik.com/wp-content/uploads/2020/04/logos_productos_esri.jpg" width="314" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><br /><br /></div><p>Dengan peta interaktif dapat menjelaskan data yang kita miliki dan menggugah bagi pengguna untuk mengeksplor data yang kita sajikan lebih jauh. Data atau informasi sama namun disajikan dalam bentuk yang berbeda akan memberikan kesan yang berbeda bagi yang melihat atau menggunakannya. Itulah yang dapat diberikan oleh ArcGIS Online dengan menampilkan <i>smart mapping</i> yang memberikan visualisasi data yang berkesan dan imaginatif bagi yang melihat atau menggunakan data.</p><p>ArcGIS Online merupakan salah satu software andalan ArcGIS yang menyesuaikan dengan perkembangan teknologi. ArcGIS Online berbasis cloud sehinga memutuskan hambatan ruang dan waktu dalam manajemen, akses, analisis dan visualisasi data spasial.</p><p>Untuk dapat menggunakan ArcGIS Online harus membayar lisensi yang tidak sedikit, namun bagi yang mau belajar dan mengenal ArcGIS Online dan menggunakan banyak fitur atau aplikasi yang disediakan bisa menggunakan ArcGIS Online versi Trial. Dengan menggunakan versi trial kita bisa explore dan belajar menggunakan ArcGIS Online yang memiliki banyak ragam aplikasi dengan cuma-cuma. Namun tentu dengan batasan waktu 21 hari penggunaan. Tapi ini suatu hal yang sangat menarik dan patut di coba untuk mengetahui, belajar dan explor ArcGIS Online free trial.</p><div class="separator" style="clear: both; text-align: center;"><a href="https://www.esri.com/content/dam/esrisites/en-us/arcgis/products/arcgis-online/arcgis-online-overview-2020-update/assets/agol-overview-tcs-make-maps.gif" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="352" data-original-width="644" height="352" src="https://www.esri.com/content/dam/esrisites/en-us/arcgis/products/arcgis-online/arcgis-online-overview-2020-update/assets/agol-overview-tcs-make-maps.gif" width="644" /></a></div><br /><p><br /></p><p>Untuk bisa menggunakan ArcGIS Online free trial silahkan lakukan pendaftaran di link dibawah ini:</p><p><span class="selectable-text copyable-text"><a href="https://www.esri.com/en-us/lg/training-and-services/learn-arcgis-education-trial">https://www.esri.com/en-us/lg/training-and-services/learn-arcgis-education-trial</a></span></p><p><span class="selectable-text copyable-text">Silahkan lakukan pendaftaran dan cek email untuk verifkasi pendaftaran.</span></p><p><span class="selectable-text copyable-text">Silahkan coba explore aplikasi-aplikasi yang terdapat dalam ArcGIS Online..</span></p><p><span class="selectable-text copyable-text"><br /></span></p><p> </p><p><br /></p><p><br /></p><p>Referensi:</p><p><span style="font-size: x-small;">https://www.esri.com/en-us/arcgis/products/arcgis-online/overview</span></p><p><span face=""Avenir Next", Avenir, "Helvetica Neue", sans-serif" style="background-color: white; color: #4a4a4a; font-size: 14px;">Build interactive maps that explain your data and encourage users to explore. Map your own data and gain perspective by adding the authoritative location-based data included in ArcGIS Online. Use smart mapping to guide your data exploration and visualization. </span></p><h2 class="avenir-light font-size-4 contentbar_heading" style="background-color: #394eee; box-sizing: inherit; color: var(--calcite-ui-text-1); font-family: "Avenir Next", Avenir, "Helvetica Neue", sans-serif; font-size: var(--font-4); font-weight: var(--calcite-font-weight-normal); line-height: 1.375; margin: 0 0 var(--space-4);">Map and interact with your location data</h2><hr class="separator" style="border: none; box-sizing: inherit; color: #151515; font-family: "Avenir Next", Avenir, "Helvetica Neue", sans-serif; font-size: 16px; height: 3px; margin: var(--space-4) 0; width: 50px;" /><div class="richtext-container" style="background-color: #394eee; box-sizing: inherit; color: #151515; font-family: "Avenir Next", Avenir, "Helvetica Neue", sans-serif; font-size: 16px;"><div class="font-size-1 trailer-0" style="box-sizing: inherit; font-size: var(--font-1); line-height: 1.375; margin-bottom: 0rem;"><p style="box-sizing: inherit; color: var(--calcite-ui-text-1); margin-block-end: var(--space-4); margin-block-start: 0px; margin-bottom: 0px; margin-top: 0px;">Build interactive web maps with ArcGIS Online, Esri's web-based mapping software. Gain new perspectives and enhanced details as you interact with data, zoom in, and search on the map. Use smart, data-driven mapping styles and intuitive analysis tools to gain location intelligence. Work effectively across your organization by collaboratively building and using maps. Share your insights with specific people or the entire world.</p></div></div>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-19186712002712917082022-06-02T08:43:00.005+07:002022-06-02T09:23:59.969+07:00Install Anaconda di Windows Subsystem Linux (WSL)<div class="separator" style="clear: both; text-align: center;"><a href="https://community.algostudio.net/wp-content/uploads/2020/04/Anaconda_Logo.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="223" data-original-width="447" height="223" src="https://community.algostudio.net/wp-content/uploads/2020/04/Anaconda_Logo.png" width="447" /></a></div><br /><p>Bagi yang menggunakan sistem operasi Linux dengan menggunakan Windows System Linux, misal linux versi Ubuntu. Disini say aakan share bagaimana install anaconda di Ubuntu WSL. Lankahnya sebagai berikut:</p><p>1. Buka web <a href="https://repo.anaconda.com/archive">https://repo.anaconda.com/archive</a>/ untuk melihat versi anaconda yang akan kita install</p><p>2. Misal kita kan mengintall versi Anaconda3-5.2.0 maka masukan perintah </p><p><span face="ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace" style="background-color: rgba(175, 184, 193, 0.2); color: #24292f; font-size: 13.6px;">$ wget https://repo.continuum.io/archive/Anaconda3-5.2.0-Linux-x86_64.sh</span></p>3. Jalankan perintah untuk menjalankan instalasi anaconda yang telah kita pilih, masukan perintah <div><span face="ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace" style="background-color: rgba(175, 184, 193, 0.2); color: #24292f; font-size: 13.6px;"><br /></span></div><div><span face="ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace" style="background-color: rgba(175, 184, 193, 0.2); color: #24292f; font-size: 13.6px;">$ bash Anaconda3-5.2.0-Linux-x86_64.sh</span></div><div><span face="ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace" style="background-color: rgba(175, 184, 193, 0.2); color: #24292f; font-size: 13.6px;"><br /></span></div>4. Kemudian tekan Enter dan tunggu proses instalasi sampai selesai.<div><br /></div><div>5. Kemudian ada pilihan untuk install VS Code, silahkan mau diinstall atau tidak.</div><div><br /></div><div>6. Selanjutnya test apakah sudah jalan dengan mengetikan perintah</div><div><br /></div><div><span face="ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace" style="background-color: rgba(175, 184, 193, 0.2); color: #24292f; font-size: 13.6px;">$ which python</span></div><div><span face="ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace" style="background-color: rgba(175, 184, 193, 0.2); color: #24292f; font-size: 13.6px;"><br /></span></div>7. Jika tidak menampilkan lokasi dimana aanoconda diinstall, maka bisa kita daftarkan ke dalam path dengan mengetikan perintah<div><br /></div><div><span face="ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace" style="background-color: rgba(175, 184, 193, 0.2); color: #24292f; font-size: 13.6px;">$ /home/kauff/anaconda3/bin/python</span></div><div><br /></div>8. Selanjutnya kita coba menjalankan python dengan mengetikan perintah <div><br /></div><div><span face="ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace" style="background-color: rgba(175, 184, 193, 0.2); color: #24292f; font-size: 13.6px;">$ python</span></div><div><span face="ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace" style="color: #24292f;"><span style="font-size: 13.6px;"><br /></span></span></div>9. Saat pertama menggunakan sebaiknya dibuat environment, dengan cara ketikan perintah, dimana ganti nama_env sesuai yang kita inginkan dan versi python sesuai dengan versi yang kita install dengan Anaonda sebelumnya.<div><br /></div><div><span style="background-color: rgba(175, 184, 193, 0.2); color: #24292f; font-size: 13.6px;">$ conda create -n nama_env python=3.6,5</span></div><div><div><br /></div><div>10. Kemudian aktifkan environment tersebut dengan mengetikan perintah</div><div><br /></div><div><span style="background-color: rgba(175, 184, 193, 0.2); color: #24292f; font-size: 13.6px;">$ source activate nama_env</span></div><div><br /></div><div>11. Kalau ingin menonaktifkan ketikan perintah </div><div><br /></div><div><span style="background-color: rgba(175, 184, 193, 0.2); color: #24292f; font-size: 13.6px;">$ source deactivate</span></div><div><br /></div><div>12. Selanjutnya silahkan install package-pakage yang diperlukan, dengan catatan kita dalam sebuah virtual environment atau virtual environment sudah kita aktifkan.</div><div><br /></div><div>13. Misal install numpy</div><div><br /></div><div><span style="background-color: rgba(175, 184, 193, 0.2); color: #24292f; font-size: 13.6px;">$ conda install numpy</span></div><div><span style="color: #24292f;"><span style="font-size: 13.6px;"><br /></span></span></div><div>14. Jika sudah selesai install, silahkan cek dengan cara masuk ke python <span style="background-color: rgba(175, 184, 193, 0.2); color: #24292f; font-size: 13.6px;">$ python, lalu </span>import package tersebut</div><div><br /></div><div><span style="background-color: rgba(175, 184, 193, 0.2); color: #24292f; font-size: 13.6px;">$ import numpy</span></div><div><span style="color: #24292f;"><span style="font-size: 13.6px;"><br /></span></span><br /><br />Terima kasih semoga membantu@wawanhn.<div><br /></div><div><span style="font-size: x-small;">sources: https://gist.github.com/kauffmanes/5e74916617f9993bc3479f401dfec7da</span><br /><div><div><div><br /></div></div></div></div></div></div>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-25188164836550783182022-05-23T22:57:00.005+07:002022-05-23T22:57:45.886+07:00Cara memperbaikai hardisk yang tidak bisa diakses dengan error the file or directory is corrupted and unreadable di Windows<div class="separator" style="clear: both; text-align: center;"><a href="https://www.mediafire.com/convkey/f29e/kf61qpq36f9er2zzg.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="172" data-original-width="366" height="172" src="https://www.mediafire.com/convkey/f29e/kf61qpq36f9er2zzg.jpg" width="366" /></a></div><br /><p>Saat mendapatkan permasalahan suatu drive tidak bisa diakses di saat data semua terdapat di hardsik tersebut merupakan salah satu masalah buruk yang mungkin membuat sangat frustasi. Bagi yang mendapatkan permasalahan seperti itu jangan panik terlebih dahulu. Salah satu cara yang bisa dilakukan ketika terjadi permasalahan tersebut di sistem operasi Windos bisa melakukan langkah-langkah dibawah ini:</p><p>1. Pertama buka <i><b>command prompt.</b></i></p><p>2. Lalu ketikan perintah <b><i>chkdsk /f /r d:</i></b></p><p><b><i> </i></b><b> </b>dimana drive hardsik yang tidak bisa diakses adalah <b>drive d</b></p><p><b></b></p><div class="separator" style="clear: both; text-align: center;"><b><a href="https://www.mediafire.com/convkey/428f/jvv3gtt8hqruan8zg.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="496" data-original-width="731" height="496" src="https://www.mediafire.com/convkey/428f/jvv3gtt8hqruan8zg.jpg" width="731" /></a></b></div><b><p><b><br /></b></p> </b>3. Tunggu proses pengecekan dan perbaikan file atau directory yang korup dilakukan.<p></p><p>4. Jika proses perbaikan selesai dilakukan dan lihat informasi apakah perbaikan berhasil, dan kemudian cek ulang drive hardisk.</p><p>5. Semoga dengan cara ini permasalahan akses hardisk bisa di perbaiki. Terimakasih @wawanhn</p>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-3896778179082930902022-04-24T07:15:00.004+07:002022-05-23T22:42:28.920+07:00Install SSH Server di Linux Ubuntu<div class="separator" style="clear: both; text-align: center;"><a href="https://upload.wikimedia.org/wikipedia/en/6/65/OpenSSH_logo.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="191" data-original-width="194" height="191" src="https://upload.wikimedia.org/wikipedia/en/6/65/OpenSSH_logo.png" width="194" /></a></div><p>Saat kita membutuhkan pekerjaan dengan cara sistem remote, maka salah satu yang dapat kita gunakan adalah melaui SSH. Dengan menggunakan ssh bisa dengan cara aman melakukan pekerjaan secara remote/mengontrol komputer/server layaknya seperti remote desktop yang biasa kita lakukan namun berbasis text. SSH atau secure shell merupakan sebuah protokol transfer yang memungkinkan untuk melakukan pengontrolan sebuah perangkat dari jarak jauh melalui koneksi internet. </p><p>Oke tidak usah panjang lebar, dalam tulisan ini kita akan bahas membuat ssh server di ubuntu dengan langkah sebagai berikut:</p><p></p><ul style="text-align: left;"><li>pertama buka terminal linux</li><li>kemudian install openssh-server dengan mengetikan perintah </li></ul><p></p><p> <span style="font-family: courier;"> </span><span style="font-family: courier;"><span> </span>$ sudo apt-get install openssh-server</span></p><p></p><ul style="text-align: left;"><li>aktifkan service ssh dengan mengetikan perintah</li></ul><div><span style="font-family: courier;"><span> </span><span> </span>$ <span style="background-color: rgba(0, 0, 0, 0.08); color: #111111; font-size: 16px;">sudo systemctl enable ssh</span></span></div><ul style="text-align: left;"><li>jalankan service ssh dengan mengetikan perintah</li></ul><div><span> </span><span> <span> </span><span> </span></span><span style="font-family: courier;">$ <span style="background-color: rgba(0, 0, 0, 0.08); color: #111111; font-size: 16px;">sudo systemctl start ssh</span></span></div><ul style="text-align: left;"><li>atau bisa dengan mengunakan perinta</li></ul><div><span> </span><span> </span><span> </span><span> </span><span style="font-family: courier;">$ sudo service ssh start</span></div><ul style="text-align: left;"><li>kemudian cek apakah status ssh server sudah berjalan</li></ul><div><span> </span><span> </span><span> </span><span> </span><span style="font-family: courier;">$ service ssh status</span></div><ul style="text-align: left;"><li>kalau mau melakukan konfigurasi di server ssh bisa ketikan perintah</li></ul><div><span> </span><span> </span><span> </span><span> </span><span style="font-family: courier;">$ pico /etc/ssh/sshd_config</span></div><ul style="text-align: left;"><li>buat Key dengan mengetikan perintah</li></ul><div><span> </span><span> </span><span> </span><span> </span><span style="font-family: courier;">$ ssh -keygen</span></div><ul style="text-align: left;"><li>lalu ketik <i>enter </i>untuk konfirmasi penyimpana key, dan masukan passphrase. Tunggu sampai berhasil.</li><li>lalu ketikan ifconfig untuk mengecek IP yang akan diremote</li><li>selanjutnya dengan menggunakan aplikasi Putty kita dapat konek ke server/komputer tersebut dengan memasukan No IP dan port 22. Saat pertama kali kita konek ada window yang melakukan konfirmasi apakah kita benar menuju server yang dituju lalu klik Accept.</li></ul><div>Source: https://www.goldenfast.net/blog/ssh-adalah/</div>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0tag:blogger.com,1999:blog-3806903242399597685.post-76457828651007688822022-02-24T20:59:00.006+07:002022-02-24T20:59:47.222+07:00Menggunakan Change Geolocation untuk Set lokasi anda koordinat di browser Google <p> <span style="text-indent: -18pt;">1.</span><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; text-indent: -18pt;">
</span><span style="text-indent: -18pt;">Change Gelocation (Location Guard) extension di Google Chrome:</span></p><p class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -18.0pt;"><o:p></o:p></p>
<span style="font-family: "Calibri",sans-serif; font-size: 11.0pt; line-height: 107%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><a href="https://chrome.google.com/webstore/detail/change-geolocation-locati/lejoknkbcogjceoniealiipllomkpioe?hl=en-US">https://chrome.google.com/webstore/detail/change-geolocation-locati/lejoknkbcogjceoniealiipllomkpioe?hl=en-US</a></span><div><br /></div><div>2.<span> </span><span style="text-indent: -18pt;">Add to Chrome</span><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; text-indent: -18pt;"> </span></div><div><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; text-indent: -18pt;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://www.mediafire.com/convkey/a60f/5ve3lnzcis4l7yc7g.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="315" data-original-width="624" height="315" src="https://www.mediafire.com/convkey/a60f/5ve3lnzcis4l7yc7g.jpg" width="624" /></a></div><br /><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; text-indent: -18pt;"><br /></span></div><div><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; text-indent: -18pt;"><br /></span></div><div><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; text-indent: -18pt;"><br /></span></div><div><span style="text-indent: -18pt;">3.</span><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; text-indent: -18pt;"> </span><span style="text-indent: -24px;">Klik Add Extension toolbar</span></div><div><span style="text-indent: -24px;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://www.mediafire.com/convkey/6d7a/34n4juupfbgz63ezg.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="318" data-original-width="624" height="318" src="https://www.mediafire.com/convkey/6d7a/34n4juupfbgz63ezg.jpg" width="624" /></a></div><br /><span style="text-indent: -24px;"><br /></span></div><div><span style="text-indent: -18pt;">4.</span><span style="text-indent: -18pt;"> </span><span style="text-indent: -18pt;">Klik extension toolbar, dan klik Pin</span></div><div><span style="text-indent: -18pt;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://www.mediafire.com/convkey/4b27/ehgf2qixgru0kbq7g.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="329" data-original-width="624" height="329" src="https://www.mediafire.com/convkey/4b27/ehgf2qixgru0kbq7g.jpg" width="624" /></a></div><br /></div><div><span style="text-indent: -18pt;">5.</span><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; text-indent: -18pt;">
</span><span style="text-indent: -18pt;">Klik toolbar Geolocation Guard lalu pilih
Options,</span></div><div><span style="text-indent: -18pt;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://www.mediafire.com/convkey/91c7/qc8gwwezt7u7ochzg.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="335" data-original-width="624" height="335" src="https://www.mediafire.com/convkey/91c7/qc8gwwezt7u7ochzg.jpg" width="624" /></a></div><br /><span style="text-indent: -18pt;"><br /></span></div><div><span style="text-indent: -18pt;">6.</span><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; text-indent: -18pt;"> </span><span style="text-indent: -18pt;">Masukan nilai koordinat, misal: latitude: </span>-6.2184825 dan<span style="text-indent: -18pt;"> longitude: </span>106.8165278.</div><div><br /><span style="text-indent: -18pt;"><div class="separator" style="clear: both; text-align: center;"><a href="https://www.mediafire.com/convkey/10e5/ys4fn2mwukag32k7g.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="334" data-original-width="624" height="334" src="https://www.mediafire.com/convkey/10e5/ys4fn2mwukag32k7g.jpg" width="624" /></a></div></span><br /></div><div><br /></div><div><span style="text-indent: -18pt;">7.</span><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; text-indent: -18pt;">
</span><span style="text-indent: -18pt;">Silahkan coba buka </span><a href="https://www.google.com/maps" style="text-indent: -18pt;">https://www.google.com/maps</a></div><div><span style="text-indent: -18pt;"><br /></span></div><div><span style="text-indent: -18pt;">8.<span> </span>Lalu pilih button lokasi anda, maka akan
menampilkan lokasi koordinat yang dimasukan tadi, maka langkah Anda sudah
benar.</span></div><div><span style="text-indent: -18pt;"><br /></span></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://www.mediafire.com/convkey/324c/fib3hht74amob6tzg.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="336" data-original-width="624" height="336" src="https://www.mediafire.com/convkey/324c/fib3hht74amob6tzg.jpg" width="624" /></a></div><br /><span style="text-indent: -18pt;"><br /></span></div><div><span style="text-indent: -18pt;">9.</span><span style="font-size: 7pt; font-stretch: normal; font-variant-east-asian: normal; font-variant-numeric: normal; line-height: normal; text-indent: -18pt;">
</span><span style="text-indent: -18pt;">Selamat mencoba.</span></div><div><p class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -18.0pt;"><o:p></o:p></p>
<br /></div><p class="MsoListParagraph" style="mso-list: l0 level1 lfo1; text-indent: -18.0pt;"><o:p></o:p></p>Wawanhnhttp://www.blogger.com/profile/10276434629005290206noreply@blogger.com0