5# added category model
This commit is contained in:
parent
4326743bee
commit
6a0da8cced
@ -84,7 +84,10 @@ DATABASES = {
|
||||
'USER': 'root',
|
||||
'PASSWORD': '',
|
||||
'HOST': 'localhost',
|
||||
'PORT': '3306'
|
||||
'PORT': '3306',
|
||||
'OPTIONS': {
|
||||
"init_command": "SET foreign_key_checks = 0",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
from django.contrib import admin
|
||||
from .models import Job
|
||||
from .models import Job, Category
|
||||
|
||||
admin.site.register(Job)
|
||||
admin.site.register(Category)
|
||||
|
31
jobs/migrations/0002_auto_20201231_1043.py
Normal file
31
jobs/migrations/0002_auto_20201231_1043.py
Normal file
@ -0,0 +1,31 @@
|
||||
# Generated by Django 3.1.4 on 2020-12-31 09:43
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jobs', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Category',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=100)),
|
||||
('slug', models.SlugField(default=None, editable=False)),
|
||||
],
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='job',
|
||||
options={'ordering': ('-id',)},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='job',
|
||||
name='category',
|
||||
field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, related_name='jobs', to='jobs.category'),
|
||||
),
|
||||
]
|
19
jobs/migrations/0003_auto_20201231_1050.py
Normal file
19
jobs/migrations/0003_auto_20201231_1050.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Generated by Django 3.1.4 on 2020-12-31 09:50
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jobs', '0002_auto_20201231_1043'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='job',
|
||||
name='category',
|
||||
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='jobs', to='jobs.category'),
|
||||
),
|
||||
]
|
20
jobs/migrations/0004_auto_20201231_1058.py
Normal file
20
jobs/migrations/0004_auto_20201231_1058.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Generated by Django 3.1.4 on 2020-12-31 09:58
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jobs', '0003_auto_20201231_1050'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='job',
|
||||
name='category',
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='Category',
|
||||
),
|
||||
]
|
27
jobs/migrations/0005_auto_20201231_1059.py
Normal file
27
jobs/migrations/0005_auto_20201231_1059.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Generated by Django 3.1.4 on 2020-12-31 09:59
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jobs', '0004_auto_20201231_1058'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Category',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=100)),
|
||||
('slug', models.SlugField(default=None, editable=False)),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='job',
|
||||
name='category',
|
||||
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='jobs', to='jobs.category'),
|
||||
),
|
||||
]
|
19
jobs/migrations/0006_auto_20201231_1102.py
Normal file
19
jobs/migrations/0006_auto_20201231_1102.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Generated by Django 3.1.4 on 2020-12-31 10:02
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jobs', '0005_auto_20201231_1059'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='job',
|
||||
name='category',
|
||||
field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, related_name='jobs', to='jobs.category'),
|
||||
),
|
||||
]
|
17
jobs/migrations/0007_remove_job_category.py
Normal file
17
jobs/migrations/0007_remove_job_category.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Generated by Django 3.1.4 on 2020-12-31 10:04
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jobs', '0006_auto_20201231_1102'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='job',
|
||||
name='category',
|
||||
),
|
||||
]
|
19
jobs/migrations/0008_job_category.py
Normal file
19
jobs/migrations/0008_job_category.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Generated by Django 3.1.4 on 2020-12-31 10:05
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jobs', '0007_remove_job_category'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='job',
|
||||
name='category',
|
||||
field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, related_name='jobs', to='jobs.category'),
|
||||
),
|
||||
]
|
@ -4,6 +4,18 @@ from django.template.defaultfilters import slugify
|
||||
from jobportal import settings
|
||||
|
||||
|
||||
class Category(models.Model):
|
||||
title = models.CharField(max_length=100)
|
||||
slug = models.SlugField(default=None, editable=False)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self.slug = slugify(self.title)
|
||||
super(Category, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class Job(models.Model):
|
||||
title = models.CharField(max_length=300)
|
||||
company = models.CharField(max_length=300)
|
||||
@ -21,6 +33,7 @@ class Job(models.Model):
|
||||
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)
|
||||
category = models.ForeignKey(Category, on_delete=models.CASCADE, related_name="jobs", default=None)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
Loading…
Reference in New Issue
Block a user