2. 打開cmd命令列建立Django
django-admin startproject Romyk
cd Romyk
python manage.py startapp myapp
mkdir teamplates
mkdir static
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | """ Django settings for Romyk project. Generated by 'django-admin startproject' using Django 4.2.9. For more information on this file, see https://docs.djangoproject.com/en/4.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.2/ref/settings/ """ from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-hk7y*r8sq$+nhugm$8b8y$itqalp%3geltfi77r98(^rh&1lnd' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = ["*"] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'myapp', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'Romyk.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [BASE_DIR / 'templates'], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'Romyk.wsgi.application' # Database # https://docs.djangoproject.com/en/4.2/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', } } # Password validation # https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/4.2/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.2/howto/static-files/ STATIC_URL = 'static/' STATICFILES_DIRS = [ BASE_DIR/'static', ] # Default primary key field type # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' |
6.Romyk/Romyk/urls.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | """ URL configuration for Romyk project. The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/4.2/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin from django.urls import path from myapp.views import index urlpatterns = [ path('admin/', admin.site.urls), path('', index), path('index/', index), ] |
7.修改Romyk/myapp/views.py
1 2 3 4 5 | from django.shortcuts import render # Create your views here. def index(request): return render(request, "index.html", locals()) |
8.修改index.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | <!DOCTYPE html> <html> <head> {% load static %} <!-- basic --> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- mobile metas --> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="initial-scale=1, maximum-scale=1"> <!-- site metas --> <title>Romyk</title> <meta name="keywords" content=""> <meta name="description" content=""> <meta name="author" content=""> <!-- bootstrap css --> <link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap.min.css' %}"> <!-- style css --> <link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}"> <!-- Responsive--> <link rel="stylesheet" href="{% static 'css/responsive.css' %}"> <!-- fevicon --> <link rel="icon" href="{% static 'images/fevicon.png' %}" type="image/gif" /> <!-- font css --> <link href="https://fonts.googleapis.com/css?family=Roboto:400,500,700&display=swap" rel="stylesheet"> <!-- Scrollbar Custom CSS --> <link rel="stylesheet" href="{% static 'css/jquery.mCustomScrollbar.min.css' %}"> <!-- Tweaks for older IEs--> <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css"> </head> <body> <div class="header_section"> <div class="container"> <nav class="navbar navbar-expand-lg navbar-light bg-light"> <a class="navbar-brand"href="index.html"><img src="{% static 'images/logo.png' %}"></a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav ml-auto"> <li class="nav-item active"> <a class="nav-link" href="index.html">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="about.html">About</a> </li> <li class="nav-item"> <a class="nav-link" href="icecream.html">Icecream</a> </li> <li class="nav-item"> <a class="nav-link" href="services.html">Services</a> </li> <li class="nav-item"> <a class="nav-link" href="blog.html">Blog</a> </li> <li class="nav-item"> <a class="nav-link" href="contact.html">Contact Us</a> </li> </ul> <form class="form-inline my-2 my-lg-0"> <div class="login_bt"><a href="#">Login <span style="color: #222222;"><i class="fa fa-user" aria-hidden="true"></i></span></a></div> <div class="fa fa-search form-control-feedback"></div> </form> </div> </nav> </div> <!-- banner section start --> <div class="banner_section layout_padding"> <div class="container"> <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel"> <ol class="carousel-indicators"> <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active">01</li> <li data-target="#carouselExampleIndicators" data-slide-to="1">02</li> <li data-target="#carouselExampleIndicators" data-slide-to="2">03</li> <li data-target="#carouselExampleIndicators" data-slide-to="3">04</li> </ol> <div class="carousel-inner"> <div class="carousel-item active"> <div class="row"> <div class="col-sm-6"> <h1 class="banner_taital">Ice Cream</h1> <p class="banner_text">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem</p> <div class="started_text"><a href="#">Order Now</a></div> </div> <div class="col-sm-6"> <div class="banner_img"><img src="{% static 'images/banner-img.png' %}"></div> </div> </div> </div> <div class="carousel-item"> <div class="row"> <div class="col-sm-6"> <h1 class="banner_taital">Ice Cream</h1> <p class="banner_text">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem</p> <div class="started_text"><a href="#">Order Now</a></div> </div> <div class="col-sm-6"> <div class="banner_img"><img src="{% static 'images/banner-img.png' %}"></div> </div> </div> </div> <div class="carousel-item"> <div class="row"> <div class="col-sm-6"> <h1 class="banner_taital">Ice Cream</h1> <p class="banner_text">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem</p> <div class="started_text"><a href="#">Order Now</a></div> </div> <div class="col-sm-6"> <div class="banner_img"><img src="{% static 'images/banner-img.png' %}"></div> </div> </div> </div> <div class="carousel-item"> <div class="row"> <div class="col-sm-6"> <h1 class="banner_taital">Ice Cream</h1> <p class="banner_text">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem</p> <div class="started_text"><a href="#">Order Now</a></div> </div> <div class="col-sm-6"> <div class="banner_img"><img src="{% static 'images/banner-img.png' %}"></div> </div> </div> </div> </div> </div> </div> </div> <!-- banner section end --> </div> <!-- header section end --> <!-- about sectuion start --> <div class="about_section layout_padding"> <div class="container"> <div class="row"> <div class="col-md-6"> <div class="about_img"><img src="{% static 'images/about-img.png' %}"></div> </div> <div class="col-md-6"> <h1 class="about_taital">About Icecream</h1> <p class="about_text">Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore euconsectetur adipiscing esequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu</p> <div class="read_bt_1"><a href="#">Read More</a></div> </div> </div> </div> </div> <!-- about sectuion end --> <!-- cream sectuion start --> <div class="cream_section layout_padding"> <div class="container"> <div class="row"> <div class="col-md-12"> <h1 class="cream_taital">Our Featured Ice Cream</h1> <p class="cream_text">tempor incididunt ut labore et dolore magna aliqua</p> </div> </div> <div class="cream_section_2"> <div class="row"> <div class="col-md-4"> <div class="cream_box"> <div class="cream_img"><img src="{% static 'images/img-1.png' %}"></div> <div class="price_text">$10</div> <h6 class="strawberry_text">Strawberry Ice Cream</h6> <div class="cart_bt"><a href="#">Add To Cart</a></div> </div> </div> <div class="col-md-4"> <div class="cream_box"> <div class="cream_img"><img src="{% static 'images/img-2.png' %}"></div> <div class="price_text">$10</div> <h6 class="strawberry_text">Strawberry Ice Cream</h6> <div class="cart_bt"><a href="#">Add To Cart</a></div> </div> </div> <div class="col-md-4"> <div class="cream_box"> <div class="cream_img"><img src="{% static 'images/img-1.png' %}"></div> <div class="price_text">$10</div> <h6 class="strawberry_text">Strawberry Ice Cream</h6> <div class="cart_bt"><a href="#">Add To Cart</a></div> </div> </div> </div> </div> <div class="cream_section_2"> <div class="row"> <div class="col-md-4"> <div class="cream_box"> <div class="cream_img"><img src="{% static 'images/img-3.png' %}"></div> <div class="price_text">$10</div> <h6 class="strawberry_text">Strawberry Ice Cream</h6> <div class="cart_bt"><a href="#">Add To Cart</a></div> </div> </div> <div class="col-md-4"> <div class="cream_box"> <div class="cream_img"><img src="{% static 'images/img-4.png' %}"></div> <div class="price_text">$10</div> <h6 class="strawberry_text">Strawberry Ice Cream</h6> <div class="cart_bt"><a href="#">Add To Cart</a></div> </div> </div> <div class="col-md-4"> <div class="cream_box"> <div class="cream_img"><img src="{% static 'images/img-5.png' %}"></div> <div class="price_text">$10</div> <h6 class="strawberry_text">Strawberry Ice Cream</h6> <div class="cart_bt"><a href="#">Add To Cart</a></div> </div> </div> </div> </div> <div class="seemore_bt"><a href="#">See More</a></div> </div> </div> <!-- cream sectuion end --> <!-- services section start --> <div class="services_section layout_padding"> <div class="container"> <div class="row"> <div class="col-md-12"> <h1 class="services_taital">Our Ice Cream Services</h1> <p class="services_text">tempor incididunt ut labore et dolore magna aliqua</p> </div> </div> <div class="services_section_2"> <div class="row"> <div class="col-md-4"> <div class="services_box"> <h5 class="tasty_text"><span class="icon_img"><img src="{% static 'images/icon-1.png' %}"></span>Cookies Ice Cream</h5> <p class="lorem_text">commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fat </p> </div> </div> <div class="col-md-4"> <div class="services_box"> <h5 class="tasty_text"><span class="icon_img"><img src="{% static 'images/icon-2.png' %}"></span>Cookies Ice Cream</h5> <p class="lorem_text">commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fat </p> </div> </div> <div class="col-md-4"> <div class="services_box"> <h5 class="tasty_text"><span class="icon_img"><img src="{% static 'images/icon-1.png' %}"></span>Cookies Ice Cream</h5> <p class="lorem_text">commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fat </p> </div> </div> </div> </div> <div class="seemore_bt"><a href="#">Read More</a></div> </div> </div> <!-- services section end --> <!-- testimonial section start --> <div class="testimonial_section layout_padding"> <div class="container"> <div class="row"> <div class="col-md-12"> <h1 class="testimonial_taital">Testimonial</h1> </div> </div> <div class="testimonial_section_2"> <div class="row"> <div class="col-md-12"> <div class="testimonial_box"> <div id="main_slider" class="carousel slide" data-ride="carousel"> <div class="carousel-inner"> <div class="carousel-item active"> <p class="testimonial_text">tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint</p> <h4 class="client_name">Marri Fen</h4> <div class="client_img"><img src="{% static 'images/client-img.png' %}"></div> </div> <div class="carousel-item"> <p class="testimonial_text">tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint</p> <h4 class="client_name">Marri Fen</h4> <div class="client_img"><img src="{% static 'images/client-img.png' %}"></div> </div> <div class="carousel-item"> <p class="testimonial_text">tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint</p> <h4 class="client_name">Marri Fen</h4> <div class="client_img"><img src="{% static 'images/client-img.png' %}"></div> </div> </div> <a class="carousel-control-prev" href="#main_slider" role="button" data-slide="prev"> <i class="fa fa-angle-left"></i> </a> <a class="carousel-control-next" href="#main_slider" role="button" data-slide="next"> <i class="fa fa-angle-right"></i> </a> </div> </div> </div> </div> </div> </div> </div> <!-- testimonial section end --> <!-- contact section start --> <div class="contact_section layout_padding"> <div class="container"> <div class="row"> <div class="col-md-4"> <div class="contact_main"> <h1 class="contact_taital">Contact Us</h1> <form action="/action_page.php"> <div class="form-group"> <input type="text" class="email-bt" placeholder="Name" name="Name"> </div> <div class="form-group"> <input type="text" class="email-bt" placeholder="Email" name="Name"> </div> <div class="form-group"> <input type="text" class="email-bt" placeholder="Phone Numbar" name="Email"> </div> <div class="form-group"> <textarea class="massage-bt" placeholder="Massage" rows="5" id="comment" name="Massage"></textarea> </div> </form> <div class="main_bt"><a href="#">SEND</a></div> </div> </div> <div class="col-md-8"> <div class="location_text"> <ul> <li> <a href="#"> <span class="padding_left_10 active"><i class="fa fa-map-marker" aria-hidden="true"></i></span>Making this the first true</a> </li> <li> <a href="#"> <span class="padding_left_10"><i class="fa fa-phone" aria-hidden="true"></i></span>Call : +01 1234567890 </a> </li> <li> <a href="#"> <span class="padding_left_10"><i class="fa fa-envelope" aria-hidden="true"></i></span>Email : demo@gmail.com </a> </li> </ul> </div> <div class="mail_main"> <h3 class="newsletter_text">Newsletter</h3> <div class="form-group"> <textarea class="update_mail" placeholder="Enter Your Email" rows="5" id="comment" name="Enter Your Email"></textarea> <div class="subscribe_bt"><a href="#">Subscribe</a></div> </div> </div> <div class="footer_social_icon"> <ul> <li><a href="#"><i class="fa fa-facebook" aria-hidden="true"></i></a></li> <li><a href="#"><i class="fa fa-twitter" aria-hidden="true"></i></a></li> <li><a href="#"><i class="fa fa-linkedin" aria-hidden="true"></i></a></li> <li><a href="#"><i class="fa fa-instagram" aria-hidden="true"></i></a></li> </ul> </div> </div> </div> </div> </div> <!-- contact section end --> <!-- copyright section start --> <div class="copyright_section"> <div class="container"> <p class="copyright_text">2020 All Rights Reserved. Design by <a href="https://html.design">Free Html Templates</a> Distribution by <a href="https://themewagon.com">ThemeWagon</a></p> </div> </div> <!-- copyright section end --> <!-- Javascript files--> <script src="{% static 'js/jquery.min.js' %}"></script> <script src="{% static 'js/popper.min.js' %}"></script> <script src="{% static 'js/bootstrap.bundle.min.js' %}"></script> <script src="{% static 'js/jquery-3.0.0.min.js' %}"></script> <script src="{% static 'js/plugin.js' %}"></script> <!-- sidebar --> <script src="{% static 'js/jquery.mCustomScrollbar.concat.min.js' %}"></script> <script src="{% static 'js/custom.js' %}"></script> <!-- javascript --> </body> </html> |
沒有留言:
張貼留言