Filter list with db model
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,5 +2,4 @@
|
|||||||
/.vscode
|
/.vscode
|
||||||
/.venv
|
/.venv
|
||||||
__pycache__
|
__pycache__
|
||||||
/db.sqlite3
|
|
||||||
/project/settings_local.py
|
/project/settings_local.py
|
||||||
|
|||||||
BIN
db.sqlite3
Normal file
BIN
db.sqlite3
Normal file
Binary file not shown.
@ -3,4 +3,4 @@ from django.apps import AppConfig
|
|||||||
|
|
||||||
class MainConfig(AppConfig):
|
class MainConfig(AppConfig):
|
||||||
default_auto_field = "django.db.models.BigAutoField"
|
default_auto_field = "django.db.models.BigAutoField"
|
||||||
name = "main"
|
name = "project.main"
|
||||||
|
|||||||
34
project/main/migrations/0001_initial.py
Normal file
34
project/main/migrations/0001_initial.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# Generated by Django 5.0.4 on 2024-05-14 20:16
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = []
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="CatBreed",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.BigAutoField(
|
||||||
|
auto_created=True,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name="ID",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("name", models.CharField(max_length=100)),
|
||||||
|
("country", models.CharField(max_length=100)),
|
||||||
|
("origin", models.CharField(max_length=100)),
|
||||||
|
("coat", models.CharField(max_length=100)),
|
||||||
|
("pattern", models.CharField(max_length=100)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
"db_table": "cat_breeds",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -1,8 +1,10 @@
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class CatBreed:
|
class Breed:
|
||||||
name: str
|
name: str
|
||||||
country: str
|
country: str
|
||||||
origin: str
|
origin: str
|
||||||
@ -11,672 +13,672 @@ class CatBreed:
|
|||||||
|
|
||||||
|
|
||||||
cat_breeds = [
|
cat_breeds = [
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Abyssinian",
|
name="Abyssinian",
|
||||||
country="Ethiopia",
|
country="Ethiopia",
|
||||||
origin="Natural/Standard",
|
origin="Natural/Standard",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Ticked",
|
pattern="Ticked",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Aegean",
|
name="Aegean",
|
||||||
country="Greece",
|
country="Greece",
|
||||||
origin="Natural/Standard",
|
origin="Natural/Standard",
|
||||||
coat="Semi-long",
|
coat="Semi-long",
|
||||||
pattern="Bi- or tri-colored",
|
pattern="Bi- or tri-colored",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="American Curl",
|
name="American Curl",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Mutation",
|
origin="Mutation",
|
||||||
coat="Short/Long",
|
coat="Short/Long",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="American Bobtail",
|
name="American Bobtail",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Mutation",
|
origin="Mutation",
|
||||||
coat="Short/Long",
|
coat="Short/Long",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="American Shorthair",
|
name="American Shorthair",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="All but colorpoint",
|
pattern="All but colorpoint",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="American Wirehair",
|
name="American Wirehair",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Mutation",
|
origin="Mutation",
|
||||||
coat="Rex",
|
coat="Rex",
|
||||||
pattern="All but colorpoint",
|
pattern="All but colorpoint",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Arabian Mau",
|
name="Arabian Mau",
|
||||||
country="Arabian Peninsula",
|
country="Arabian Peninsula",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Australian Mist",
|
name="Australian Mist",
|
||||||
country="Australia",
|
country="Australia",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Spotted and Classic tabby",
|
pattern="Spotted and Classic tabby",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Asian",
|
name="Asian",
|
||||||
country="United Kingdom",
|
country="United Kingdom",
|
||||||
origin="",
|
origin="",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Evenly solid",
|
pattern="Evenly solid",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Asian Semi-longhair",
|
name="Asian Semi-longhair",
|
||||||
country="United Kingdom",
|
country="United Kingdom",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Semi-long",
|
coat="Semi-long",
|
||||||
pattern="Solid",
|
pattern="Solid",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Balinese",
|
name="Balinese",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Long",
|
coat="Long",
|
||||||
pattern="Colorpoint",
|
pattern="Colorpoint",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Bambino",
|
name="Bambino",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Hairless/Furry down",
|
coat="Hairless/Furry down",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Bengal",
|
name="Bengal",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Hybrid",
|
origin="Hybrid",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Spotted/Marbled",
|
pattern="Spotted/Marbled",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Birman",
|
name="Birman",
|
||||||
country="France",
|
country="France",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Semi Long",
|
coat="Semi Long",
|
||||||
pattern="Colorpoint",
|
pattern="Colorpoint",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Bombay",
|
name="Bombay",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Crossbred",
|
origin="Crossbred",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Solid",
|
pattern="Solid",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Brazilian Shorthair",
|
name="Brazilian Shorthair",
|
||||||
country="Brazil",
|
country="Brazil",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="British Semi-longhair",
|
name="British Semi-longhair",
|
||||||
country="United Kingdom",
|
country="United Kingdom",
|
||||||
origin="",
|
origin="",
|
||||||
coat="Medium",
|
coat="Medium",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="British Shorthair",
|
name="British Shorthair",
|
||||||
country="United Kingdom",
|
country="United Kingdom",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="British Longhair",
|
name="British Longhair",
|
||||||
country="United Kingdom",
|
country="United Kingdom",
|
||||||
origin="",
|
origin="",
|
||||||
coat="Long",
|
coat="Long",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Burmese",
|
name="Burmese",
|
||||||
country="Burma and Thailand",
|
country="Burma and Thailand",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Solid",
|
pattern="Solid",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Burmilla",
|
name="Burmilla",
|
||||||
country="United Kingdom",
|
country="United Kingdom",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Short/Long",
|
coat="Short/Long",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="California Spangled",
|
name="California Spangled",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Spotted",
|
pattern="Spotted",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Chantilly-Tiffany",
|
name="Chantilly-Tiffany",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="",
|
origin="",
|
||||||
coat="",
|
coat="",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Chartreux",
|
name="Chartreux",
|
||||||
country="France",
|
country="France",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Solid",
|
pattern="Solid",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Chausie",
|
name="Chausie",
|
||||||
country="France",
|
country="France",
|
||||||
origin="Hybrid",
|
origin="Hybrid",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Ticked",
|
pattern="Ticked",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Cheetoh",
|
name="Cheetoh",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Hybrid Crossbreed",
|
origin="Hybrid Crossbreed",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Spotted",
|
pattern="Spotted",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Cornish Rex",
|
name="Cornish Rex",
|
||||||
country="United Kingdom",
|
country="United Kingdom",
|
||||||
origin="Mutation",
|
origin="Mutation",
|
||||||
coat="Rex",
|
coat="Rex",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Cymric or Manx Longhair",
|
name="Cymric or Manx Longhair",
|
||||||
country="United Kingdom",
|
country="United Kingdom",
|
||||||
origin="Natural/Mutation",
|
origin="Natural/Mutation",
|
||||||
coat="Long",
|
coat="Long",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Cyprus",
|
name="Cyprus",
|
||||||
country="Cyprus",
|
country="Cyprus",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="All",
|
coat="All",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Devon Rex",
|
name="Devon Rex",
|
||||||
country="United Kingdom",
|
country="United Kingdom",
|
||||||
origin="Mutation",
|
origin="Mutation",
|
||||||
coat="Rex",
|
coat="Rex",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Donskoy, or Don Sphynx",
|
name="Donskoy, or Don Sphynx",
|
||||||
country="Russia",
|
country="Russia",
|
||||||
origin="",
|
origin="",
|
||||||
coat="Hairless",
|
coat="Hairless",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Dragon Li",
|
name="Dragon Li",
|
||||||
country="China",
|
country="China",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Striped tabby",
|
pattern="Striped tabby",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Dwarf cat, or Dwelf",
|
name="Dwarf cat, or Dwelf",
|
||||||
country="",
|
country="",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="",
|
coat="",
|
||||||
pattern="Hairless",
|
pattern="Hairless",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Egyptian Mau",
|
name="Egyptian Mau",
|
||||||
country="Egypt",
|
country="Egypt",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Spotted",
|
pattern="Spotted",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="European Shorthair",
|
name="European Shorthair",
|
||||||
country="Finland and Sweden",
|
country="Finland and Sweden",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Exotic Shorthair",
|
name="Exotic Shorthair",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Foldex[4]",
|
name="Foldex[4]",
|
||||||
country="Canada",
|
country="Canada",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="German Rex",
|
name="German Rex",
|
||||||
country="East Germany",
|
country="East Germany",
|
||||||
origin="Mutation",
|
origin="Mutation",
|
||||||
coat="Rex",
|
coat="Rex",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Havana Brown",
|
name="Havana Brown",
|
||||||
country="United Kingdom",
|
country="United Kingdom",
|
||||||
origin="",
|
origin="",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Solid",
|
pattern="Solid",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Highlander",
|
name="Highlander",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Short/Long",
|
coat="Short/Long",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Himalayan, or Colorpoint Persian",
|
name="Himalayan, or Colorpoint Persian",
|
||||||
country="United States/United Kingdom",
|
country="United States/United Kingdom",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Long",
|
coat="Long",
|
||||||
pattern="Colorpoint",
|
pattern="Colorpoint",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Japanese Bobtail",
|
name="Japanese Bobtail",
|
||||||
country="Japan",
|
country="Japan",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short/Long",
|
coat="Short/Long",
|
||||||
pattern="All but colorpoint and ticked",
|
pattern="All but colorpoint and ticked",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Javanese",
|
name="Javanese",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Long/Short",
|
coat="Long/Short",
|
||||||
pattern="Colorpoint",
|
pattern="Colorpoint",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Karelian Bobtail",
|
name="Karelian Bobtail",
|
||||||
country="Western Russia",
|
country="Western Russia",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="",
|
coat="",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Khao Manee",
|
name="Khao Manee",
|
||||||
country="Thailand",
|
country="Thailand",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Solid",
|
pattern="Solid",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Korat",
|
name="Korat",
|
||||||
country="Thailand",
|
country="Thailand",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Solid",
|
pattern="Solid",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Korean Bobtail",
|
name="Korean Bobtail",
|
||||||
country="Korea",
|
country="Korea",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short/Long",
|
coat="Short/Long",
|
||||||
pattern="Colorprint",
|
pattern="Colorprint",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Korn Ja",
|
name="Korn Ja",
|
||||||
country="Thailand",
|
country="Thailand",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short/Hairless",
|
coat="Short/Hairless",
|
||||||
pattern="Solid",
|
pattern="Solid",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Kurilian Bobtail, or Kuril Islands Bobtail",
|
name="Kurilian Bobtail, or Kuril Islands Bobtail",
|
||||||
country="Eastern Russia,Japan",
|
country="Eastern Russia,Japan",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short/Long",
|
coat="Short/Long",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="LaPerm",
|
name="LaPerm",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Mutation",
|
origin="Mutation",
|
||||||
coat="Rex",
|
coat="Rex",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Lykoi",
|
name="Lykoi",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Natural/Mutation",
|
origin="Natural/Mutation",
|
||||||
coat="Partly Hairless",
|
coat="Partly Hairless",
|
||||||
pattern="Ticked",
|
pattern="Ticked",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Maine Coon",
|
name="Maine Coon",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Long",
|
coat="Long",
|
||||||
pattern="All but colorpoint and ticked",
|
pattern="All but colorpoint and ticked",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Manx",
|
name="Manx",
|
||||||
country="United Kingdom",
|
country="United Kingdom",
|
||||||
origin="Mutation",
|
origin="Mutation",
|
||||||
coat="Short/Long",
|
coat="Short/Long",
|
||||||
pattern="All but colorpoint",
|
pattern="All but colorpoint",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Mekong Bobtail",
|
name="Mekong Bobtail",
|
||||||
country="Russia",
|
country="Russia",
|
||||||
origin="Natural/Mutation",
|
origin="Natural/Mutation",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Colorpoint",
|
pattern="Colorpoint",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Minskin",
|
name="Minskin",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Short/Hairless",
|
coat="Short/Hairless",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Munchkin",
|
name="Munchkin",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Mutation",
|
origin="Mutation",
|
||||||
coat="",
|
coat="",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Nebelung",
|
name="Nebelung",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="",
|
origin="",
|
||||||
coat="Semi-long",
|
coat="Semi-long",
|
||||||
pattern="Solid",
|
pattern="Solid",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Napoleon",
|
name="Napoleon",
|
||||||
country="",
|
country="",
|
||||||
origin="",
|
origin="",
|
||||||
coat="Long/short",
|
coat="Long/short",
|
||||||
pattern="Varied",
|
pattern="Varied",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Norwegian Forest cat",
|
name="Norwegian Forest cat",
|
||||||
country="Norway",
|
country="Norway",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Long",
|
coat="Long",
|
||||||
pattern="All but colorpoint",
|
pattern="All but colorpoint",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Ocicat",
|
name="Ocicat",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Spotted",
|
pattern="Spotted",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Ojos Azules",
|
name="Ojos Azules",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="",
|
origin="",
|
||||||
coat="",
|
coat="",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Oregon Rex",
|
name="Oregon Rex",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Mutation",
|
origin="Mutation",
|
||||||
coat="Rex",
|
coat="Rex",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Oriental Bicolor",
|
name="Oriental Bicolor",
|
||||||
country="",
|
country="",
|
||||||
origin="",
|
origin="",
|
||||||
coat="",
|
coat="",
|
||||||
pattern="Bicolor",
|
pattern="Bicolor",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Oriental Shorthair",
|
name="Oriental Shorthair",
|
||||||
country="",
|
country="",
|
||||||
origin="",
|
origin="",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="All but colorpoint",
|
pattern="All but colorpoint",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Oriental Longhair",
|
name="Oriental Longhair",
|
||||||
country="",
|
country="",
|
||||||
origin="",
|
origin="",
|
||||||
coat="Semi-long",
|
coat="Semi-long",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="PerFoldæ(Experimental Breed - WCF),",
|
name="PerFoldæ(Experimental Breed - WCF),",
|
||||||
country="Europe",
|
country="Europe",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Long",
|
coat="Long",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Persian (Modern Persian Cat),",
|
name="Persian (Modern Persian Cat),",
|
||||||
country="Iran (Persia),",
|
country="Iran (Persia),",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Long",
|
coat="Long",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Persian (Traditional Persian Cat),",
|
name="Persian (Traditional Persian Cat),",
|
||||||
country="Greater Iran",
|
country="Greater Iran",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Long",
|
coat="Long",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Peterbald",
|
name="Peterbald",
|
||||||
country="Russia",
|
country="Russia",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Hairless",
|
coat="Hairless",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Pixie-bob",
|
name="Pixie-bob",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Spotted",
|
pattern="Spotted",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Raas",
|
name="Raas",
|
||||||
country="Indonesia",
|
country="Indonesia",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Ragamuffin",
|
name="Ragamuffin",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Long",
|
coat="Long",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Ragdoll",
|
name="Ragdoll",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Long",
|
coat="Long",
|
||||||
pattern="Colorpoint/Mitted/Bicolor",
|
pattern="Colorpoint/Mitted/Bicolor",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Russian Blue",
|
name="Russian Blue",
|
||||||
country="Russia",
|
country="Russia",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Solid",
|
pattern="Solid",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Russian White, Black and Tabby",
|
name="Russian White, Black and Tabby",
|
||||||
country="Australia",
|
country="Australia",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Sam Sawet",
|
name="Sam Sawet",
|
||||||
country="Thailand",
|
country="Thailand",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Solid",
|
pattern="Solid",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Savannah",
|
name="Savannah",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Hybrid",
|
origin="Hybrid",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Spotted",
|
pattern="Spotted",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Scottish Fold",
|
name="Scottish Fold",
|
||||||
country="United Kingdom",
|
country="United Kingdom",
|
||||||
origin="Natural/Mutation",
|
origin="Natural/Mutation",
|
||||||
coat="Short/Long",
|
coat="Short/Long",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Selkirk Rex",
|
name="Selkirk Rex",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Mutation/Cross",
|
origin="Mutation/Cross",
|
||||||
coat="Rex (Short/Long),",
|
coat="Rex (Short/Long),",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Serengeti",
|
name="Serengeti",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Hybrid Crossbreed",
|
origin="Hybrid Crossbreed",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Spotted",
|
pattern="Spotted",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Serrade petit",
|
name="Serrade petit",
|
||||||
country="France",
|
country="France",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Siamese",
|
name="Siamese",
|
||||||
country="Thailand",
|
country="Thailand",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Colorpoint",
|
pattern="Colorpoint",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Siberian",
|
name="Siberian",
|
||||||
country="Russia",
|
country="Russia",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Semi-long",
|
coat="Semi-long",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Singapura",
|
name="Singapura",
|
||||||
country="Singapore",
|
country="Singapore",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Ticked",
|
pattern="Ticked",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Snowshoe",
|
name="Snowshoe",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Colorpoint",
|
pattern="Colorpoint",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Sokoke",
|
name="Sokoke",
|
||||||
country="Kenya",
|
country="Kenya",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Classic tabby with ticking",
|
pattern="Classic tabby with ticking",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Somali",
|
name="Somali",
|
||||||
country="Somalia",
|
country="Somalia",
|
||||||
origin="Mutation",
|
origin="Mutation",
|
||||||
coat="Long",
|
coat="Long",
|
||||||
pattern="Ticked",
|
pattern="Ticked",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Sphynx",
|
name="Sphynx",
|
||||||
country="Canada",
|
country="Canada",
|
||||||
origin="Mutation",
|
origin="Mutation",
|
||||||
coat="Hairless",
|
coat="Hairless",
|
||||||
pattern="All",
|
pattern="All",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Suphalak",
|
name="Suphalak",
|
||||||
country="Thailand",
|
country="Thailand",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Solid",
|
pattern="Solid",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Thai",
|
name="Thai",
|
||||||
country="Thailand",
|
country="Thailand",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Colorpoint",
|
pattern="Colorpoint",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Thai Lilac",
|
name="Thai Lilac",
|
||||||
country="Thailand",
|
country="Thailand",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Solid",
|
pattern="Solid",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Tonkinese",
|
name="Tonkinese",
|
||||||
country="Canada",
|
country="Canada",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Colorpoint/Mink/Solid",
|
pattern="Colorpoint/Mink/Solid",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Toyger",
|
name="Toyger",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Crossbreed",
|
origin="Crossbreed",
|
||||||
coat="Short",
|
coat="Short",
|
||||||
pattern="Mackerel",
|
pattern="Mackerel",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Turkish Angora",
|
name="Turkish Angora",
|
||||||
country="Turkey",
|
country="Turkey",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
coat="Semi-long",
|
coat="Semi-long",
|
||||||
pattern="All but colorpoint",
|
pattern="All but colorpoint",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="Ukrainian Levkoy",
|
name="Ukrainian Levkoy",
|
||||||
country="Ukraine",
|
country="Ukraine",
|
||||||
origin="",
|
origin="",
|
||||||
coat="Hairless",
|
coat="Hairless",
|
||||||
pattern="",
|
pattern="",
|
||||||
),
|
),
|
||||||
CatBreed(
|
Breed(
|
||||||
name="York Chocolate",
|
name="York Chocolate",
|
||||||
country="United States",
|
country="United States",
|
||||||
origin="Natural",
|
origin="Natural",
|
||||||
@ -684,3 +686,32 @@ cat_breeds = [
|
|||||||
pattern="Solid",
|
pattern="Solid",
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def create_cat_breeds(apps, schema_editor):
|
||||||
|
CatBreed = apps.get_model("main", "CatBreed")
|
||||||
|
|
||||||
|
bulk = []
|
||||||
|
|
||||||
|
for cat_breed in cat_breeds:
|
||||||
|
bulk.append(
|
||||||
|
CatBreed(
|
||||||
|
name=cat_breed.name,
|
||||||
|
country=cat_breed.country,
|
||||||
|
origin=cat_breed.origin,
|
||||||
|
coat=cat_breed.coat,
|
||||||
|
pattern=cat_breed.pattern,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
CatBreed.objects.bulk_create(bulk)
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("main", "0001_initial"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(create_cat_breeds),
|
||||||
|
]
|
||||||
@ -1,3 +0,0 @@
|
|||||||
from django.db import models
|
|
||||||
|
|
||||||
# Create your models here.
|
|
||||||
1
project/main/models/__init__.py
Normal file
1
project/main/models/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
from .cat_breed import CatBreed
|
||||||
12
project/main/models/cat_breed.py
Normal file
12
project/main/models/cat_breed.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
class CatBreed(models.Model):
|
||||||
|
name = models.CharField(max_length=100)
|
||||||
|
country = models.CharField(max_length=100)
|
||||||
|
origin = models.CharField(max_length=100)
|
||||||
|
coat = models.CharField(max_length=100)
|
||||||
|
pattern = models.CharField(max_length=100)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = "cat_breeds"
|
||||||
@ -1,27 +1,31 @@
|
|||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
from project.main.cat_breeds import CatBreed, cat_breeds
|
from django.db.models import Count, Q
|
||||||
|
|
||||||
|
from project.main.models import CatBreed
|
||||||
from project.main.views.demo_view_base import DemoViewBase
|
from project.main.views.demo_view_base import DemoViewBase
|
||||||
|
|
||||||
|
|
||||||
def get_countries() -> list[str]:
|
def get_countries() -> list[str]:
|
||||||
return sorted(set([c.country for c in cat_breeds if len(c.country)]))
|
ann = (
|
||||||
|
CatBreed.objects.values("country")
|
||||||
|
.annotate(Count("country"))
|
||||||
|
.order_by("country")
|
||||||
|
)
|
||||||
|
return [a["country"] for a in ann]
|
||||||
|
|
||||||
|
|
||||||
def filter_cat_breeds(
|
def filter_cat_breeds(
|
||||||
breed_filter: Optional[str] = None, country_filter: Optional[str] = None
|
breed_filter: Optional[str] = None, country_filter: Optional[str] = None
|
||||||
) -> list[CatBreed]:
|
) -> list[CatBreed]:
|
||||||
if not breed_filter and not country_filter:
|
q = Q()
|
||||||
return cat_breeds
|
|
||||||
|
|
||||||
result = []
|
if breed_filter:
|
||||||
for breed in cat_breeds:
|
q &= Q(name__icontains=breed_filter)
|
||||||
# if (not breed_filter or breed_filter.lower() in breed.name.lower()) or (
|
if country_filter:
|
||||||
# not country_filter or country_filter == breed.country
|
q &= Q(country=country_filter)
|
||||||
# ):
|
|
||||||
if not breed_filter or breed_filter.lower() in breed.name.lower():
|
return CatBreed.objects.filter(q).order_by("name")
|
||||||
result.append(breed)
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
class FilterListView(DemoViewBase):
|
class FilterListView(DemoViewBase):
|
||||||
|
|||||||
@ -37,6 +37,7 @@ INSTALLED_APPS = [
|
|||||||
"django.contrib.sessions",
|
"django.contrib.sessions",
|
||||||
"django.contrib.messages",
|
"django.contrib.messages",
|
||||||
"django.contrib.staticfiles",
|
"django.contrib.staticfiles",
|
||||||
|
"project.main",
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|||||||
Reference in New Issue
Block a user