{"id":75167,"date":"2020-01-18T12:12:24","date_gmt":"2020-01-18T06:42:24","guid":{"rendered":"https:\/\/www.vskills.in\/certification\/tutorial\/?p=75167"},"modified":"2024-04-12T14:17:11","modified_gmt":"2024-04-12T08:47:11","slug":"starting-a-project","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/starting-a-project\/","title":{"rendered":"Starting a Project"},"content":{"rendered":"<p class=\"VSKILLbodytext\">A project is a collection of settings for an instance of Django, including database configuration, Django-specific options, and application-specific settings. If this is your first time using Django, you\u2019ll have to take care of some initial setup. Create a new directory to start working in, perhaps something like \/home\/username\/djcode\/, and change into that directory.<\/p>\n<p class=\"VSKILLbodytext\"><span style=\"font-size: 6.0pt;\">\u00a0<\/span><b>Note<\/b> &#8211; django-admin.py should be on your system path if you installed Django via its setup.py utility. If you checked out from Subversion, you can find it in djtrunk\/django\/bin. Since you\u2019ll be using django-admin.py often, consider adding it to your path. On Unix, you can do so by symlinking from \/usr\/local\/bin, using a command such as sudo ln -s \/path\/to\/django\/bin\/django-admin.py \/usr\/local\/bin\/django-admin.py. On Windows, you\u2019ll need to update your PATH environment variable. Run the command django-admin.py startproject mysite to create a mysite directory in your current directory. Let\u2019s look at what startproject created:<\/p>\n<pre>mysite\/\n\u00a0\u00a0\u00a0 __init__.py\n\u00a0\u00a0\u00a0 manage.py\n\u00a0\u00a0\u00a0 settings.py\n\u00a0\u00a0\u00a0 urls.py\n    <span lang=\"EN-US\">wsgi.py<\/span><\/pre>\n<p class=\"VSKILLbodytext\">These files are as follows:<\/p>\n<ul>\n<li>The outer mysite\/ root directory is just a container for your project. Its name doesn\u2019t matter to Django; you can rename it to anything you like.<\/li>\n<li>py: A command-line utility to interact with this Django project in various ways.<\/li>\n<li>The inner mysite\/ directory is the actual Python package for your project. Its name is the Python package name you\u2019ll need to use to import anything inside it (e.g. mysite.urls).<\/li>\n<li>mysite\/__init__.py: An empty file that tells Python that this directory should be considered a Python package. A file for Python to treat the directory as a package (i.e., a group of modules)<\/li>\n<li>mysite\/settings.py: Settings\/configuration for this Django project.<\/li>\n<li>mysite\/urls.py: The URL declarations for this Django project; a \u201ctable of contents\u201d of your Django-powered site.<\/li>\n<li>mysite\/wsgi.py: An entry-point for WSGI-compatible web servers to serve your project.<\/li>\n<\/ul>\n<p><strong>Where Should This Directory Live? <\/strong><\/p>\n<p>If your background is in PHP, you\u2019re probably used to putting code under the Web server\u2019s document root (in a place such as \/var\/www). With Django, you don\u2019t do that. It\u2019s not a good idea to put any of this Python code within your Web server\u2019s document root, because in doing so you risk the possibility that people will be able to view your code over the Web. That\u2019s not good for security. Put your code in some directory outside of the document root.<\/p>\n<p class=\"VSKILLbodytext\"><b><span lang=\"EN-US\">The Development Server<\/span><\/b><span lang=\"EN-US\"> &#8211; Django includes a built-in, lightweight Web server you can use while developing your site. We\u2019ve included this server so you can develop your site rapidly, without having to deal with configuring your production Web server (e.g., Apache) until you\u2019re ready for production. <\/span><\/p>\n<p class=\"VSKILLbodytext\"><span lang=\"EN-US\">\u00a0<\/span><span lang=\"EN-US\">To verify your Django project works, change into the outer mysite directory, and run the following command<\/span><\/p>\n<pre class=\"VSKILLbodytext\"><span lang=\"EN-US\">\u00a0<\/span><span lang=\"EN-US\">$ python manage.py runserver<\/span><\/pre>\n<p class=\"VSKILLbodytext\"><span lang=\"EN-US\">\u00a0<\/span><span lang=\"EN-US\">This development server watches your code for changes and automatically reloads, helping you make many rapid changes to your project without needing to restart anything. Change into the mysite directory, if you haven\u2019t already, and run the command python manage.py runserver. You\u2019ll see something like this:<\/span><\/p>\n<pre class=\"VSKILLbodytext\"><span lang=\"EN-US\" style=\"font-size: 6.0pt;\">\u00a0<\/span><span lang=\"EN-US\">Validating models...<\/span><\/pre>\n<pre style=\"margin-left: 18.0pt; tab-stops: 36.0pt;\"><span lang=\"EN-US\">0 errors found.<\/span><\/pre>\n<pre style=\"margin-left: 18.0pt; tab-stops: 36.0pt;\"><span lang=\"EN-US\">Django version 1.0, using settings 'mysite.settings'<\/span><\/pre>\n<pre style=\"margin-left: 18.0pt; tab-stops: 36.0pt;\"><span lang=\"EN-US\">Development server is running at http:\/\/127.0.0.1:8000\/<\/span><\/pre>\n<pre style=\"margin-left: 18.0pt; tab-stops: 36.0pt;\"><span lang=\"EN-US\">Quit the server with CONTROL-C.<\/span><\/pre>\n<p class=\"VSKILLbodytext\"><span lang=\"EN-US\" style=\"font-size: 6.0pt;\">\u00a0<\/span><span lang=\"EN-US\">Although the development server is extremely nice for, well, development, resist the temptation to use this server in anything resembling a production environment. The development server can handle only a single request at a time reliably, and it has not gone through a security audit of any sort. <\/span><\/p>\n<p class=\"VSKILLbodytext\"><span lang=\"EN-US\" style=\"font-size: 6.0pt;\">\u00a0<\/span><b><span lang=\"EN-US\">Changing the Host or the Port<\/span><\/b><span lang=\"EN-US\"> &#8211; By default, the runserver command starts the development server on port 8000, listening only for local connections. If you want to change the server\u2019s port, pass it as a command-line argument:<\/span><\/p>\n<pre class=\"VSKILLbodytext\"><span lang=\"EN-US\" style=\"font-size: 6.0pt;\">\u00a0<\/span><span lang=\"EN-US\">python manage.py runserver 8080<\/span><\/pre>\n<p class=\"VSKILLbodytext\"><span lang=\"EN-US\" style=\"font-size: 6.0pt;\">\u00a0<\/span><span lang=\"EN-US\">You can also change the IP address that the server listens on. This is especially helpful if you\u2019d like to share a development site with other developers. The following:<\/span><\/p>\n<pre class=\"VSKILLbodytext\"><span lang=\"EN-US\" style=\"font-size: 6.0pt;\">\u00a0<\/span><span lang=\"EN-US\">python manage.py runserver 0.0.0.0:8080<\/span><\/pre>\n<p class=\"VSKILLbodytext\"><span lang=\"EN-US\">will make Django listen on any network interface, thus DJango welcome page is shown at <a href=\"http:\/\/127.0.0.1:8000\/\"><span style=\"color: windowtext; text-decoration: none; text-underline: none;\">http:\/\/127.0.0.1:8000\/<\/span><\/a> <\/span><\/p>\n<p class=\"VSKILLbodytext\"><span lang=\"EN-US\">\u00a0<\/span><span lang=\"EN-US\">You\u2019ve started the Django development server, a lightweight Web server written purely in Python. Don\u2019t use this server in anything resembling a production environment. It\u2019s intended only for use while developing. Now that the server\u2019s running, visit http:\/\/127.0.0.1:8000\/ with your Web browser. You\u2019ll see a \u201cCongratulations!\u201d page, with a rocket taking off. It worked!<\/span><\/p>\n<p><a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/certified-django-developer\/\" target=\"_blank\" rel=\"noopener noreferrer\">Back to Tutorial<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A project is a collection of settings for an instance of Django, including database configuration, Django-specific options, and application-specific settings. If this is your first time using Django, you\u2019ll have to take care of some initial setup. Create a new directory to start working in, perhaps something like \/home\/username\/djcode\/, and change into that directory. \u00a0Note&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[8655,1],"tags":[8657],"class_list":["post-75167","page","type-page","status-publish","hentry","category-django-web-development","category-uncategorized","tag-starting-a-project"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Starting a Project - Tutorial<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/starting-a-project\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Starting a Project - Tutorial\" \/>\n<meta property=\"og:description\" content=\"A project is a collection of settings for an instance of Django, including database configuration, Django-specific options, and application-specific settings. If this is your first time using Django, you\u2019ll have to take care of some initial setup. Create a new directory to start working in, perhaps something like \/home\/username\/djcode\/, and change into that directory. \u00a0Note...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/starting-a-project\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:47:11+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/starting-a-project\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/starting-a-project\/\",\"name\":\"Starting a Project - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2020-01-18T06:42:24+00:00\",\"dateModified\":\"2024-04-12T08:47:11+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/starting-a-project\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/starting-a-project\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/starting-a-project\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Starting a Project\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Starting a Project - Tutorial","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vskills.in\/certification\/tutorial\/starting-a-project\/","og_locale":"en_US","og_type":"article","og_title":"Starting a Project - Tutorial","og_description":"A project is a collection of settings for an instance of Django, including database configuration, Django-specific options, and application-specific settings. If this is your first time using Django, you\u2019ll have to take care of some initial setup. Create a new directory to start working in, perhaps something like \/home\/username\/djcode\/, and change into that directory. \u00a0Note...","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/starting-a-project\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:47:11+00:00","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/starting-a-project\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/starting-a-project\/","name":"Starting a Project - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2020-01-18T06:42:24+00:00","dateModified":"2024-04-12T08:47:11+00:00","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/starting-a-project\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/starting-a-project\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/starting-a-project\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Starting a Project"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/75167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=75167"}],"version-history":[{"count":5,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/75167\/revisions"}],"predecessor-version":[{"id":83315,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/75167\/revisions\/83315"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=75167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=75167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=75167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}