
Add Institution / Company

Show code
models.py Code
from django.db import models
from django_countries.fields import CountryField
# Create your models here.
class Institution(models.Model):
class Institution(models.Model):
CATEGORY_CHOICES = (('Specialization certificate', 'Specialization certificate'),
('Professional certificate', 'Professional certificate'))
category = models.CharField(max_length=50, choices=CATEGORY_CHOICES)
name = models.CharField(max_length=50, unique=True)
def __str__(self):
return self.name
forms.py Code
class InstitutionForm(forms.ModelForm):
class Meta:
model = Institution
fields = '__all__'
widgets = {
'name': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Input Name of Specialization', }),
'category': forms.Select(attrs={'class': 'form-control', "placeholder": "Select Institution / Company", }),
}
Template Code
Django Engine template
{% extends 'base.html' %}
{% block content %}
{% load static %}
{% load fontawesome_5 %}
{{ STATIC_URL }}
{% load pygmentize %}
{% load crispy_forms_tags %}
<br><br>
<section class="container-section mb-4 mt-8">
<div class="container-fluid">
<div class="row g-0">
<div class="portfolio-box-caption">
<div class="row">
<div class="col-1"><img src="{% static 'img/worldwide.gif' %}" alt="Skills"></div>
<div class="col">
<h2 class="portfolio-box-headers" style="text-align:center">
Add Institution / Company</h2>
</div>
</div>
</div>
<hr>
<div class="container border p-3 mb-3 bg-light text-dark" id="specialization">
<form action="" method="POST">
{% csrf_token %}
<div class="form-group row mt-8">
<div class="col-md-6 mb-0">
{{ form.name|as_crispy_field }}
</div>
<div class="col-md-6 mb-0">
{{ form.category|as_crispy_field }}
</div>
</div>
{% if user.is_authenticated %}
<div class="d-grid col-6">
<button type="submit" id="btn-enviar" class="btn btn-warning btn-lg">Enviar</button>
</div>
{% endif %}
</form>
</div>
</div>
</div>
</section>
<section class="container-section mb-4 mt-8">
<div class="container-fluid">
<div class="row g-0">
<div class="portfolio-box-caption">
<div class="row">
<div class="col-1"><img src="{% static 'img/worldwide.gif' %}" alt="Skills"></div>
<div class="col">
<h2 class="portfolio-box-headers" style="text-align:center">
Show code</h2>
</div>
</div>
</div>
<hr>
<div class="container mb-4">
<div class="row mb-4">
<div class="col-sm-6 col-xs-12">
<h4>models.py Code</h4>
<div class="sourcecode">
{{ models|pygmentize:"python3" }}
</div>
</div>
<div class="col-sm-6 col-xs-12">
<h4>forms.py Code</h4>
<div class="sourcecode">
{{ forms|pygmentize:"python3" }}
</div>
</div>
</div>
<hr>
<div class="row">
<h4>Template Code</h4>
<p>Django Engine template</p>
<div class="sourcecode">
{{ template|pygmentize:"html" }}
</div>
</div>
</div>
</div>
</div>
</section>
{% endblock %}