Pilot for DJango
Homedjango

Pilot for DJango

Pilot for DJango

DJango

TOC

  • Pilot version: 2.0.5

Development steps

  1. Design
    • UI
    • Table
    • Logic
    • URL
  2. Set up project base
  3. Create application
  4. Make model
  5. Define URL
  6. Define view
  7. Design template

Set up Project Base

Create project directory

cd WORKSPACE
django-admin.py startproject mysite
mv mysite mysite_base
Bash

Configure

vi mysite_base/settings.py
Bash

Set up database

# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}
#####
Python

Set up static files

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/

STATIC_URL = '/static/'

STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
Python

Set up time zone

#TIME_ZONE = 'UTC'
TIME_ZONE='Asia/Seoul'
Python

Create basic table

python manage.py migrate
Bash

Create super user

python manage.py createsuperuser
Bash

Create application

Start application

python manage.py startapp bookmark
Bash

Register application

vi mysite_base/settings.py
Bash

Make model

vi bookmark/models.py
Bash
from django.db import models

# Create your models here.
class Bookmark(models.Model):
    title = models.CharField(max_length=100, blank=True, null=True)
    url = models.URLField('url', unique=True)

    def __str__(self):
        return self.title
Python

Register model to admin site

vi bookmark/admin.py
Bash
from django.contrib import admin
from bookmark.models import Bookmark

# Register your models here.
class BookmarkAdmin(admin.ModelAdmin):
    list_display = ('title', 'url')

admin.site.register(Bookmark, BookmarkAdmin)
Python

Apply change of database

python manage.py makemigrations
python manage.py migrate
Bash

Define URL

Define URL for base

vi mysite_base/urls.py
Bash
from django.contrib import admin
from django.urls import path
from django.conf.urls import include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('bookmark/', include(('bookmark.urls', 'bookmark'), namespace='bookmark'))
]
#####
Python

Define URL for bookmark

vi bookmark/urls.py
Bash
from django.urls import path
from bookmark.views import BookmarkLV, BookmarkDV

urlpatterns = [
    path('', BookmarkLV.as_view(), name='index'),
    path('<int:pk>/', BookmarkDV.as_view(), name='detail'),
]
#####
Python

Define view

Create templates directory

cd bookmark
mkdir templates
cd templates
mkdir bookmark
cd ../..
Bash

Make view for list

vi templates/bookmark/bookmark_list.html
Bash
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Django Bookmark List</title>
</head>
<body>

<div id="content">
    <h1>Bookmark List</h1>

    <ul>
        {% for bookmark in object_list %}
            <li><a href="{% url 'bookmark:detail' bookmark.id %}">{{ bookmark }}</a></li>
        {% endfor %}
    </ul>
</div>

</body>
</html>
HTML

Make view for detail

vi templates/bookmark/bookmark_detail.html
Bash
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>DJango Bookmark Detail</title>
</head>
<body>

<div id="content">
    <h1>{{ object.title }}</h1>
    <ul>
        <li>URL: <a href="{{ object.url }}">{{ object.url }}</a></li>
    </ul>
</div>

</body>
</html>
HTML
Name

0 weights,1,abstract class,1,active function,3,adam,2,Adapter,1,affine,2,argmax,1,back propagation,3,binary classification,3,blog,2,Bucket list,1,C++,11,Casting,1,cee,1,checkButton,1,cnn,3,col2im,1,columnspan,1,comboBox,1,concrete class,1,convolution,2,cost function,6,data preprocessing,2,data set,1,deep learning,31,Design Pattern,12,DIP,1,django,1,dnn,2,Don't Repeat Your code,1,drop out,2,ensemble,2,epoch,2,favicon,1,fcn,1,frame,1,gradient descent,5,gru,1,he,1,identify function,1,im2col,1,initialization,1,Lab,9,learning rate,2,LifeLog,1,linear regression,6,logistic function,1,logistic regression,3,logit,3,LSP,1,lstm,1,machine learning,31,matplotlib,1,menu,1,message box,1,mnist,3,mse,1,multinomial classification,3,mutli layer neural network,1,Non Virtual Interface,1,normalization,2,Note,21,numpy,4,one-hot encoding,3,OOP Principles,2,Open Close Principle,1,optimization,1,overfitting,1,padding,2,partial derivative,2,pooling,2,Prototype,1,pure virtual function,1,queue runner,1,radioButton,1,RBM,1,regularization,1,relu,2,reshape,1,restricted boltzmann machine,1,rnn,2,scrolledText,1,sigmoid,2,sigmoid function,1,single layer neural network,1,softmax,6,softmax classification,3,softmax cross entropy with logits,1,softmax function,2,softmax regression,3,softmax-with-loss,2,spinBox,1,SRP,1,standardization,1,sticky,1,stride,1,tab,1,Template Method,1,TensorFlow,31,testing data,1,this,2,tkinter,5,tooltip,1,Toplevel,1,training data,1,vanishing gradient,1,Virtual Copy Constructor,1,Virtual Destructor,1,Virtual Function,1,weight decay,1,xavier,2,xor,3,
ltr
item
Universe In Computer: Pilot for DJango
Pilot for DJango
Pilot for DJango
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFn1G530ZqdrYoWmq-7fMjtEayExF3_q8C5HGIlABgac-zz1iN2RMuJInC5kY6UqQFawhW6EvTSdjyfyPFFyF4j2V_1A4l2JrUr7HpvkUpdj1lwnVyI3Ha8hAtIZs0yFLof9F2XAMBnp0w/
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFn1G530ZqdrYoWmq-7fMjtEayExF3_q8C5HGIlABgac-zz1iN2RMuJInC5kY6UqQFawhW6EvTSdjyfyPFFyF4j2V_1A4l2JrUr7HpvkUpdj1lwnVyI3Ha8hAtIZs0yFLof9F2XAMBnp0w/s72-c/
Universe In Computer
https://kunicom.blogspot.com/2018/04/pilot-for-django.html
https://kunicom.blogspot.com/
https://kunicom.blogspot.com/
https://kunicom.blogspot.com/2018/04/pilot-for-django.html
true
2543631451419919204
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy