I just started my first app with django. I have built forms previously with bootstrap and custom styling. Now i came to know about django built-in forms with models. i have written the code for this but found that there is not styling and it's look so ugly. i want to add my custom styling to this form how can i do this. here is my code.
model.py
class Message(models.Model):
MessageID = models.AutoField(verbose_name='Message ID',primary_key=True)
MessageSubject = models.CharField(verbose_name='Subject',max_length=255,null=True,blank=True)
MessageContent = models.TextField(verbose_name='Content',null=True,blank=True)
MessageType = models.CharField(verbose_name='Message Type',max_length=255,default='Email',null=True,blank=True)
forms.py
from django import forms
from django.forms import ModelForm
from Apps.SendMessage.models import Message
class Message_form(ModelForm):
class Meta:
model = Message
views.py
def add_message(request):
message_form = {'message_form': Message_form}
print request.POST.get('Subject')
return render_to_response('sendmessage_form.html', message_form, context_instance=RequestContext(request))
and sendmessage_form.html
{% extends "base.html" %}
{% block Content %}
<div class="container">
<!-- Contacts -->
<div id="contacts">
<div class="row">
<!-- Alignment -->
<div class="col-sm-offset-3 col-sm-4">
<!-- Form itself -->
<form name="sentMessage" action="" method="POST" class="well" id="contactForm" novalidate>
{% csrf_token %}
{{ message_form }}
<button type="submit" class="btn btn-primary btn-sm pull-right">Send</button><br />
</form>
</div>
</div>
</div>
</div>
{% endblock %}