Create a model class Contact(models.Model): name = models.CharField(max_length=100) email = models.EmailField(max_length=100) subject = models.CharField(max_length=100) message = models.TextField() mobile = models.IntegerField() created_date = models.DateField(auto_now_add=True) Load View from views.py from .models import Contact def indexPageView(request): contact = Contact.objects.all() return render(request, “index.html”,{‘contact’: contact}) Print data in a template {% for contact in contact %} <h1>{{contact.name}}</h1> {% endfor %}

First, create Model class Contact(models.Model): name = models.CharField(max_length=100) email = models.EmailField(max_length=100) subject = models.CharField(max_length=100) message = models.TextField() mobile = models.IntegerField() created_date = models.DateField(auto_now_add=True) Import model within the admin from django.contrib import admin from .models import Contact # Register your models here. admin.site.register(Contact) Create superuser python manage.py createsuperuser Enter your desired username and press enter. Username: admin You will then be prompted for your desired email address: Email address: [email protected] Start server python manage.py runserver

Create a model field within models.py file class Contact(models.Model): name = models.CharField(max_length=100) email = models.EmailField(max_length=100) subject = models.CharField(max_length=100) message = models.TextField() mobile = models.IntegerField(max_length=180) created_on = models.DateTimeField(auto_now_add=True) Associate with settings.py INSTALLED_APPS = [ ‘contact.apps.ContactConfig’, ] Run migrations command python manage.py makemigrations Check Migration python manage.py showmigrations python manage.py migrate

Create a model class Page(): id: int name: str Import to View from .models import Page def indexPageView(request): page = Page() page.name =”home” page1 = Page() page1.name = “about” page2 = Page() page2.name = “contact” page = [page, page1, page2] return render(request, “index.html”, {‘page’: page}) Now add for loop to index.html {% for page in page %} <h1>{{ page.name }}</h1> {% endfor %}

There are 3 main things we need to do: set STATIC_ROOT in settings.py run python manage.py collectstatic (or python3.5 or python3.6 as appropriate) Example: python manage.py collectstatic set up a Static Files entry on the PythonAnywhere Web tab. we can also customise STATIC_URL, if we want to use a static URL prefix other than /static/ STATIC_ROOT = os.path.join(BASE_DIR, ‘assets’) Set url.py to load template from .views import indexPageView urlpatterns = [ path(”, indexPageView, name=’index’)] Now,…

What is a Web Framework? A web framework is a code library which helps you to build a flexible, scalable, and maintainable, dynamic website, web app, and web services. Different web frameworks are Zend for PHP, Ruby on Rails for Ruby, etc. What is Django? Django is a web development framework for Python which offers a standard method for fast and effective website development. It helps you to assists in building and maintaining quality web…

<?php $servername = “localhost”; $username = “username”; $password = “password”; $database_name = “databasetesting”; // Create connection $conn = mysqli_connect($servername, $username, $password, $database_name); // Check connection if (!$conn) { die(“Connection failed: ” . mysqli_connect_error()); } echo “Connected successfully”; ?>

benefits of ssh if we have set up one time we don’t need to put username and password again and again. Open a terminal on Linux or macOS, or Git Bash / WSL on Windows. Step 1: Generate a new SSH key pair: ssh-keygen Step 2: now copy code from User/username/.ssh folder and open file id_rsa.pub copy code form this file and post in the gitlab account https://gitlab.com/profile/keys now upload code in the profile section…

fork is a clone. It emerged because you cannot push to others’ copies without their permission. They make a copy of it for you (fork), where you will have write permission as well. Step 1: Login your account and go to your project Step 2: Select your project and click on fork if you get the message No available namespaces to fork the project. then click on groups->yourgroup from the menu and create a new…

Step 1: Download git from https://git-scm.com/downloads Step 2: check git version in your machine git –version Step 3: Set global user git config –global user.name “” check user git config –global user.name git config –global user.email “” check email set in global git config –global user.email Now check list of global git config –global –list Step 4: Create a project in your system Step 5: Open terminal in mac or open cmd or git bash…