Сделал поле для ввода ссылки без значения по умолчанию, с placeholder и обязательное для заполнения #31 #32

Merged
redex2000 merged 1 commits from link into master 2 years ago
  1. 3
      cms/forms.py
  2. 18
      cms/migrations/0004_alter_article_link.py
  3. 2
      cms/models.py

3
cms/forms.py

@ -5,6 +5,9 @@ from .models import Article
class ArticleForm(forms.ModelForm):
link_widget = forms.TextInput(attrs={'placeholder': 'Введите ссылку новости'})
link = forms.CharField(widget=link_widget)
class Meta:
model = Article
fields = ('body', 'link',)

18
cms/migrations/0004_alter_article_link.py

@ -0,0 +1,18 @@
# Generated by Django 4.1.4 on 2022-12-28 06:06
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cms', '0003_alter_article_link'),
]
operations = [
migrations.AlterField(
model_name='article',
name='link',
field=models.CharField(max_length=200),
),
]

2
cms/models.py

@ -3,4 +3,4 @@ from django.db import models
class Article(models.Model):
body = models.TextField(null=False)
link = models.CharField(max_length=200, default='https://zakonvremeni.ru/news/')
link = models.CharField(max_length=200, null=False)

Loading…
Cancel
Save