Advertisement
lamorfini

Untitled

Jan 25th, 2022
733
248 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """ forms.py """
  2. class NewsFormAdd(forms.ModelForm):
  3.     class Meta:
  4.         model = News
  5.         fields = ['title',  'content_resume', 'content', 'status']
  6.         widgets = {
  7.             'title' : forms.TextInput(attrs={'class': 'form-control'}),
  8.             'content_resume' : forms.Textarea(attrs={'class': 'form-control'}),
  9.             'content' : forms.Textarea(attrs={'class': 'form-control'}),
  10.             'status' : forms.RadioSelect(),
  11.         }
  12.  
  13. """ news_add.html """"
  14. {% extends "common/news.html" %}
  15. {% block title %} Aggiungi {% endblock %}
  16. {% block content %}
  17. <h1 class="display-1 text-center">Aggiungi notizia</h1>
  18. <div id="content-custom" class="mb-3">
  19.    <div id="news">
  20. <div class="row">
  21.    <form method="post" novalidate>
  22.        {% csrf_token %}
  23.        {% for field in form.visible_fields %}
  24.            <div class="form-group">
  25.                <label for="{{ field.id_for_label }}" class="mt-3 mb-3">{{field.label}}</label>
  26.                {{field}}
  27.                {% for error in field.errors %}
  28.                    <span class="help-block" style="color:red">{{error}}</span>
  29.                {% endfor %}
  30.            </div>
  31.        {% endfor %}
  32.        <div class="mt-3">
  33.            <button type="submit" class="btn btn-success">Aggiungi</button>
  34.        </div>
  35.    </form>
  36. </div>
  37. </div>
  38. </div>
  39. <div id="control">
  40.    <p class="text-center"><a href="{% url 'news-list' %}" class="btn btn-default btn-primary">Ritorna alla lista</a></p></p>
  41. </div>
  42. {% endblock %}
  43.  
  44.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement