Answer the question
In order to leave comments, you need to log in
How to give each field a separate class?
Hello everyone,
I have a form to add vacancies. I need to understand how can I make each field have its own design? For example, if this is a job title, then it should have its own div class, and the other field should have a different one.
I'm still inexperienced and learning, so do not judge strictly.
When rendering form.as_p it doesn't output as expected.
models.py
class Vacancies (models.Model):
vac_name = models.CharField("Название вакансии", max_length=50)
vac_req = models.TextField("Требования", max_length=1000)
vac_obz = models.TextField("Обязанности", max_length=1000)
vac_usl = models.TextField("Условия",max_length=1000)
vac_salary = models.IntegerField("Зарплата", blank=False, default=0)
vac_comp = models.ForeignKey(User,
related_name='company_name')
vac_zan = models.ForeignKey('WorkTime', verbose_name="Выберите тип занятости")
vac_locat = models.ForeignKey('LocatOn', verbose_name="Город")
vac_exp = models.ForeignKey('Expierence', verbose_name="Требуемый опыт")
vac_cat = models.ForeignKey('VacanCategory', verbose_name="Выберите категорию")
created_date = models.DateTimeField(auto_now_add=True)
modified_date = models.DateTimeField(auto_now=True)
def __str__(self):
return self.vac_name
class CompanyName (models.Model):
comp_name = models.CharField("Название компании", max_length=50, default=" ##Название компании## ")
def __str__(self):
return self.comp_name
class WorkTime (models.Model):
work_t = models.CharField("Время работы", max_length=30, default=" ##Режим Работы## ")
def __str__(self):
return self.work_t
class LocatOn (models.Model):
location_city = models.CharField("Город", max_length=30, default=" ##Название города## ")
def __str__(self):
return self.location_city
class Expierence (models.Model):
exp_srok = models.CharField ("Опыт работы", max_length=10, default=" ##ОПЫТ РАБОТЫ## ")
def __str__(self):
return self.exp_srok
class VacanCategory (models.Model):
vacan_cat = models.CharField ("Категория вакансии", max_length=45, default=" ##ОСНОВНАЯ КАТЕГОРИЯ## ")
def __str__(self):
return self.vacan_cat
from django import forms
from .models import Vacancies
class VacForm(forms.ModelForm):
class Meta:
model = Vacancies
fields = ('vac_name', 'vac_req','vac_obz', 'vac_usl','vac_salary', 'vac_comp','vac_zan', 'vac_locat', 'vac_exp','vac_cat', )
Answer the question
In order to leave comments, you need to log in
I'm still inexperienced and learning, so do not judge strictly.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question