Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to import numpy when deploying django through heroku?
I am trying to deploy my Django app via Heroku. However, I do not know how to install numpy for Heroku. When I want to deploy it, it gives the following error: No module named 'numpy' As I said, it seems Heroku has not installed numpy by default. I have written numpy in my requirements.txt file but it seems it is nit sufficient. Any help is appreciated. -
Jquery script execution order DataTables
I am populating page with html loaded from controler by calling $("#test").load("{% url 'simple_dataframe' %}"); 'simple_dataframe' is pandas.to_html() method which is returning proper html for datatables jquery. Next script is: <script> $(document).ready(function () { $('#df_table').DataTable(); }); </script> Which doesnt load properly. I have copied returned html to page and run it with only DataTable jquery and it runs fine. So its not related to malformed html. I think its something to do with the order in which scripts are called. {% load static %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="{% static '/css/bootstrap.min.css' %}" type="text/css"/> <link rel="stylesheet" href="{% static '/css/jquery.dataTables.css' %}" type="text/css"/> <script src="{% static "js/jquery-3.3.1.min.js" %}"></script> <script src="{% static 'js/jquery.dataTables.js' %}"></script> </head> <body> <div id="test"></div> <script> $(document).ready(function () { $("#test").load("{% url 'simple_dataframe' %}"); });</script> <script> $(document).ready(function () { $('#df_table').DataTable(); }); </script> </body> </html> -
How to dump full SQL of failing Django queryset?
I am trying out a complex query on the django shell: qs.annotate(rn=Window(expression=RowNumber(), order_by=F('date').desc(), partition_by=[F('name')])) This is failing with: ProgrammingError: syntax error at or near "DESC" LINE 1: ...ion"."storage_name", ROW_NUMBER() OVER (ORDER BY DESC) OVER... I need to debug this. I would like to see the full SQL, before it is even sent to Postgres (since it is failing). How can I do this? From a working queryset, I would simply do: In [60]: qs = Consumption.objects.values('name') In [61]: print(qs.query) SELECT "consumption_consumption"."name" FROM "consumption_consumption" -
Docker: Cannot Start Service Worker Mounts Denied
I have tried with the latest version of my channel (Stable or Edge) and I have uploaded Diagnostics Diagnostics ID: C0EB54F4-8235-4BED-9A4C-04C8B108E25E/20181113154016 Expected behavior I received some Django work that I'm trying to open in Docker but I keep getting this Error when I try to use docker-compose up -d Actual behavior ERROR: for worker Cannot start service worker: Mounts denied: The path /var/www/static is not shared from OS X and is not known to Docker. You can configure shared paths from Docker -> Preferences... -> File Sharing. See https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info. Information macOS Version: High Sierra Diagnostic logs Docker for Mac: version 18.06.1-ce, build e68fc7a Steps to reproduce the behavior Navigate into project folder run docker-compose build run docker-compose up -d When I use the docs info on the problem (https://docs.docker.com/docker-for-mac/osxfs/#namespaces) I can finally locate the file, but then am unable to add it to the path using file sharing, because it says the path does not exist in OS. Please help! -
Can you use json/xml instead of a headless cms?
I am migrating multiple websites from Wordpress to Django, for majority of dynamic contents I am going to use either APIs or Django models for blogs, but howabout the static contents? I know some people recommend headless CMS, but I am not sure if it would be as flexible as a simple json file. Does anybody know if it is a common practice to render static contents using a json or xml file? Also does anybody know if is going to have any impact on the performance of the website if all the contents, colours and images are rendered using a json file. Is there any better solution other than headless CMS for this? I have checked Django CMS but again I think it is over complicated and it would not be easy for copy writers to use it. -
Bootstrap collapse "in" class has no effect
I am trying to use Bootstrap's collapse class to toggle an element when the checkbox is clicked. The page should load with the checkbox unclicked and the element displayed. When the box is clicked, the element should hide. I am trying to achieve that with the "in" class, but the page renders the same way (with the element starting hidden) regardless of if I include the in class or not. Here is my code. I am using Django for the backend, which utilizes the elements in curly braces. <!DOCTYPE html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Javascript --> <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> <!-- Bootstrap --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <!-- Add additional CSS in static file --> {% load static %} <link rel="stylesheet" href="{% static 'custom.css' %}"> <link rel="shortcut icon" href="{% static 'favicon.ico' %}"> <title>Website Vetting</title> </head> <body> <div> <!-- Header --> <h1 class="bg-dark text-white p-2 text-center mb-0">Identifying Dark Patterns</h1> </div> <h2 class="m-3"> Website Vetting </h2> <form method="POST" enctype="multipart/form-data" class="m-3"> {{ formset.management_form }} {% for form in formset %} {% csrf_token %} <div style="max-width: 758px;"> {{ form.site }} </div> <label data-toggle="collapse" … -
Django page not saving data correctly
I have a form in a HTML page that I'm using for a Django project. This form takes the input from the user and sends it to a page which should save it to the database, but right now its not doing do. Here is the code: <!DOCTYPE html> <html> <body> <h2>Create product here</h2> <div> <form id="new_user_form" method="post" action="user/create"}> {% csrf_token %} <div> <label for="name" > Name:<br></label> <input type="text" id="name"/> </div> <br/> <div> <label for="description"> description:<br></label> <input type="text" id="description"/> </div> <div> <label for="price" > price:<br></label> <input type="text" id="price"/> </div> <div> <input type="submit" value="submit"/> </div> </div> </form> </body> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> </html> My urls.py file: from django.contrib import admin from django.urls import path from django.conf.urls import include, url from testapp import views admin.autodiscover() urlpatterns = [ path('admin/', admin.site.urls), path('', views.index), path('user/create', views.create_user, name='create_user') ] The views.py file: from django.shortcuts import render from testapp.models import User from django.http import HttpResponse def index(request): return render(request, 'index.html') def create_user(request): if request.method == 'POST': name = request.POST.get('name') description = request.POST.get('description') price = request.POST.get('price') newUser = User( name = name, description = description, price = price ) newUser.save() return HttpResponse('') And the models.py file: from django.db import models # Create your models here. class User(models.Model): name = … -
Django navbar links disappearing in the post
So sorry probably this is very easy but i learn django and have a problem. My navbar working on index page is perfectly. but when i go contact form or another post url, navbar links disappear. When i go some post page or my contact form page 1- {{ article.title }} and href links are disappear Can i ask help ? my navbar.html {% load i18n %} <!-- Menu --> <div class="menu-wrapper center-relative"> <nav id="header-main-menu"> <div class="mob-menu">Menu</div> <ul class="main-menu sm sm-clean"> <li><a href="{% url "index" %}">{% trans "HomePage" %}</a></li> <li><a href="#services">{% trans "Services" %}</a></li> <li> {% for article in articles %} {% if article.slug == 'about_us' %} <a href="{% url 'article:detail' slug=article.slug %}"> {{ article.title }}</a> {% endif %} {% endfor %} </li> <li><a href="#video">{% trans "HELLO WORLD" %}</a></li> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-1643 dropdown"> <a title="" href="">{% trans "Producs" %}</a> <ul role="menu" class=" dropdown-menu"> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-1644 dropdown"> <a title="Level 2" href="">{% trans "Consult" %}</a> <ul role="menu" class=" dropdown-menu"> <li > {% for category in category %} {% if category.name == 'consult' %} {% for article in category.get_article %} <a title="{{ article.title }}" href="{% url 'article:detail' slug=article.slug %}"> <p> {{ article.title }}</p></a> {% endfor %} … -
Create shopping cart with flask and python
I've created a website using flask and would like to add a shopping cart. I've tried looking up to do it with flask but have come up empty. I understand that there are packages that help you do that such as satchel but i don't know how to implement it and I've found no resources that can help me do it. I'm not trying to code a shopping cart from scratch( unless that is possible). I simply want to implement it but I don't know where to start. If anyone could assist me with points or links or free resources I'd appreciate that. -
Version issue:Django1.11 for Django2.0
this is in Django1.11: url(r'', include('learning_logs.urls', namespace='learning_logs')) if we use Django2.0,help me! -
Problem with set value in view and template
I want to create a list where the user can give titles to his list in which he selects in which category he should be, this is how the model looks like class UserListAnime(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) anime = models.ManyToManyField(Anime, through='ListAnime') class Anime(models.Model): title = models.CharField(max_length=200) slug = extension_fields.AutoSlugField(populate_from='title', blank=True) class ListAnime(models.Model): LIST_CHOICES = ( (WATCHING, 'Oglądam'), (PLANNING, 'Planuję'), (COMPLETED, 'Ukończone'), (DROPPED, 'Porzucone'), (ONHOLD, 'Wstrzymane'), (MISSING, 'Pomijam'), ) user = models.ForeignKey(UserListAnime, on_delete=models.CASCADE, null=True, blank=True) anime = models.ForeignKey(Anime, on_delete=models.CASCADE, null=True, blank=True) type = models.CharField(max_length=30, choices=LIST_CHOICES, null=False, blank=False) In the view I only have to take a list of the user and I have displayed it but I want it to be filtered through the type in ListAnime def ListAnimeView(request, pk, username): list_anime = UserListAnime.objects.filter(user__pk=pk, user__username=username, listanime__type='ogladam', anime__listanime__type='ogladam').all() context = locals() and html looks like {% for list in list_anime.anime.all %} {{ list }} {% endfor %} My question is how to extract all records when type = LIST_CHOICES and show this in html -
Django : How to associate a user to a created post when post is created through a ModelForm
I created a normal Django posts app , which basically create a post and its content. Now the thing is that I implemented the create post form as a modelform in forms.py .Now if it wasnt a modelform and just a html-form , I would have user request.POST.get('data') But now when I used class PostForm(forms.ModelForm): class Meta: model = Post fields = ( 'title', 'content', 'image', ) Model.py class Post(models.Model): title = models.CharField(max_length=100) image = models.ImageField(null=True,blank=True) content = models.TextField() user = models.ForeignKey(User,on_delete=models.CASCADE,null=True) Views.py def create(request): form = PostForm(request.POST or None) if form.is_valid(): instance = form.save(commit=False) instance.save() return HttpResponseRedirect('/home') return render(request,'create.html',{'form':form}) How can I join a user to a created post -
Python manage.py runserver throws an error
I have been running my python server for a few months now but without using the virtual environment and I have no problems, but ever since I have installed react-native I now get the following error. I don't know if the python problem is related to the installation of react-native but it seems like a bit of coincidence. Any help in solving this issue would be appreciated File "manage.py", line 14 ) from exc ^ SyntaxError: invalid syntax code here -
Elasticsearch indexing stops on certain index
When I try indexing it by bulk_indexing() process it stops on certain index. I changed heap_size in jvm.options it doesn't help. This is the output: Product 489 indexed Product 490 indexed Product 491 indexed Product 492 indexed Product 493 indexed Product 494 indexed Product 495 indexed Product 496 indexed Product 497 indexed Product 498 indexed Product 2280 indexed POST http://localhost:9200/_bulk [status:N/A request:0.001s] Traceback (most recent call last): File "", line 1, in File "/code/products/documents.py", line 93, in bulk_indexing bulk(client=es, actions=(p.indexing() for p in models.Product.objects.all().iterator())) File "/usr/local/lib/python3.6/site-packages/elasticsearch/helpers/init.py", line 257, in bulk for ok, item in streaming_bulk(client, actions, **kwargs): File "/usr/local/lib/python3.6/site-packages/elasticsearch/helpers/init.py", line 192, in streaming_bulk raise_on_error, **kwargs) File "/usr/local/lib/python3.6/site-packages/elasticsearch/helpers/init.py", line 99, in _process_bulk_chunk raise e File "/usr/local/lib/python3.6/site-packages/elasticsearch/helpers/init.py", line 95, in _process_bulk_chunk resp = client.bulk('\n'.join(bulk_actions) + '\n', **kwargs) File "/usr/local/lib/python3.6/site-packages/elasticsearch/client/utils.py", line 76, in _wrapped return func(*args, params=params, **kwargs) File "/usr/local/lib/python3.6/site-packages/elasticsearch/client/init.py", line 1150, in bulk headers={'content-type': 'application/x-ndjson'}) File "/usr/local/lib/python3.6/site-packages/elasticsearch/transport.py", line 314, in perform_request status, headers_response, data = connection.perform_request(method, url, params, body, headers=headers, ignore=ignore, timeout=timeout) File "/usr/local/lib/python3.6/site-packages/elasticsearch/connection/http_urllib3.py", line 175, in perform_request raise ConnectionError('N/A', str(e), e) elasticsearch.exceptions.ConnectionError: ConnectionError(: Failed to establish a new connection: [Errno 111] Connection refused) caused by: NewConnectionError(: Failed to establish a new connection: [Errno 111] Connection refused) -
Serving django app in an intended location (NGINX)
I have a web server serving my Django app (using NGINX) and I need to access it in a defined "location". For example, I access my Django app XPTO in "ip:port/" but I need to access it like "ip:port/XPTO/". All urls specified in Django have to be resolved "after" this "base url". Anyway I can do this without messing with my "urls.py" in Django? I had tried some configurations on NGINX but nothing worked. Thanks in advance! -
Generating model one-to-one field with django-autofixtures
I'm trying to create fake data for my model which is linked to the auth.User. I'm running Python 3.7 with Django 2.1. models.py Class Person(models.Model): user = models.OneToOneField(User, on_delete=models.SET_NULL, null=True) about = models.CharField(max_length=200) autofixtures.py Class PersonGenerator(AutoFixture): field_values = { 'user':InstanceGenerator(autofixture=UserFixture(User)), 'about': LoremGenerator(max_length=200) } register(Person,PersonGenerator) Then I run the autofixtures file to register my generator py manage.py shell >>> exec(open('myapp/autofixtures.py').read()) >>> exit() py manage.py loadtestdata myapp.Person:50 I've got the following error message: File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "D:\..\env\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line utility.execute() File "D:\..\env\lib\site-packages\django\core\management\__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "D:\..\env\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv self.execute(*args, **cmd_options) File "D:\..\env\lib\site-packages\django\core\management\base.py", line 353, in execute output = self.handle(*args, **options) File "c:\users\manhn\appdata\local\programs\python\python37-32\Lib\contextlib.py", line 74, in inner return func(*args, **kwds) File "D:\..\env\lib\site-packages\autofixture\management\commands\loadtestdata.py", line 225, in handle autofixture.create(model, count, **kwargs) File "D:\..\env\lib\site-packages\autofixture\__init__.py", line 136, in create return autofixture.create(count, **create_kwargs) File "D:\..\env\lib\site-packages\autofixture\base.py", line 554, in create instance = self.create_one(commit=commit, **kwargs) File "D:\..\env\lib\site-packages\autofixture\base.py", line 501, in create_one self.process_field(instance, field) File "D:\..\env\lib\site-packages\autofixture\base.py", line 400, in process_field value = self.get_value(field) File "D:\..\env\lib\site-packages\autofixture\base.py", line 396, in get_value value = generator() File "D:\..\env\lib\site-packages\autofixture\generators.py", line 71, in __call__ return self.get_value() File "D:\..\env\lib\site-packages\autofixture\generators.py", line 67, in get_value value = self.generate() File "D:\..\env\lib\site-packages\autofixture\generators.py", line 535, in generate return self.autofixture.create()[0] File "D:\..\env\lib\site-packages\autofixture\base.py", … -
Django - Collector dependencies does not include models in which the deleteable model is a nullable field
Supposing I have the following models: class Foo(models.Model): ... class Bar(models.Model): foo = models.ForeignKey(Foo) class Baz(models.Model): foo = models.ForeignKey(Foo, null=True, blank=True) If I tried to use the Django Collector, as follows, I would get all the dependencies except for Baz: from django.db.models.deletion import Collector def get_related_models(obj): collector = Collector(using='default') collector.collect([obj]) return collector.dependencies.get(obj.__class__, set()) The reason, I suspect, was that Foo was a nullable field in Baz, so Collector probably thinks deleting a Foo would only make the corresponding Baz object's Foo field point to null. However, if you delete a Foo the related Baz would be deleted too. I would like to inform my users that Baz is dependent on Foo, despite the Foo field in Baz being nullable. -
Problems in reading static files with docker and django
I am new at the development with Django and Docker. I am creating a small project to grab some knowledge in its use. However, I am not able to load the static files (css, javascript). There is some configuration that I am using right now: docker-compose.yml version: '3' services: # database containers, one for each db database1: image: postgres:10 volumes: - database1_volume:/var/lib/postgresql/data env_file: - config/db/database1_env networks: - database1_network # web container, with django + gunicorn djangoapp: build: . restart: on-failure volumes: - .:/opt/services/djangoapp/ - static:/opt/services/djangoapp/app/static networks: - database1_network - nginx_network depends_on: - database1 expose: - "8000" # reverse proxy container (nginx) nginx: image: nginx:1.13 ports: - 8000:80 volumes: - ./config/nginx/conf.d:/etc/nginx/conf.d - static:/opt/services/djangoapp/app/static networks: - nginx_network depends_on: - djangoapp networks: database1_network: driver: bridge nginx_network: driver: bridge volumes: database1_volume: static: media: dockerfile FROM python:3.6 #RUN pip install pipenv && pipenv install --system RUN mkdir -p /opt/services/djangoapp/ WORKDIR /opt/services/djangoapp/ COPY requirements.txt /opt/services/djangoapp/ RUN pip3 install -r /opt/services/djangoapp/requirements.txt COPY . /opt/services/djangoapp/ RUN cd app && python manage.py collectstatic --noinput EXPOSE 8000 CMD ["gunicorn", "-c", "config/gunicorn/conf.py", "--bind", ":8000", "--chdir", "app", "app.wsgi:application"] nginx local.conf upstream app_server { server djangoapp:8000; } server { listen 80; server_name localhost; location /static/ { autoindex on; alias /opt/services/djangoapp/app/static; } location / … -
how can I increase the value of my article in another model view for example in django
So here, I would like the quantity existing of my Article model to increase when saving the Purchase model, Here is my code in views.py that does not work! I need your help because it is urgent and I am still a beginner in Django. thank you in advance def achat_form_view(request): if (request.method == 'POST'): form = AchatForm(request.POST,error_class=ParagraphErrorList) if form.is_valid(): Article.quantite = Article.quantite + Achat.quantite_a form.save(commit=True) return redirect('manapoitra_achat') else: form = AchatForm() return render(request, 'achatH.html', {'form': form}) -
How can I add a new record with multiple actie_gebruiker(s) via the Python shell?
Here are the imports: from django.db import models from datetime import datetime, timedelta from django.contrib.auth.models import User This is the first class I defined. It is the status of the action (Actie) and it has a status-id and a status-name with a max_length attribute of 5 (todo, doing, done) class Status(models.Model): id = models.IntegerField(primary_key=True) status_naam = models.CharField(max_length=5, default='todo') def __str__(self): return str(self.id) + " - " + self.status_naam This is the class Actie (Action or the action the user determines) wich has an id, an action-name, a action-status wich refers to the table Status here above, an action-publish-date, an ending-date (the deadline) and a user-id wich refers to the table Users django gives me. class Actie(models.Model): id = models.IntegerField(primary_key=True) actie_naam = models.CharField(max_length=150, default='-') actie_status = models.ForeignKey(Status, default=1) actie_aanmaakdatum = models.DateTimeField(default=datetime.now()) actie_einddatum = models.DateTimeField(default=datetime.now() + timedelta(days=1)) actie_gebruiker = models.ManyToManyField(User) def __str__(self): return str(self.id) + " - " + self.actie_naam My question now is how can I add a new Actie-object with multiple actie_gebruiker(s) via the Python shell like what command do I have to use..? -
Django unitests WARNING:uwsgi_tasks:UWSGI environment is not available
Running django ./manage.py test gives me following error: WARNING:uwsgi_tasks:UWSGI environment is not available, so task <TaskFactory: "app.tasks.sometask"> will be executed at runtime Is there anyway to avoid these warnings while running django unit test ? Or we should ignore these warnings ? -
Deploy python 3.6.5 Django app on heroku-18 stack
So, I am deploying my first django app to heroku for the first time. I have configured the app locally, pushed it to my remote repository. But when I push the code to my heroku repository, the build fails giving the reason that python 3.6.5 is not available on current stack (heroku-18). It also says here that heroku-18 supports 3.6.6. My simple question is "How do I deploy my python 3.6.5 app on current stack (heroku-18)?" -
adding a user to a group doesn't automatically add permissions
I have some Django Users, Groups, and Permissions. I thought that the point of Groups was to add/remove multiple permissions at once. But maybe I am misunderstanding things. Here is some code: from django.contrib.auth import get_user_model from django.contrib.auth.models import Group, Permission from django.contrib.contenttypes.models import ContentType User = get_user_model() bob = User.objects.get(username="bob") user_content_type = ContentType.objects.get_for_model(User) test_permission = Permission(name="test", codename="test", content_type=user_content_type) test_permission.save() test_group = Group(name="test") test_group.save() test_group.permissions.add(test_permission) Now if I add bob to the "test" group, I assume that he would get all of the "test" permissions as well. But I get the following output: test_group.user_set.add(bob) print bob.groups.all() >>> <Queryset [<Group: test>]> print bob.user_permissions.all() >>> <Queryset []> Obviously, I can add "test" permission manually. But I don't want to. -
Pysassc not genearing source maps in django compressor
I'm in my development environment (settings.DEBUG=True) and want to add a source map to ease my life. We are currently using django compressor to compile sass. Its settings are like this: COMPRESS_PRECOMPILERS = ( ('text/x-sass', 'pysassc {infile} {outfile} --sourcemap'), ) pysassc has a sourcemap option. In the CLI, I use it like this: pysassc APP_NAME\static\APP_NAME\scss\main.scss staticfiles\APP_NAME\css\main.css --sourcemap This works perfectly and creates main.css as well as main.css.map. The problem is that it doesn't appear to work when I run it with through django compress. As django compress adds a hash whenever it compiles something, creating the source map from the CLI serves me little purpose as the generated source map would lack the hash. I tried the following, with both the debug flag turned on or off: python manage.py collectstatic --clear --no-input python manage.py compress --force python manage.py runserver I think there must be something about django compressor that I'm missing. I couldn't find a way to see what commands it actually runs, so I'm debugging in the dark here. How do you create source maps with django compress? -
How to do arthimetic operations on database values in django
I have Prof:AssociateProf:AssistantProf = x:y:z in database and I have to do these operations x/(x+y+z) : y/(x+y+z) : z/(x+y+z) in django. Can anyone help me on this and models.py is class Show(models.Model) : Total = models.IntegerField(default = 0) Prof = models.IntegerField(default = 0) AssociateProf = models.IntegerField(default = 0) AssistantProf = models.IntegerField(default = 0) ResearchScholar = models.IntegerField(default = 0) MTech = models.IntegerField(default = 0)