diff --git a/cmsMain/admin.py b/cmsMain/admin.py index 4671396..03d8799 100644 --- a/cmsMain/admin.py +++ b/cmsMain/admin.py @@ -2,7 +2,7 @@ from django.contrib import admin from django.contrib.auth.admin import UserAdmin,GroupAdmin from django.contrib.auth.models import User, Group from unfold.admin import ModelAdmin -from .models import Site, Page +from .models import Site, Page, Url, Variable admin.site.unregister(Group) admin.site.unregister(User) @@ -16,4 +16,11 @@ class GroupAdmin(GroupAdmin, ModelAdmin): pass class SiteAdmin(ModelAdmin): pass @admin.register(Page) -class PageAdmin(ModelAdmin): pass \ No newline at end of file +class PageAdmin(ModelAdmin): pass + +@admin.register(Url) +class UrlAdmin(ModelAdmin): pass + +@admin.register(Variable) +class VariableAdmin(ModelAdmin): pass + \ No newline at end of file diff --git a/cmsMain/migrations/0002_alter_site_options_page_title_url.py b/cmsMain/migrations/0002_alter_site_options_page_title_url.py new file mode 100644 index 0000000..e51969f --- /dev/null +++ b/cmsMain/migrations/0002_alter_site_options_page_title_url.py @@ -0,0 +1,37 @@ +# Generated by Django 5.1 on 2024-08-13 10:04 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cmsMain', '0001_initial'), + ] + + operations = [ + migrations.AlterModelOptions( + name='site', + options={'verbose_name': 'Сайт', 'verbose_name_plural': 'Сайтов'}, + ), + migrations.AddField( + model_name='page', + name='title', + field=models.CharField(default='Главная страница', max_length=50, verbose_name='Название'), + preserve_default=False, + ), + migrations.CreateModel( + name='Url', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('path', models.CharField(max_length=50, verbose_name='Путь')), + ('page', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='cmsMain.page', verbose_name='Страница')), + ('site', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='cmsMain.site', verbose_name='Сайт')), + ], + options={ + 'verbose_name': 'Ссылка', + 'verbose_name_plural': 'Ссылок', + }, + ), + ] diff --git a/cmsMain/migrations/0003_alter_site_options_alter_url_options.py b/cmsMain/migrations/0003_alter_site_options_alter_url_options.py new file mode 100644 index 0000000..e245b9c --- /dev/null +++ b/cmsMain/migrations/0003_alter_site_options_alter_url_options.py @@ -0,0 +1,21 @@ +# Generated by Django 5.1 on 2024-08-13 11:17 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('cmsMain', '0002_alter_site_options_page_title_url'), + ] + + operations = [ + migrations.AlterModelOptions( + name='site', + options={'verbose_name': 'Сайт', 'verbose_name_plural': 'Сайты'}, + ), + migrations.AlterModelOptions( + name='url', + options={'verbose_name': 'Ссылка', 'verbose_name_plural': 'Ссылки'}, + ), + ] diff --git a/cmsMain/migrations/0004_variable.py b/cmsMain/migrations/0004_variable.py new file mode 100644 index 0000000..96f6c62 --- /dev/null +++ b/cmsMain/migrations/0004_variable.py @@ -0,0 +1,25 @@ +# Generated by Django 5.1 on 2024-08-13 11:17 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cmsMain', '0003_alter_site_options_alter_url_options'), + ] + + operations = [ + migrations.CreateModel( + name='Variable', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=50, verbose_name='Имя')), + ('value', models.TextField(verbose_name='Значение')), + ], + options={ + 'verbose_name': 'Переменная', + 'verbose_name_plural': 'Переменные', + }, + ), + ] diff --git a/cmsMain/models.py b/cmsMain/models.py index 31e6e7a..edd688b 100644 --- a/cmsMain/models.py +++ b/cmsMain/models.py @@ -3,7 +3,10 @@ from django.db import models # Create your models here. class Page(models.Model): + title = models.CharField("Название",max_length=50) content = models.TextField("Содержимое") + def __str__(self): + return self.title class Meta: verbose_name = "Страница" verbose_name_plural = "Страницы" @@ -15,4 +18,23 @@ class Site(models.Model): return self.domain class Meta: verbose_name = "Сайт" - verbose_name_plural = "Сайты" \ No newline at end of file + verbose_name_plural = "Сайты" + +class Url(models.Model): + site = models.ForeignKey(Site,on_delete=models.PROTECT,verbose_name="Сайт") + path = models.CharField("Путь",max_length=50) + page = models.ForeignKey(Page,on_delete=models.PROTECT,verbose_name="Страница") + def __str__(self): + return f"{self.site.domain}/{self.path}" + class Meta: + verbose_name="Ссылка" + verbose_name_plural="Ссылки" + +class Variable(models.Model): + name = models.CharField("Имя",max_length=50) + value = models.TextField("Значение") + def __str__(self): + return self.name + class Meta: + verbose_name = "Переменная" + verbose_name_plural = "Переменные" \ No newline at end of file diff --git a/cmsMain/templates/index.html b/cmsMain/templates/index.html deleted file mode 100644 index bfc96ba..0000000 --- a/cmsMain/templates/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - -
- - -