Here is what i am doing in settings.py
DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': 'jobs_db',
'HOST': 'localhost',
'PORT': '27017',
'username': '',
'password': '',
}
}
in models.py
from mongoengine import *
connect('jobs_tbl')
class jobs_tbl(models.Model):
job_company = models.CharField(max_length=200,null=True)
job_location = models.CharField(max_length=200,null=True)
job_title = models.CharField(max_length=200,null=True)
Views.py content
from mongoengine import *
connect('jobs_tbl')
def home(request):
job=jobs_tbl.objects.all()
context={
'jobs':job,
}
return render(request,'Jobseeker.html',context)
html content
<div class="container card">
<h1>Available openings</h1>
<div class="card-body">
<table class="table table-hover">
<tr>
<th>Name</th>
<th>Position</th>
<th>Description</th>
</tr>
{% for c in jobs %}
<tr>
<td>{{c.job_company}}</td>
<td>{{c.job_location}}</td>
<td>{{c.job_title}}</td>
<td><a href="{% url 'apply' %}" class="btn btn-info btn-sm" type="submit">Apply</a></td>
</tr>
{% endfor %}
</table>
</div>
</div>