admin管理员组文章数量:1397219
This is my model.py file code:
class Review(models.Model):
VOTE_TYPE = (
('up','Up Vote'),
('down','Down Vote'),
)
owner = models.ForeignKey(Profile, on_delete=models.CASCADE, null = True)
project = models.ForeignKey(Project, on_delete=models.CASCADE) # when the model is deleted, all the reviews should also be deleted.
body = models.TextField(null = True, blank=True)
value = models.CharField(max_length=200, choices = VOTE_TYPE)
created = models.DateTimeField(auto_now_add=True)
id = models.UUIDField(default=uuid.uuid4, unique=True,
primary_key=True, editable=False)
This is my forms.py code:
class ReviewForm(ModelForm):
class Meta:
model = Review
fields = ['value', 'body']
labels = {
'value': 'Place your vote',
'body': 'Add a comment with your code'
}
def __init__(self,*args,**kwargs):
super(ReviewForm, self).__init__(*args, **kwargs)
for name,field in self.fields.items():
field.widget.attrs.update({'class':'input'})
This my html file code
<form class="form" action="{% url 'project' project.id %}" method="POST">
{% for field in form %}
<!-- 'form' IS THE WORLD WE PUT IN CONTEXT DICT IN PROJECTS VIEW. -->
<div class="form__field">
<label for="formInput#textarea">{{ field.label }}</label>
{{ field }}
</div>
{% endfor %}
<input class="btn btn--sub btn--lg" type="submit" value="Add Review" />
</form>
The label's CSS is here:
ments {
margin-top: 4rem;
padding-top: 3rem;
border-top: 2px solid var(--color-light);
}
ments .form label {
position: absolute;
margin: -9999px;
}
mentList {
margin: 3rem 0;
}
ment {
display: flex;
gap: 2rem;
}
the problem is that Labels are not showing.Can anybody help me how to fix this issue? The picture's inspect will might help.
The image attached to this question will be very helpful.
本文标签: cssLabels in the form is not showingStack Overflow
版权声明:本文标题:css - Labels in the form is not showing - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744109903a2591241.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论