One place for hosting & domains

      Framework

      Make Material Design Websites with the Materialize CSS Framework

      Introduction

      Materialize is a Responsive CSS Framework based on Google’s Material Design Language. In this tutorial I will explain what material design is and then we will build a portfolio website using Materialize. I will also compare Materialize with other popular CSS frameworks like Foundation and Bootstrap.

      Material Design is a Design Language that challenges to create a visual language for users that synthesizes the classic principles of good design with the innovation and possibility of technology and science.

      Other competitive design languages are flat design, metro design, realism design etc. Material differs from them on the basics of color schemes, shapes, patterns, textures, or layouts. Material is the only design language that adds motion and depth to elements.

      In material design, everything should have a certain z-depth that determines how far raised or close to the page the element is.

      As the user interacts with the design, due to motion, the design transforms and reorganizes itself on a continuity fashion.

      According to the official website, “Materialize is a modern responsive front-end framework based on Material Design”. So it’s just one of the many CSS frameworks like Bootstrap, Foundation etc.

      The difference between Materialize, Bootstrap, and Foundation is that Materialize is based on Google’s Material Design language where as bootstrap and foundation are based on the mobile first design language and flat design language, respectively.

      Materialize provides all CSS and JS components that are provided by bootstrap and foundation.

      You can download Materialize CSS and JS files from Materialize Download Page. Now create index.html and css/style.css files. And finally create an images directory where the images for our project will be kept in.

      Here is how our project directory will look:

          ----- css/
          ---------- materialize.min.css
          ---------- style.css
          ----- js/
          ---------- materialize.min.js
          ----- images/
          - index.html
      

      Here is the starting code in our index.html file. Here we are loading the Materialize CSS and JS library and, also, our custom style.css file.

          <html>
          <head>
      
            <title>Materialize CSS Framework Demo</title>
            <meta name="viewport" content="width=device-width, initial-scale=1"/>
      
            <link type="text/css" rel="stylesheet" href="css/materialize.min.css"  media="screen,projection"/>
            <link type="text/css" rel="stylesheet" href="css/style.css">
      
          </head>
          <body>
      
            
            <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
            <script type="text/javascript" src="js/materialize.min.js"></script>
            <script type="text/javascript">
              //custom JS code
            </script>
      
          </body>
          </html>
      

      Material Design is based on some predefined colors. Materialize provides classes to provide those colors to font and background.

      Here is an example:

      BACKGROUND COLOR

          <div class="card-panel teal lighten-2">This is a card panel with a teal lighten-2 class</div>
      

      TEXT COLOR

          <div class="card-panel">
            <span class="blue-text text-darken-2">This is a card panel with dark blue text</span>
          </div>
      

      See the Pen yyMjVO by Narayan Prusty (@qnimate) on CodePen.

      Materialize uses the standard 12 column fluid responsive grid system.

      The .container class is not strictly part of the grid, but it is important in laying out content. It allows you to center your page content. The container class is set to ~70% of the window width. It helps you center and contain your page content. We use the container to contain our body content.

      .row class holds the grid. The .s, .m and .l classes are used to define the width of columns for small, medium, and large screens.

      Here is an example:

          <div class="container">
            <div class="row">
              <div class="blue lighten-5 col s12 m1 l1">1</div>
              <div class="blue lighten-4 col s12 m1 l1">1</div>
              <div class="blue lighten-3 col s12 m1 l1">1</div>
              <div class="blue lighten-2 col s12 m2 l2">2</div>
              <div class="blue lighten-1 col s12 m3 l3">2</div>
              <div class="blue col s12 m4 l4">2</div>
            </div>
          </div>
      

      See the Pen xbqjrP by Narayan Prusty (@qnimate) on CodePen.

      Complete Materialize Color Palette

      SideNav is a navigation that works on all widths. It toggles from the left/right side of viewport.

      Here is an example:

          <ul id="slide-out" class="side-nav full">
            <li><a href="#!">First Sidebar Link</a></li>
            <li><a href="#!">Second Sidebar Link</a></li>
          </ul>
      
          <a href="#" data-activates="slide-out" class="button-collapse">
            <i class="large mdi-navigation-menu"></i>
          </a>
      

      See the Pen zxZLGg by Narayan Prusty (@qnimate) on CodePen.

      You can easily, vertically center things by adding the class valign-wrapper to the container, holding the items you want to vertically align.

          <div class="box valign-wrapper">
            <h5>Vertical</h5>
          </div>
      

      See the Pen rayvgp by Narayan Prusty (@qnimate) on CodePen.

      In material design, everything should have a certain z-depth that determines how far raised or close to the page the element is.

      You can easily apply this shadow effect by adding a class=“z-depth-n” to an HTML tag.

          <p class="z-depth-1">z-depth-1</p>
          <p class="z-depth-2">z-depth-2</p>
          <p class="z-depth-3">z-depth-3</p>
          <p class="z-depth-4">z-depth-4</p>
          <p class="z-depth-5">z-depth-5</p>
      

      See the Pen vExrBq by Narayan Prusty (@qnimate) on CodePen.

      There are two main button types described in material design. The raised button is a standard button that signify actions and seeks to give depth to a mostly flat page. The floating, circular action button is meant for very important functions.

          <a class="waves-effect waves-light btn">Stuff</a>
          <a class="waves-effect waves-light btn"><i class="mdi-file-cloud left"></i>button</a>
          <a class="waves-effect waves-light btn"><i class="mdi-file-cloud right"></i>button</a>
          <a class="btn-floating btn-large waves-effect waves-light red"><i class="mdi-content-add"></i></a>
      

      See the Pen GgWGJg by Narayan Prusty (@qnimate) on CodePen.

      Forms are the standard way to receive user inputted data. The transitions and smoothness of these elements are very important because of the inherent user interaction associated with forms.

      Text fields allow user input. The border should light up simply and clearly indicating which field the user is currently editing. You must have an .input-field div wrapping your input and label. This helps our jQuery animate the label. This is only used in our Input and Textarea to form elements.

      If you don’t want the Green and Red validation states, just remove the validate class from your inputs.

          <div class="row">
            <form class="col s12">
              <div class="row">
                <div class="input-field col s6">
                  <input id="first_name" type="text" class="validate">
                  <label for="first_name">First Name</label>
                </div>
                <div class="input-field col s6">
                  <input id="last_name" type="text" class="validate">
                  <label for="last_name">Last Name</label>
                </div>
              </div>
              <div class="row">
                <div class="input-field col s12">
                  <input id="username" type="text" class="validate">
                  <label for="username">Username</label>
                </div>
              </div>
              <div class="row">
                <div class="input-field col s12">
                  <input id="password" type="password" class="validate">
                  <label for="password">Password</label>
                </div>
              </div>
              <div class="row">
                <div class="input-field col s12">
                  <input id="email" type="email" class="validate">
                  <label for="email">Email</label>
                </div>
              </div>
            </form>
          </div>
      

      See the Pen PwpabN by Narayan Prusty (@qnimate) on CodePen.

      Materialize has included 740 Material Design Icons, courtesy of Google. The icons font file is embedded into the Materialize CSS file in form of Data URI. Icon classes use pseudo elements to select the HTML element and use generated content to populate it with icons using the icon’s UNICODE.

      To use these icons, just place the name of the icon into the class of an HTML tag

      To control the size of the icon, change the font-size property of your icon. Optionally, you can use small, large and medium.

                <i class="small mdi-content-add"></i>
      
                <i class="medium mdi-content-add"></i>
      
                <i class="large mdi-content-add"></i>
      

      See the Pen ByWVRQ by Narayan Prusty (@qnimate) on CodePen.

      The tabs structure consists of an unordered list of tabs that have hashes corresponding to tab ids. Then, when you click on each tab, only the container with the corresponding tab id will become visible.

           <div class="row">
              <div class="col s12">
                <ul class="tabs">
                  <li class="tab col s3"><a href="#test1">Test 1</a></li>
                  <li class="tab col s3"><a class="active" href="#test2">Test 2</a></li>
                  <li class="tab col s3"><a href="#test3">Test 3</a></li>
                  <li class="tab col s3"><a href="#test4">Test 4</a></li>
                </ul>
              </div>
              <div id="test1" class="col s12">Test 1</div>
              <div id="test2" class="col s12">Test 2</div>
              <div id="test3" class="col s12">Test 3</div>
              <div id="test4" class="col s12">Test 4</div>
            </div>
      

      See the Pen LEWrQw by Narayan Prusty (@qnimate) on CodePen.

      Material box is a material design implementation of the Lightbox plugin, when a user clicks on an image that can be enlarged. Material box centers the image and enlarges it in a smooth, non-jarring manner. To dismiss the image, the user can either click on the image again, scroll away, or press the ESC key.

      It is very easy to add a short caption to your photo. Just add the caption as a data-caption attribute.

               <img class="materialboxed" width="300" src="https://cask.scotch.io/2015/01/784014790032582570.png" data-caption="Materialize Demo">
      

      See the Pen PwpaRb by Narayan Prusty (@qnimate) on CodePen.

      Add a dropdown list to any button. Make sure that the data-activates attribute matches the id in the <ul> tag.

      You can add a divider with the <li class="divider"></li> tag.

            
            <a class='dropdown-button btn' href='#' data-activates='dropdown1'>Drop Me!</a>
      
            
            <ul id='dropdown1' class='dropdown-content'>
              <li><a href="#!">one</a></li>
              <li><a href="#!">two</a></li>
              <li class="divider"></li>
              <li><a href="#!">three</a></li>
            </ul>
      

      See the Pen bNqKKr by Narayan Prusty (@qnimate) on CodePen.

      We covered some of the most important components of Materialize CSS Framework. Its time to put them together and create a portfolio site. Complete demo of the portfolio site which we will be creating in this tutorial.

      Introduction Banner

      In our portfolio site, first, we will have a big horizontal banner which displays your name and profession. We can create this using Materialize text formatting tags and little CSS.

          <div class="intro deep-orange lighten-2 z-depth-1">
            <h1 class="grey-text text-lighten-5">narayan prusty</h1>
            <h5 class="grey lighten-4 grey-text text-darken-1">web and mobile developer</h5>
          </div>
      

      See the Pen vExrvG by Narayan Prusty (@qnimate) on CodePen.

      Detail Information

      We need to display bio, profile, and current job statuses in our portfolio. For this, we can create a 3 column grid. This grid is 3 column is medium and large screen, but on mobile phones it’s stacked.

          <div class="container about">
            <h5>about me</h5>
            <h6>let me introduce my self</h6>
            <hr>
            <div class="row">
              <div class="col s12 m4 l4">
                <h6>Story</h6>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing 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.</p>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
              </div>
              <div class="col s12 m4 l4">
                <h6>Profile</h6>
                <div class="card blue-grey darken-1">
                  <div class="card-content white-text">
                    <img src="http://labs.qnimate.com/portfolio-materialize/images/profile.png" width="64" height="64">
                    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore.</p>
                  </div>
                  <div class="card-action">
                    <a href="#">Link</a>
                    <a href='#'>Link</a>
                  </div>
                </div>
              </div>
              <div class="col s12 m4 l4">
                <h6>current jobs</h6>
                <ul class="collapsible">
                  <li class="active">
                    <div class="collapsible-header"><i class="mdi-av-web"></i>Designer</div>
                    <div class="collapsible-body"><p>Lorem ipsum dolor sit amet.</p></div>
                  </li>
                  <li>
                    <div class="collapsible-header"><i class="mdi-editor-format-align-justify"></i>Developer</div>
                    <div class="collapsible-body"><p>Lorem ipsum dolor sit amet.</p></div>
                  </li>
                  <li>
                    <div class="collapsible-header"><i class="mdi-av-play-shopping-bag"></i>Video Editor</div>
                    <div class="collapsible-body"><p>Lorem ipsum dolor sit amet.</p></div>
                  </li>
                  <li>
                    <div class="collapsible-header"><i class="mdi-editor-insert-comment"></i>Support Asst.</div>
                    <div class="collapsible-body"><p>Lorem ipsum dolor sit amet.</p></div>
                  </li>
                </ul>
              </div>
            </div>
          </div>
      

      See the Pen WbpyPM by Narayan Prusty (@qnimate) on CodePen.

      We used Materialize cards in Middle column. Cards are a convenient means of displaying content composed of different types of objects. They’re also well-suited for presenting similar objects whose size or supported actions can vary considerably, like photos with captions of variable length.

      Here we used Material Collapsible in the last column. Collapsibles are accordion elements that expand when clicked on. They allow you to hide content that is not immediately relevant to the user.

      Displaying Projects

      You need to also display some of your awesome work on your portfolio. You’ll need a image of your work and a title/link.

      We will display projects via floated material boxes.

          <div class="container portfolio">
            <h5>portfolio</h5>
            <h6>MY LATEST PROJECTS</h6>
            <hr>
            <div class="row">
              <div class="col s12 m12 l12 portfolio-holder">
                <img class="materialboxed" src="http://labs.qnimate.com/portfolio-materialize/images/project.png">
                <img class="materialboxed" src="http://labs.qnimate.com/portfolio-materialize/images/project.png">
                <img class="materialboxed" src="http://labs.qnimate.com/portfolio-materialize/images/project.png">
                <img class="materialboxed" src="http://labs.qnimate.com/portfolio-materialize/images/project.png">
                <img class="materialboxed" src="http://labs.qnimate.com/portfolio-materialize/images/project.png">
                <img class="materialboxed" src="http://labs.qnimate.com/portfolio-materialize/images/project.png">
              </div>
            </div>
          </div>
      

      See the Pen GgWGLr by Narayan Prusty (@qnimate) on CodePen.

      Displaying Contact Information

      We need to display a contact form in case the user wants to contact us. We have the capacity to display a phone number, an address, and an email address for other ways to communicate.

      We can build the form using Material form classes.

          <div class="container contact">
            <h5>contact</h5>
            <h6>get in touch with me</h6>
            <hr>
            <div class="row">
              <div class="col s12 m6 l6">
                <div class="row">
                  <form class="col s12">
                    <div class="row">
                      <div class="input-field col s6">
                        <input id="first_name" type="text" class="validate">
                        <label for="first_name">First Name</label>
                      </div>
                      <div class="input-field col s6">
                        <input id="last_name" type="text" class="validate">
                        <label for="last_name">Last Name</label>
                      </div>
                    </div>
                    <div class="row">
                      <div class="input-field col s12">
                        <input id="email" type="email" class="validate">
                        <label for="email">E-Mail</label>
                      </div>
                    </div>
                    <textarea class="materialize-textarea" placeholder="Your Message" required></textarea>
                    <button class="btn waves-effect waves-light" type="submit" name="action">Submit
                      <i class="mdi-content-send right"></i>
                    </button>
                  </form>
                </div>
              </div>
              <div class="col s12 m6 l6 contact-holder">
                <h6 class="mdi-action-home">Address</h6>
                <p>Nr. 6, 21 Awesome Street, London, UK</p>
                <h6 class="mdi-hardware-phone-android">Phone Number</h6>
                <p>+91 9912776151</p>
                <h6 class="mdi-action-open-in-browser">Website</h6>
                <p>qnimate.com</p>
              </div>
            </div>
          </div>
      

      See the Pen vExrwX by Narayan Prusty (@qnimate) on CodePen.

      At the bottom of the site we will keep a footer which displays a copyright text and a link. Materialize provides classes to create a footer in no time.

          <footer>
            <div class="footer-copyright">
              <div class="container">
              © 2014 Copyright Text
              <a class="grey-text text-lighten-4 right" href="#!">Link</a>
              </div>
            </div>
          </footer>
      

      See the Pen WbpKbJ by Narayan Prusty (@qnimate) on CodePen.

      We saw some of the features and components of Material Design. There are lot more components offered by Materialize so that you can build any kind of website frontend.

      If you’re planning to create a new website or redesign your site, then I recommend to choose Materialize Framework, because there are very few sites which are material designed and your site will stand out of the crowd. You can also use Materialize in designing hybrid mobile apps. Please share your experiences with Materialize below.

      Building a REST API With Django REST Framework


      How to Join

      This Tech Talk is free and open to everyone. Register below to get a link to join the live stream or receive the video recording after it airs.

      DateTimeRSVP
      April 28, 202111:00–12:00 p.m. ET / 3:00–4:00 p.m. GMT

      About the Talk

      The Django REST Framework is a powerful toolkit for building RESTful APIs on top of the popular Python framework Django. With its browsable API, robust authentication policies, and object serialization, it offers an amazing experience for rapidly creating REST APIs. Let’s get our hands dirty and build some APIs with DRF!

      What You’ll Learn

      • How to install the Django REST Framework
      • How to authenticate against the DRF
      • How to quickly create a CRUD based REST API

      This Talk Is Designed For

      Developers who want to build robust RESTful APIs using Python.

      Prerequisites

      A basic understanding of the Python programming language.

      Resources

      Django REST framework quickstart

      To join the live Tech Talk, register here.



      Source link

      How To Install the Django Web Framework on Ubuntu 20.04


      Not using Ubuntu 20.04?


      Choose a different version or distribution.

      Introduction

      Django is a full-featured Python web framework for developing dynamic websites and applications. Using Django, you can quickly create Python web applications and rely on the framework to do a good deal of the heavy lifting.

      In this guide, you will get Django up and running on an Ubuntu 20.04 server. After installation, you will start a new project to use as the basis for your site.

      Different Methods

      There are different ways to install Django, depending upon your needs and how you want to configure your development environment. These have different advantages and one method may lend itself better to your specific situation than others.

      Some of the different methods include:

      • Global install from packages: The official Ubuntu repositories contain Django packages that can be installed with the conventional apt package manager. This is simple, but not as flexible as some other methods. Also, the version contained in the repositories may lag behind the official versions available from the project.
      • Install with pip in a virtual environment: You can create a self-contained environment for your projects using tools like venv and virtualenv. A virtual environment allows you to install Django in a project directory without affecting the larger system, along with other per-project customizations and packages. This is typically the most practical and recommended approach to working with Django.
      • Install the development version with git: If you wish to install the latest development version instead of the stable release, you can acquire the code from the Git repo. This is necessary to get the latest features/fixes and can be done within your virtual environment. Development versions do not have the same stability guarantees as more stable versions, however.

      Prerequisites

      Before you begin, you should have a non-root user with sudo privileges available on your Ubuntu 20.04 server. To set this up, follow our Ubuntu 20.04 initial server setup guide.

      Global Install from Packages

      If you wish to install Django using the Ubuntu repositories, the process is very straightforward.

      First, update your local package index with apt:

      Next, check which version of Python you have installed. 20.04 ships with Python 3.8 by default, which you can verify by typing:

      You should see output like this:

      Output

      Python 3.8.2

      Next, install Django:

      • sudo apt install python3-django

      You can test that the installation was successful by typing:

      Output

      2.2.12

      This means that the software was successfully installed. You may also notice that the Django version is not the latest stable version. To learn more about how to use the software, skip ahead to learn how to create sample project.

      Install with pip in a Virtual Environment

      The most flexible way to install Django on your system is within a virtual environment. We will show you how to install Django in a virtual environment that we will create with the venv module, part of the standard Python 3 library. This tool allows you to create virtual Python environments and install Python packages without affecting the rest of the system. You can therefore select Python packages on a per-project basis, regardless of conflicts with other projects’ requirements.

      Let’s begin by refreshing the local package index:

      Check the version of Python you have installed:

      Output

      Python 3.8.2

      Next, let’s install pip and venv from the Ubuntu repositories:

      • sudo apt install python3-pip python3-venv

      Now, whenever you start a new project, you can create a virtual environment for it. Start by creating and moving into a new project directory:

      • mkdir ~/newproject
      • cd ~/newproject

      Next, create a virtual environment within the project directory using the python command that’s compatible with your version of Python. We will call our virtual environment my_env, but you should name it something descriptive:

      This will install standalone versions of Python and pip into an isolated directory structure within your project directory. A directory will be created with the name you select, which will hold the file hierarchy where your packages will be installed.

      To install packages into the isolated environment, you must activate it by typing:

      • source my_env/bin/activate

      Your prompt should change to reflect that you are now in your virtual environment. It will look something like (my_env)username@hostname:~/newproject$.

      In your new environment, you can use pip to install Django. Regardless of your Python version, pip should just be called pip when you are in your virtual environment. Also note that you do not need to use sudo since you are installing locally:

      You can verify the installation by typing:

      Output

      3.0.8

      Note that your version may differ from the version shown here.

      To leave your virtual environment, you need to issue the deactivate command from anywhere on the system:

      Your prompt should revert to the conventional display. When you wish to work on your project again, re-activate your virtual environment by moving back into your project directory and activating:

      • cd ~/newproject
      • source my_env/bin/activate

      Development Version Install with Git

      If you need a development version of Django, you can download and install Django from its Git repository. Let’s do this from within a virtual environment.

      First, let’s update the local package index:

      Check the version of Python you have installed:

      Output

      Python 3.8.2

      Next, install pip and venv from the official repositories:

      • sudo apt install python3-pip python3-venv

      The next step is cloning the Django repository. Between releases, this repository will have more up-to-date features and bug fixes at the possible expense of stability. You can clone the repository to a directory called ~/django-dev within your home directory by typing:

      • git clone git://github.com/django/django ~/django-dev

      Change to this directory:

      Create a virtual environment using the python command that’s compatible with your installed version of Python:

      Activate it:

      • source my_env/bin/activate

      Next, you can install the repository using pip. The -e option will install in “editable” mode, which is necessary when installing from version control:

      • pip install -e ~/django-dev

      You can verify that the installation was successful by typing:

      Output

      3.2

      Again, the version you see displayed may not match what is shown here.

      You now have the latest version of Django in your virtual environment.

      Creating a Sample Project

      With Django installed, you can begin building your project. We will go over how to create a project and test it on your development server using a virtual environment.

      First, create a directory for your project and change into it:

      • mkdir ~/django-test
      • cd ~/django-test

      Next, create your virtual environment:

      Activate the environment:

      • source my_env/bin/activate

      Install Django:

      To build your project, you can use django-admin with the startproject command. We will call our project djangoproject, but you can replace this with a different name. startproject will create a directory within your current working directory that includes:

      • A management script, manage.py, which you can use to administer various Django-specific tasks.
      • A directory (with the same name as the project) that includes the actual project code.

      To avoid having too many nested directories, however, let’s tell Django to place the management script and inner directory in the current directory (notice the ending dot):

      • django-admin startproject djangoproject .

      To migrate the database (this example uses SQLite by default), let’s use the migrate command with manage.py. Migrations apply any changes you’ve made to your Django models to your database schema.

      To migrate the database, type:

      You will see output like the following:

      Output

      Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions Running migrations: Applying contenttypes.0001_initial... OK Applying auth.0001_initial... OK Applying admin.0001_initial... OK Applying admin.0002_logentry_remove_auto_add... OK Applying admin.0003_logentry_add_action_flag_choices... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying auth.0007_alter_validators_add_error_messages... OK Applying auth.0008_alter_user_username_max_length... OK Applying auth.0009_alter_user_last_name_max_length... OK Applying sessions.0001_initial... OK

      Finally, let’s create an administrative user so that you can use the Djano admin interface. Let’s do this with the createsuperuser command:

      • python manage.py createsuperuser

      You will be prompted for a username, an email address, and a password for your user.

      Modifying ALLOWED_HOSTS in the Django Settings

      To successfully test your application, you will need to modify one of the directives in the Django settings.

      Open the settings file by typing:

      • nano ~/django-test/djangoproject/settings.py

      Inside, locate the ALLOWED_HOSTS directive. This defines a list of addresses or domain names that may be used to connect to the Django instance. An incoming request with a Host header that is not in this list will raise an exception. Django requires that you set this to prevent a certain class of security vulnerability.

      In the square brackets, list the IP addresses or domain names that are associated with your Django server. Each item should be listed in quotations, with separate entries separated by a comma. If you want requests for an entire domain and any subdomains, prepend a period to the beginning of the entry:

      ~/django-test/djangoproject/settings.py

      ALLOWED_HOSTS = ['your_server_ip_or_domain', 'your_second_ip_or_domain', . . .]
      

      When you are finished, save the file and exit your editor.

      Testing the Development Server

      Once you have a user, you can start up the Django development server to see what a fresh Django project looks like. You should only use this for development purposes. When you are ready to deploy, be sure to follow Django’s guidelines on deployment carefully.

      Before you try the development server, make sure you open the appropriate port in your firewall. If you followed the initial server setup guide and are using UFW, you can open port 8000 by typing:

      Start the development server:

      • python manage.py runserver your_server_ip:8000

      Visit your server’s IP address followed by :8000 in your web browser:

      http://your_server_ip:8000
      

      You should see something that looks like this:

      Django public page

      To access the admin interface, add /admin/ to the end of your URL:

      http://your_server_ip:8000/admin/
      

      This will take you to a log in screen:

      Django admin login

      If you enter the admin username and password that you just created, you will have access to the main admin section of the site:

      Django admin page

      For more information about working with the Django admin interface, please see “How To Enable and Connect the Django Admin Interface.”

      When you are finished looking through the default site, you can stop the development server by typing CTRL-C in your terminal.

      The Django project you’ve created provides the structural basis for designing a more complete site. Check out the Django documentation for more information about how to build your applications and customize your site.

      Conclusion

      You should now have Django installed on your Ubuntu 20.04 server, providing the main tools you need to create powerful web applications. You should also know how to start a new project and launch the developer server. Leveraging a complete web framework like Django can help make development faster, allowing you to concentrate only on the unique aspects of your applications.

      If you would like more information about working with Django, including in-depth discussions of things like models and views, please see our Django development series.



      Source link