Tag

Django

Browsing

Django: Advantages of Using Django 1. Security Users of Django will be impressed with the level of protection from all possible security-related errors like clickjacking, SQL injections, cross-site scripting, and forgery. 2. Full-featured Django goes well with lots of extra features, which main aim is to help with sitemaps, user authentication, and content administration. The following bonuses assist implementation in every step of web development.Web development 3. Scalability Django is the best choice for dealing with…

https://www.codementor.io/overiq/deploying-django-project-to-digitalocean-xt5s538tp sudo nano /etc/nginx/sites-available/djangobin sudo service nginx restart server { server_name www.soluball.com; rewrite ^(.*) http://domain_name.com$1 permanent; } server { server_name https://www.soluball.com; rewrite ^(.*) http://domain_name.com$1 permanent; } server { server_name 18.141.82.48; rewrite ^(.*) http://domain_name.com$1 permanent; } server { server_name soluball.com; access_log off; location /static/ { alias /home/ubuntu/soluball-django/static/; } location / { proxy_set_header Host $http_host; proxy_pass http://127.0.0.1:8000; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Real-IP $remote_addr; add_header P3P ‘CP=”ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV”‘; }…

In this tutorial I will cover how to create Django user sign up/registration, login, logout. Usually I have done it from scratch. You can checkoutout. For the examples I will use an empty Django project named college. Inside the college folder I created an app student core. So every time you see college and/or core, change to the suitable project name and app name. Basic Sign Up The most simple way to implement a user…

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 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 %}

Faster PHP Cloud Hosting