4# added pagination
This commit is contained in:
parent
df87060fe2
commit
4326743bee
@ -1,3 +1,4 @@
|
||||
from django.contrib import admin
|
||||
from .models import Job
|
||||
|
||||
# Register your models here.
|
||||
admin.site.register(Job)
|
||||
|
31
jobs/migrations/0001_initial.py
Normal file
31
jobs/migrations/0001_initial.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Generated by Django 3.1.4 on 2020-12-30 19:24
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Job',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=300)),
|
||||
('company', models.CharField(max_length=300)),
|
||||
('job_type', models.CharField(choices=[('full_time', 'Full Time'), ('part_time', 'Part Time'), ('freelance', 'Freelance'), ('internship', 'Internship'), ('temporary', 'Temporary')], default=None, max_length=20)),
|
||||
('location', models.CharField(default=None, max_length=200)),
|
||||
('description', models.TextField(default=None)),
|
||||
('publishing_date', models.DateTimeField(auto_now_add=True)),
|
||||
('slug', models.SlugField(default=None, editable=False)),
|
||||
('employer', models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
]
|
@ -1,3 +1,33 @@
|
||||
from django.db import models
|
||||
from django.template.defaultfilters import slugify
|
||||
|
||||
# Create your models here.
|
||||
from jobportal import settings
|
||||
|
||||
|
||||
class Job(models.Model):
|
||||
title = models.CharField(max_length=300)
|
||||
company = models.CharField(max_length=300)
|
||||
CHOICES = (
|
||||
('full_time', 'Full Time'),
|
||||
('part_time', 'Part Time'),
|
||||
('freelance', 'Freelance'),
|
||||
('internship', 'Internship'),
|
||||
('temporary', 'Temporary'),
|
||||
)
|
||||
|
||||
job_type = models.CharField(max_length=20, blank=False, default=None, choices=CHOICES)
|
||||
location = models.CharField(max_length=200, blank=False, default=None)
|
||||
description = models.TextField(blank=False, default=None)
|
||||
publishing_date = models.DateTimeField(auto_now_add=True)
|
||||
slug = models.SlugField(default=None, editable=False)
|
||||
employer = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, default=None)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self.slug = slugify(self.title)
|
||||
super(Job, self).save(*args, **kwargs)
|
||||
|
||||
class Meta:
|
||||
ordering = ('-id',)
|
||||
|
@ -1,5 +1,10 @@
|
||||
from django.views.generic import TemplateView
|
||||
from django.views.generic import TemplateView, ListView
|
||||
|
||||
from jobs.models import Job
|
||||
|
||||
|
||||
class HomeView(TemplateView):
|
||||
class HomeView(ListView):
|
||||
template_name = 'jobs/index.html'
|
||||
context_object_name = 'jobs'
|
||||
model = Job
|
||||
paginate_by = 1
|
||||
|
@ -223,45 +223,30 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12 ftco-animate">
|
||||
|
||||
<div class="job-post-item bg-white p-4 d-block d-md-flex align-items-center">
|
||||
|
||||
<div class="mb-4 mb-md-0 mr-5">
|
||||
<div class="job-post-item-header d-flex align-items-center">
|
||||
<h2 class="mr-3 text-black h3">Frontend Development</h2>
|
||||
<div class="badge-wrap">
|
||||
<span class="bg-primary text-white badge py-2 px-3">Partime</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="job-post-item-body d-block d-md-flex">
|
||||
<div class="mr-3"><span class="icon-layers"></span> <a href="#">Facebook, Inc.</a></div>
|
||||
<div><span class="icon-my_location"></span> <span>Western City, UK</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ml-auto d-flex">
|
||||
<a href="job-single.html" class="btn btn-primary py-2 mr-1">Apply Job</a>
|
||||
<a href="#" class="btn btn-secondary rounded-circle btn-favorite d-flex align-items-center icon">
|
||||
<span class="icon-heart"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- end -->
|
||||
|
||||
{% for job in jobs %}
|
||||
<div class="col-md-12 ftco-animate">
|
||||
<div class="job-post-item bg-white p-4 d-block d-md-flex align-items-center">
|
||||
|
||||
<div class="mb-4 mb-md-0 mr-5">
|
||||
<div class="job-post-item-header d-flex align-items-center">
|
||||
<h2 class="mr-3 text-black h4">Full Stack Developer</h2>
|
||||
<h2 class="mr-3 text-black h4">{{ job.title }}</h2>
|
||||
<div class="badge-wrap">
|
||||
{% if job.job_type == 'full_time' %}
|
||||
<span class="bg-warning text-white badge py-2 px-3">Full Time</span>
|
||||
{% elif job.job_type == 'part_time'%}
|
||||
<span class="bg-info text-white badge py-2 px-3">Part Time</span>
|
||||
{% elif job.job_type == 'freelance'%}
|
||||
<span class="bg-primary text-white badge py-2 px-3">Freelance</span>
|
||||
{% elif job.job_type == 'internship'%}
|
||||
<span class="bg-secondary text-white badge py-2 px-3">Internship</span>
|
||||
{% elif job.job_type == 'temporary'%}
|
||||
<span class="bg-danger text-white badge py-2 px-3">Temporary</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="job-post-item-body d-block d-md-flex">
|
||||
<div class="mr-3"><span class="icon-layers"></span> <a href="#">Google, Inc.</a></div>
|
||||
<div><span class="icon-my_location"></span> <span>Western City, UK</span></div>
|
||||
<div class="mr-3"><span class="icon-layers"></span> <a href="#">{{ job.company }}</a></div>
|
||||
<div><span class="icon-my_location"></span> <span>{{ job.location }}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -274,218 +259,36 @@
|
||||
|
||||
</div>
|
||||
</div> <!-- end -->
|
||||
<div class="col-md-12 ftco-animate">
|
||||
<div class="job-post-item bg-white p-4 d-block d-md-flex align-items-center">
|
||||
{% endfor %}
|
||||
|
||||
<div class="mb-4 mb-md-0 mr-5">
|
||||
<div class="job-post-item-header d-flex align-items-center">
|
||||
<h2 class="mr-3 text-black h4">Open Source Interactive Developer</h2>
|
||||
<div class="badge-wrap">
|
||||
<span class="bg-info text-white badge py-2 px-3">Freelance</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="job-post-item-body d-block d-md-flex">
|
||||
<div class="mr-3"><span class="icon-layers"></span> <a href="#">New York Times</a></div>
|
||||
<div><span class="icon-my_location"></span> <span>Western City, UK</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ml-auto d-flex">
|
||||
<a href="job-single.html" class="btn btn-primary py-2 mr-1">Apply Job</a>
|
||||
<a href="#" class="btn btn-secondary rounded-circle btn-favorite d-flex align-items-center icon">
|
||||
<span class="icon-heart"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end -->
|
||||
<div class="col-md-12 ftco-animate">
|
||||
|
||||
<div class="job-post-item bg-white p-4 d-block d-md-flex align-items-center">
|
||||
|
||||
<div class="mb-4 mb-md-0 mr-5">
|
||||
<div class="job-post-item-header d-flex align-items-center">
|
||||
<h2 class="mr-3 text-black h4">Frontend Development</h2>
|
||||
<div class="badge-wrap">
|
||||
<span class="bg-secondary text-white badge py-2 px-3">Internship</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="job-post-item-body d-block d-md-flex">
|
||||
<div class="mr-3"><span class="icon-layers"></span> <a href="#">Facebook, Inc.</a></div>
|
||||
<div><span class="icon-my_location"></span> <span>Western City, UK</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ml-auto d-flex">
|
||||
<a href="job-single.html" class="btn btn-primary py-2 mr-1">Apply Job</a>
|
||||
<a href="#" class="btn btn-secondary rounded-circle btn-favorite d-flex align-items-center icon">
|
||||
<span class="icon-heart"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end -->
|
||||
<div class="col-md-12 ftco-animate">
|
||||
<div class="job-post-item bg-white p-4 d-block d-md-flex align-items-center">
|
||||
|
||||
<div class="mb-4 mb-md-0 mr-5">
|
||||
<div class="job-post-item-header d-flex align-items-center">
|
||||
<h2 class="mr-3 text-black h4">Open Source Interactive Developer</h2>
|
||||
<div class="badge-wrap">
|
||||
<span class="bg-danger text-white badge py-2 px-3">Temporary</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="job-post-item-body d-block d-md-flex">
|
||||
<div class="mr-3"><span class="icon-layers"></span> <a href="#">New York Times</a></div>
|
||||
<div><span class="icon-my_location"></span> <span>Western City, UK</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ml-auto d-flex">
|
||||
<a href="job-single.html" class="btn btn-primary py-2 mr-1">Apply Job</a>
|
||||
<a href="#" class="btn btn-secondary rounded-circle btn-favorite d-flex align-items-center icon">
|
||||
<span class="icon-heart"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end -->
|
||||
<div class="col-md-12 ftco-animate">
|
||||
|
||||
<div class="job-post-item bg-white p-4 d-block d-md-flex align-items-center">
|
||||
|
||||
<div class="mb-4 mb-md-0 mr-5">
|
||||
<div class="job-post-item-header d-flex align-items-center">
|
||||
<h2 class="mr-3 text-black h3">Frontend Development</h2>
|
||||
<div class="badge-wrap">
|
||||
<span class="bg-primary text-white badge py-2 px-3">Partime</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="job-post-item-body d-block d-md-flex">
|
||||
<div class="mr-3"><span class="icon-layers"></span> <a href="#">Facebook, Inc.</a></div>
|
||||
<div><span class="icon-map-marker"></span> <span>Western City, UK</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ml-auto d-flex">
|
||||
<a href="job-single.html" class="btn btn-primary py-2 mr-1">Apply Job</a>
|
||||
<a href="#" class="btn btn-secondary rounded-circle btn-favorite d-flex align-items-center icon">
|
||||
<span class="icon-heart"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- end -->
|
||||
|
||||
<div class="col-md-12 ftco-animate">
|
||||
<div class="job-post-item bg-white p-4 d-block d-md-flex align-items-center">
|
||||
|
||||
<div class="mb-4 mb-md-0 mr-5">
|
||||
<div class="job-post-item-header d-flex align-items-center">
|
||||
<h2 class="mr-3 text-black h4">Full Stack Developer</h2>
|
||||
<div class="badge-wrap">
|
||||
<span class="bg-warning text-white badge py-2 px-3">Full Time</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="job-post-item-body d-block d-md-flex">
|
||||
<div class="mr-3"><span class="icon-layers"></span> <a href="#">Google, Inc.</a></div>
|
||||
<div><span class="icon-my_location"></span> <span>Western City, UK</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ml-auto d-flex">
|
||||
<a href="job-single.html" class="btn btn-primary py-2 mr-1">Apply Job</a>
|
||||
<a href="#" class="btn btn-secondary rounded-circle btn-favorite d-flex align-items-center icon">
|
||||
<span class="icon-heart"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div> <!-- end -->
|
||||
<div class="col-md-12 ftco-animate">
|
||||
<div class="job-post-item bg-white p-4 d-block d-md-flex align-items-center">
|
||||
|
||||
<div class="mb-4 mb-md-0 mr-5">
|
||||
<div class="job-post-item-header d-flex align-items-center">
|
||||
<h2 class="mr-3 text-black h4">Open Source Interactive Developer</h2>
|
||||
<div class="badge-wrap">
|
||||
<span class="bg-info text-white badge py-2 px-3">Freelance</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="job-post-item-body d-block d-md-flex">
|
||||
<div class="mr-3"><span class="icon-layers"></span> <a href="#">New York Times</a></div>
|
||||
<div><span class="icon-my_location"></span> <span>Western City, UK</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ml-auto d-flex">
|
||||
<a href="job-single.html" class="btn btn-primary py-2 mr-1">Apply Job</a>
|
||||
<a href="#" class="btn btn-secondary rounded-circle btn-favorite d-flex align-items-center icon">
|
||||
<span class="icon-heart"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end -->
|
||||
<div class="col-md-12 ftco-animate">
|
||||
|
||||
<div class="job-post-item bg-white p-4 d-block d-md-flex align-items-center">
|
||||
|
||||
<div class="mb-4 mb-md-0 mr-5">
|
||||
<div class="job-post-item-header d-flex align-items-center">
|
||||
<h2 class="mr-3 text-black h4">Frontend Development</h2>
|
||||
<div class="badge-wrap">
|
||||
<span class="bg-secondary text-white badge py-2 px-3">Internship</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="job-post-item-body d-block d-md-flex">
|
||||
<div class="mr-3"><span class="icon-layers"></span> <a href="#">Facebook, Inc.</a></div>
|
||||
<div><span class="icon-my_location"></span> <span>Western City, UK</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ml-auto d-flex">
|
||||
<a href="job-single.html" class="btn btn-primary py-2 mr-1">Apply Job</a>
|
||||
<a href="#" class="btn btn-secondary rounded-circle btn-favorite d-flex align-items-center icon">
|
||||
<span class="icon-heart"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end -->
|
||||
<div class="col-md-12 ftco-animate">
|
||||
<div class="job-post-item bg-white p-4 d-block d-md-flex align-items-center">
|
||||
|
||||
<div class="mb-4 mb-md-0 mr-5">
|
||||
<div class="job-post-item-header d-flex align-items-center">
|
||||
<h2 class="mr-3 text-black h4">Open Source Interactive Developer</h2>
|
||||
<div class="badge-wrap">
|
||||
<span class="bg-danger text-white badge py-2 px-3">Temporary</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="job-post-item-body d-block d-md-flex">
|
||||
<div class="mr-3"><span class="icon-layers"></span> <a href="#">New York Times</a></div>
|
||||
<div><span class="icon-my_location"></span> <span>Western City, UK</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ml-auto d-flex">
|
||||
<a href="job-single.html" class="btn btn-primary py-2 mr-1">Apply Job</a>
|
||||
<a href="#" class="btn btn-secondary rounded-circle btn-favorite d-flex align-items-center icon">
|
||||
<span class="icon-heart"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end -->
|
||||
</div>
|
||||
<div class="row mt-5">
|
||||
{% if is_paginated %}
|
||||
<div class="col text-center">
|
||||
<div class="block-27">
|
||||
<ul>
|
||||
<li><a href="#"><</a></li>
|
||||
<li class="active"><span>1</span></li>
|
||||
<li><a href="#">2</a></li>
|
||||
<li><a href="#">3</a></li>
|
||||
<li><a href="#">4</a></li>
|
||||
<li><a href="#">5</a></li>
|
||||
<li><a href="#">></a></li>
|
||||
{% if page_obj.has_previous %}
|
||||
<li><a href="?page={{ page_obj.previous_page_number }}"><</a></li>
|
||||
{% else %}
|
||||
<li class="disabled"><span><</span></li>
|
||||
{% endif %}
|
||||
{% for i in paginator.page_range %}
|
||||
{% if page_obj.number == i %}
|
||||
<li class="active"><span>{{ i }}</span></li>
|
||||
{% else %}
|
||||
<li><a href="?page={{ i }}">{{ i }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if page_obj.has_next %}
|
||||
<li><a href="?page={{ page_obj.next_page_number }}">></a></li>
|
||||
{% else %}
|
||||
<li class="disabled"><span>></span></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
Loading…
Reference in New Issue
Block a user