Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django : Project Default Page
looking to see how the Default web page is created when a new django project is created (localhost:8000) - the one that says "The install worked successfully! Congratulations!". I guess that it's created "behind the scenes" (by magic). Is it configurable (can I change the content? for example). Just looking for more in depth technical background of the framework. Thanks. Tony -
TypeError: get() takes exactly 3 arguments (2 given)
I have checked few of the answers in stackoverflow but nothing worked for me. Still giving the same "TypeError: get() takes exactly 3 arguments (2 given)" Can anybody check the following code and let me know what I have done wrong ? my 'views.py' is as follows def get(self, request, tag): print("Tag for tagging :") data_loader = SvnDataLoader() print("Two :") ss = SubsystemRevision.get_subsystem_for_tag(tag) print("Subsystem is %s", ss) try: print("inside try") pr = subprocess.Popen(['perl', './svntasktag.pl', 'ss'], stdout=subprocess.PIPE) data = pr.communicate() context = {'data':data} except TagHistoryMissing: data = 'Tag is missing.' except SvnException as e: data = "Problem while trying to fetch tag-history from svn. Try again later" #logger.error("SvnException %s while trying to fetch the tag %s" % (str(e), tag.name)) return render_to_response('pai_app/create_tag.html', {'data': data}, context_instance=RequestContext(request)) Thanks in advance -
How to display AUTH_LDAP_PROFILE_ATTR_MAP
I am trying to map certain attributes of an ldap user by using django-auth-ldap. At the moment, I can not figure out how to display AUTH_LDAP_PROFILE_ATTR_MAP but AUTH_LDAP_USER_ATTR_MAP works because it compatible with the user-model in django. Settings.py AUTH_LDAP_USER_ATTR_MAP = { "first_name": "givenName", "last_name": "sn", "email": "mail", } AUTH_LDAP_PROFILE_ATTR_MAP = { "salutation": "titel", "phone": "telephoneNumber", "mobile": "mobile", } views.py def view_profile(request, pk=None): if pk: user = User.object.get(pk=pk) else: user = request.user args = {'user': user} return render(request, ('accounts/profile.html'), args) profile template <input value="{{ user.first_name}}"></input> <input value="{{ user.last_name}}"></input> <input value="{{ user.email}}"></input> <input value="{{ user.salutation }}"></input> <input value="{{ user.phone}}"></input> <input value="{{ user.mobile}}"></input> I thought about to change {{ user.phone }} to {{ profile.phone }}, but that did not work either. I am really looking for an answer as I can not work without this. Thanks in advance. -
Fetching data from various tables and show it on admin html gui table django?
I am new to django and ran into scenario of representing data from various table on to admin's after login gui web interface. my app's models.py file has model define as below from django.db import models class Config_Details(models.Model): class STB_Details(models.Model): class Channel_Details(models.Model): class VCB_Details(models.Model): class VCB_Execution_Details(models.Model): class Server_Config(models.Model): class Execution_Results(models.Model): This models are inter linked using primary and foreign keys. My Webinterface looks like I am able to do add, update and delete but now i have conditions like Select data from VCB_Details and VCB_Execution_Details based on config_id from Config_details table and represents it in table on admin gui interface. How can i acheieve this? -
How to serialize a function from a model class that has @property decorator in django
I am using django_rest framework and I would like to know how do I serialize a function that has a @property decorator. In this case from the code below I have total_salary class SalaryDetail(models.Model): employee = models.ForeignKey(Employee) year = models.IntegerField() month = models.CharField(max_length=2, choices=MONTH_CHOICES) basic = models.PositiveSmallIntegerField() da = models.PositiveSmallIntegerField() hra = models.PositiveSmallIntegerField() allowance = models.PositiveSmallIntegerField(default=0) loss_of_pay = models.PositiveSmallIntegerField(default=0) repayment_of_loan = models.PositiveSmallIntegerField(default=0) @property def total_salary(self): return self.basic + self.da + self.hra + self.allowance I know that in the serializers.py I will start by doing something like this: class SalaryDetailSerializer(serializers.ModelSerializer): class: model: SalaryDetail -
OAuth2 Authentication in Django Rest Swagger
I am Using Django Rest Swagger with Python 2.7 and Django 1.11 . I am trying to use OAuth authentication with Swagger. I have included this in my settings.py SWAGGER_SETTINGS = { "basePath": "/v2", 'SECURITY_DEFINITIONS': { 'api_authorization': { "type": "oauth2", "in": "header", "tokenUrl": "http://localhost:8000/o/token/", "authorizationUrl": "http://localhost:8000/o/authorize/", "name": "Authorization", "state": "random_state_string", "flow": "accessCode", "scopes": { "read": "Reading scope", "write": "Writing scope" } } } } When I click the Authorize button in Swagger it doesn't ask for client-id, instead it shows following screen. How to make the Django Rest Swagger wotk with OAuth Authentication? -
rendering the image to pdf from views in django pisa
I'm trying to render the image to pdf. I'm getting the image from database and from views trying to send it to pdf through templates. Its coming up to the templates but not rendering to pdf -
How do I make a apply/request system in django for a post?
I am working on a django project. It works something like this- A user fills a form that he requires a team for a particular project (for other users this will be job listings for which they can apply). The form directly goes into the database. These databases entries are displayed on a page i;e other users can see job listings and apply for joining his/ her team. Following is my models.py class TeamBuild(models.Model): name = models.CharField(max_length = 30) project_name = models.CharField(max_length = 30) project_description = models.TextField(max_length= 2500) skill_required = models.CharField(max_length = 200) team_size = models.IntegerField(default = 6) def __str__(self): return self.name def get_absolute_url(self): return reverse('startup:index') And this is my HTML page where these jobs will be listed: {% for job in jobs%} <li> <h1> {{ job.name }} </h1> <h3> {{ job.project_name }} </h3> <h5> {{ job.skill_required }} </h5> <p> {{ job.project_description }} </p> </li> <hr> {% endfor %} </ol> How do I setup a system, where there is an apply button below these lists, so that the user can apply for the job, and the one who has posted can choose to accept or decline his application ? -
django ckeditor image upload 403 forbidden
I'm using ckeditor in django project. ckeditor config.js /** * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md or http://ckeditor.com/license */ CKEDITOR.editorConfig = function( config ) { // Define changes to default configuration here. For example: // config.language = 'fr'; // config.uiColor = '#AADC6E'; config.filebrowserUploadUrl = '/media/img'; }; when select image and click 'send to server' button, it returns 403 forbidden (CSRF token missing or incorrect.) How can i solve this problem? -
Extend styles to mimic bootstrap classes?
I have some patterns that appear which, when that happens, I would like to apply the styles of a bootstrap class to my selected element. The reason is that I don't directly have access to the elements in question as they are pre-generated and fed into my jinja template. Example: Everytime I have a button in a form that I want my custom css to extend to mimic btn and btn-outline-primary classes and apply their styles to my selected button. Say then I modify the styles I extended so this button also has small caps. I've tried this, to no avail: form button{ @extend .btn @extend .btn-outline-primary font-variant: small-caps; } How do I correctly reference this outside style sheet and extend its classes? -
ALLOWED_HOSTS doesn't accept IP Address?
Within my settings.py file, when I use ALLOWED_HOSTS of either my domain name or '*', I'm able to access my website. When I indicate only my server's static IP address, I get a 400 Bad Request error. Based on what I've read, this should work. Any thoughts as to why it might not be working? I should mention that my site will be hosting a chaning list of domains, so it's important that I be able to use IP address in allowed hosts as opposed to a list of domain names. Thanks -
static files not found error in django
I know that this problem has already been asked several times here. I have searched and read a number of answers but no help. I guess, I am missing something very basic. In my settings.py, I have: STATIC_URL = '/static/' STATIC_ROOT = join(APPS_DIR, "static/") # STATICFILES_DIRS = [join(APPS_DIR, 'static')] MEDIA_ROOT = join(APPS_DIR, 'media') MEDIA_URL = "/media/" In my config/urls.py, I have: if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) In templates, I have a file located at /static/core/js/jquery_countdown/jquery.countdown.min.js which I am trying to load in template as below: <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <script type="text/javascript" src="{% static 'core/js/jquery_countdown/jquery.countdown.min.js' %}"> </script> The top of the same template looks like {% extends "contest/base.html" %} {% load static %} This results in following server error: [23/Mar/2018 10:12:08] "GET /static/core/js/jquery_countdown/jquery.countdown.min.js HTTP/1.1" 404 1858 What am I missing? -
django heroku postgres db does not detect current migration django.db.utils.DataError: value too long
When I run my script to populate my Django postgres DB, I get django.db.utils.DataError: value too long for type character varying(30). To overcome this error, I changed my code to take URL of max length of 200 characters length. from django.db import models from django.contrib.postgres.fields import ArrayField class ArticleScheme(models.Model): title = models.CharField(max_length=200) newsoutlet = models.CharField(max_length=10) url = models.CharField(max_length=200) date_joined = models.DateField() text = models.CharField(max_length=100) polarity = models.CharField(max_length=4) subjectivity = models.CharField(max_length=4) keywords = ArrayField(models.CharField(max_length=10), blank=True) def __str__(self): return ("title:{}\nnewsoutet:{}\nurl:{}\ndate_joined:{}" + "\ntext:{}\npolarity:{}\nsubjectivity:{}\nkeywords:{}").format( self.title, self.newsoutlet, self.url, self.date_joined, self.text, self.polarity, self.subjectivity, str(self.keywords) ) I saved the file used command python3 manage.py makemigrations appname. I then push that code to Heroku. Using Heroku run bash, the migrations is in the folder, but python3 manage.py migrate appname does not detect a migration to update. I run my script to to populate the database on Heroku and I get the error below. Traceback (most recent call last): File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute return self.cursor.execute(sql, params) psycopg2.DataError: value too long for type character varying(30) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line … -
What database should I use for my IoT webapp?
I'm building an IoT webapp which needs to display data from my device. I'm expecting it to be mostly write as the device will update the database every 6 hours or so and reads will only occur if the user opens the app or refreshes. The device will be uploading data from multiple sensors. I'm using Django for backend and using ReactJS frontend. Planning on using AWS so I was wondering which database to use. I've been looking at DynamoDB and RDS. Not sure what to go with and a little confused. -
Django Webpage not Updating After HTML Changes
I've been trying to change the name of the class panel for a while now and no matter what I do I don't see a difference. I've been able to force it by removing the cache aspect, but I believe that needs to be there. Here is the code: {% cache 3600 dashboardfeed %} <div class="item col-md-4 col-xs-12"> <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title">Recent Funding Rounds</h4> </div> <ul class="list-group"> {% for post in posts|slice:"3" %} <li class="list-group-item"> <div class="media"> <div class="media-left"> <a href="{% url 'directory:post-detail' slug=post.slug %}"> <img src="{{post.image.url}}" alt="cover" class="media-object" width="100" /> </a> </div> <div class="media-body"> <div class="pull-right"> <a class="btn btn-pink-500 btn-circle btn-stroke btn-sm" href="{% url 'directory:post-detail' slug=post.slug %}"><i class="fa fa-arrow-right"></i></a> </div> <h4 class="media-heading margin-v-4"><a href="{% url 'directory:post-detail' slug=post.slug %}">{{post.title|capfirst}}</a></h4> <p class="text-grey-500 margin-none">{{post.desc|truncatechars:"95"}}</p> </div> </div> </li> {% endfor %} </ul> </div> </div> {% endcache %} I have a few questions for this, 1: what does the cache actually do and do I need it. 2: How do I get the html page to update if I keep the cache in there? I'd appreciate any help as I'm still learning. Thanks in advance. -
Heroku Procfile runs local but unable to locate module on the app page
When I have my procfile as such: web: gunicorn blog.wsgi, I am able to run command heroku local and open the app in port :5000 locally. However, when I run heroku open, the app crashes and in the logs, I am given the error: 2018-03-23T03:00:15.844452+00:00 heroku[web.1]: Starting process with command `gunicorn blog.wsgi` 2018-03-23T03:00:17.723195+00:00 app[web.1]: [2018-03-23 03:00:17 +0000] [4] [INFO] Starting gunicorn 19.7.1 2018-03-23T03:00:17.724052+00:00 app[web.1]: [2018-03-23 03:00:17 +0000] [4] [INFO] Listening at: http://0.0.0.0:56252 (4) 2018-03-23T03:00:17.724212+00:00 app[web.1]: [2018-03-23 03:00:17 +0000] [4] [INFO] Using worker: sync 2018-03-23T03:00:17.728393+00:00 app[web.1]: [2018-03-23 03:00:17 +0000] [8] [INFO] Booting worker with pid: 8 2018-03-23T03:00:17.733272+00:00 app[web.1]: [2018-03-23 03:00:17 +0000] [8] [ERROR] Exception in worker process 2018-03-23T03:00:17.733276+00:00 app[web.1]: Traceback (most recent call last): 2018-03-23T03:00:17.733278+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker 2018-03-23T03:00:17.733280+00:00 app[web.1]: worker.init_process() 2018-03-23T03:00:17.733281+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process 2018-03-23T03:00:17.733283+00:00 app[web.1]: self.load_wsgi() 2018-03-23T03:00:17.733284+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi 2018-03-23T03:00:17.733286+00:00 app[web.1]: self.wsgi = self.app.wsgi() 2018-03-23T03:00:17.733288+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi 2018-03-23T03:00:17.733290+00:00 app[web.1]: self.callable = self.load() 2018-03-23T03:00:17.733291+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load 2018-03-23T03:00:17.733293+00:00 app[web.1]: return self.load_wsgiapp() 2018-03-23T03:00:17.733295+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp 2018-03-23T03:00:17.733296+00:00 app[web.1]: return util.import_app(self.app_uri) 2018-03-23T03:00:17.733298+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app 2018-03-23T03:00:17.733299+00:00 app[web.1]: __import__(module) 2018-03-23T03:00:17.733306+00:00 app[web.1]: ModuleNotFoundError: No … -
You're accessing the development server over HTTPS, but it only supports HTTP
I am working on a wagtail project(like django-cms) I get this error when I run python3 manage.py runserver 0.0.0.0:8000 code 400, message Bad request syntax ('\x16\x03\x01\x00®\x01\x00\x00ª\x03\x03³\x06âP\x97Þ%<Sg\x13Ö×[zE\x96\x15? \x96\x00\x1ah') You're accessing the development server over HTTPS, but it only supports HTTP. I had changed SECURE_SSL_REDIRECT=FALSE and tested it still i get this same error. I had disabled cache in chrome. I had deactivated chorme caching in registry by following steps. Deactivate Chrome Cache in the Registry Open Registry (Start -> Command -> Regedit) Search for: HKEY_CLASSES_ROOT\ChromeHTML\shell\open\command Change the part after ...chrom.exe" to this value: –disable-application- cache –media-cache-size=1 –disk-cache-size=1 — "%1" Example: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" - disable-application-cache –media-cache-size=1 –disk-cache-size=1 — "%1" I had also tried disable cache from chrome developer tools network -disable cache. I had also tried to cleared cache from hsts on chrome. I had also tried from incognito window on chrome. But still I get the same error It is an Ubuntu machine on AWS. I access from outside through http://54.23x.9x.17:8000 I am not able to resolve this error. Please help me in resolving this error. With Many Thanks, Bharath AK -
django user auth without typing password
I want a feature workflows as follows: 1) user login from web page ( typing user name/password),and auth success, then we can got user's password from database(not from web page), we will use it later. 2) user confirm start a small bot service that provide by us, once user confirm that, then the service will execute and callback 3) since the bot service is another independent app, so it have to use user account callback login action (auth) and record information under the user account. my question is, while I use the user's account login in bot service app, it failed, since the password has been hash. is there any way solve this issue ? I trace django source code , djanofrom django.contrib import auth auth.login(request,authenticate) seem no other way solve this issue unless modify the source code, I meaning add new function in framework? but obviously, it is not best idea anyone give tips on this issue, thanks -
Using Yelp Fusion API with Django v 1.2
I'm building a simple web application. I'm trying to query Yelp API to get a list of businesses in my area. I'm using django v 1.2 with python2 to build this. My previous exposure to APIs were using jquery where using API key was just within the request get url. But yelp API seems a lot more confusing, and since they updated the authentication protocol a few months ago, I couldn't find a lot of resources regarding this matter. I considered their official github documentation for python code usage. It makes sense, but whenever I try to use it on my views.py file inside Django, I get WSGIRequest object is not callable error. Here is my code for the relevant parts: def requets(host, path, api_key, url_params = None): url_params = url_params or {} url = '{0}{1}'.format(host, quote(path.encode('utf8'))) headers = { 'Authorization': 'Bearer {}'.format(API_KEY) } response = requests.request('GET', url, headers = headers, params = url_params) return response.json() def businesses(request): url_params = { 'term': DEFAULT_TERM, 'location': DEFAULT_LOCATION } content = { 'results': request(API_HOST, SEARCH_PATH, API_KEY, url_params = url_params) } return render(request, 'adinba_app/business.html', content) where I have set the DEFAULT_TERM, DEFAULT_LOCATION, SEARCH_PATH, API_KEY etc above. Any input and guidance is greatly appreciated!!! Thank … -
how to get current logged in user in python ldap3?
I am new in python.I am using python 3 and django 2. When i am using conn.bind() it gives me true/false.but i need the user somewhere.the current user who is trying to login. I can search with multiple field.but there is no attribute having the value of username. -
Django Regex match alt codes + eng/ar
i'am working with django and i don't know regex things so i'am stuck here urls.py urlpatterns = [ ...... url(ur'^article/(?P'[^/w/W]+)', ..) ] so i'am trying to match all ar/eng + alt codes the pattern is working but not with eng letters -
Connection refused on django cache socket
I've setup a cache as defined in documentation like this: CACHES = { 'default': { 'BACKEND': 'django_redis.cache.RedisCache', 'LOCATION': [ 'redis://127.0.0.1:6379', ], 'TIMEOUT': None, } } Now I try to access it in my website and I receive this error: ConnectionError at /exchange/provider Error 10061 connecting to 127.0.0.1:6379. No connection could be made because the target machine actively refused it. Request Method: GET Request URL: http://127.0.0.1:8000/exchange/provider Django Version: 2.0.2 Exception Type: ConnectionError Exception Value: Error 10061 connecting to 127.0.0.1:6379. No connection could be made because the target machine actively refused it. Exception Location: C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\redis\connection.py in connect, line 489 Python Executable: C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\python.exe Python Version: 3.6.4 Python Path: ['C:\\Users\\sdres\\Documents\\Django\\github_repo\\32018\\innovatorsedge', 'C:\\Program Files (x86)\\Microsoft Visual ' 'Studio\\Shared\\Python36_64\\python36.zip', 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64\\DLLs', 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64\\lib', 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64', 'C:\\Program Files (x86)\\Microsoft Visual ' 'Studio\\Shared\\Python36_64\\lib\\site-packages', 'C:\\Users\\sdres\\Documents\\Django\\github_repo\\32018\\innovatorsedge'] Server time: Thu, 22 Mar 2018 18:16:13 -0700 Error during template rendering In template C:\Users\sdres\Documents\Django\github_repo\32018\innovatorsedge\common\templates\common\base.html, error at line 0 Error 10061 connecting to 127.0.0.1:6379. No connection could be made because the target machine actively refused it. 1 {% include "common/header.html" %} 2 {% block content %}{% endblock %} 3 {% include "common/footer.html" %} Traceback Switch to copy-and-paste view … -
Casting list as string in POST request works, but leaving it as list doesn't
I'm trying to figure out why this constitutes a valid POST request: pk = 5 data = { 'ids': str([pk]), 'latitude': 0, 'longitude': 0, } response = self.client.post( '/api/{}/endpoint'.format(settings.DEFAULT_VERSION), data=json.dumps(data, indent=4), content_type='application/json', HTTP_AUTHENTICATION=peep.access_token, ) whereas this doesn't: pk = 5 data = { 'ids': [pk], 'latitude': 0, 'longitude': 0, } response = self.client.post( '/api/{}/endpoint'.format(settings.DEFAULT_VERSION), data=json.dumps(data, indent=4), content_type='application/json', HTTP_AUTHENTICATION=peep.access_token, ) The latter results in the following error: "TypeError: expected string or buffer". On the server side, the second line seems to be failing: ids_json = request.data.get('ids') ids = json.loads(ids_json) I'm not sure why casting the 'ids' list as a string works, but leaving it as a list doesn't. -
If deploying with Docker using Cookiecutter django, does Caddy make it mandatory that I have purchased a domain name?
I'd like to deploy my docker containers to Heroku, and they are cookiecutter django-based projects. Under .envs/.production/.caddy there is an ENV set for DOMAIN_NAME=example.com. Previously I had this set to example.com as I had no actual domain. But now I want to push the docker image to Heroku's docker-container-registry, so I set it to DOMAIN_NAME=https://boiling-anchorage-81725.herokuapp.com/ When I run docker-compose -f production.yml up, caddy will return an error of: caddy_1 | 2018/03/23 01:01:11 [boiling-anchorage-81725.herokuapp.com] failed to get certificate: acme: Error 403 - urn:acme:error:unauthorized - Invalid response from http://boiling-anchorage-81725.herokuapp.com/.well-known/acme-challenge/ubNNHeEiMZ5KdNj0jEyY0bRfe4sRQjcDZuqL1JLHSjo: "<!DOCTYPE html> caddy_1 | <html> caddy_1 | <head> caddy_1 | <title>Heroku | Welcome to your new app!</title> caddy_1 | <style type='text/css'>" caddy_1 | Error Detail: caddy_1 | Validation for boiling-anchorage-81725.herokuapp.com:80 caddy_1 | Resolved to: caddy_1 | 23.21.84.59 caddy_1 | 23.23.246.35 caddy_1 | 23.21.56.229 caddy_1 | 23.21.208.254 caddy_1 | 50.17.207.130 caddy_1 | 23.23.120.204 caddy_1 | 23.21.47.197 caddy_1 | 23.23.116.0 caddy_1 | Used: 23.21.84.59 caddy_1 | caddy_1 | luup_caddy_1 exited with code 1 How do I configure the production settings for a Docker container being pushed to Heroku? I'm not sure what else to try next besides actually purchasing a domain, as it seems the error might have to do with certification from owning the … -
Django 2.0 ModelForm dateField not displaying as a widget
I have a fairly simple model form with a 'date_of_birth' input value of type datefield(). For whatever reason, I cannot get it to display as a widget and can only get it to display as a text input. Here is my form code: from django import forms from . import models from django.contrib.admin import widgets class CreateNewPatient(forms.ModelForm): class Meta: model = models.PatientInfo fields = ['first_name', 'nickname','last_name', 'date_of_birth', 'school_grade', 'sex', 'school'] Here is my model: class PatientInfo(models.Model): #first name, last name,nickname, and date of birth first_name = models.CharField(max_length=100) nickname = models.CharField(max_length=100, blank=True) last_name = models.CharField(max_length=100) date_of_birth = models.DateField(auto_now=False, auto_now_add=False) school_grade = models.CharField(max_length=15, blank=True) Here is my template. It is based on a base template and is using the bootstrap4 plugin: {% block content %} <!--Form Container--> <div class="container"> <form action="{% url 'patientRecords:new_patient' %}" method="post" class="form"> {% csrf_token %} {% bootstrap_form form %} {% buttons %} <button type="submit" class="btn btn-primary">Submit</button> {% endbuttons %} </form> </div> {% endblock %} Like I said, the form displays the date of birth field as a text box. How do I make it display as the normal django date widget with bootstrap styling?