1

2 つの質問があります。フォームで翻訳するにはどうすればよいですか: a) ラベル b) フォーム ValidationErrors ?

forms.py

from django import forms
from django.db.models import Max, Min
from .models import Application, FlowRate, WaterFilterSubType, Fineness, Dirt
from .models import DirtProperties, Flange

class InputDataWaterForm(forms.Form):
    '''Application'''
    choices = list(Application.objects.values_list('id','application'))
    application = forms.ChoiceField(choices = choices, initial="1", label="Specify application:")
    ....

    def clean(self):
        cleaned_data = super(InputDataWaterForm, self).clean()
        application = cleaned_data.get('application')
    ...

        '''OTHER CONDITIONS if not flowrate ...'''
        if not (flowrate or pressure or dirt or dirtproperties or
            application or fineness or temperature or
            flange or atex or aufstellung or ventil):
            raise forms.ValidationError('PLEASE ENTER THE REQUIRED INFO')

データベース内のテーブルのコンテンツを翻訳するにはどうすればよいですか? すべてのレコード。表内の製品名は翻訳する必要があります。

models.py

from django.db import models

'''FILTER PROPERTIES LIKE COLOR'''
class FP_sealing(models.Model):
    value = models.CharField('Material Sealing', max_length=10)
    descr = models.CharField('Description', max_length=200, default="")
    def __str__(self):
        return("Seal: " + self.value)

ありがとうございました

4

1 に答える 1