Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to template tag for @property in django
I defined field in air with @property. this is my @property field: @property def points(self): if self.pk: return self.questions.all().aggregate(Sum('point'))['point__sum'] else: return 0 Then I create template tag for verbose_name in django template: from django import template register = template.Library() @register.simple_tag def verbose_name(instance, field_name): """ Returns verbose_name for a field. """ return instance._meta.get_field(field_name).verbose_name.title() When I use : {% verbose_name exam "prices" %} raise this error: Exam has no field named 'prices' How can I define verbose_name for @property and then use template tag for show verbose_name of this `@property? -
LocaleMiddleware not selecting requested available language
I am having trouble making django.middleware.locale.LocaleMiddleware set Chinese language as per the cookies/header I specify in the request. After some debugging, I have narrowed it down to the the following function, which rejects it django.utils.translations.trans_real.check_for_language all_locale_paths returns only django's locales, which do not contain 'cn'. My apps are packaged and installed separately from the project itself, and they provide their own 'cn' language files, which get discovered successfully, but since their locale directories are not specified in LOCALE_PATHS, the middleware does not check them. What is the best approach to avoid this problem? I am not adding the LOCALE_PATHS, as the app locations differ based on the different environments the project is deployed. I could import the app, and find the paths from it, but that seems like an overkill. -
Do Django aggregate functions use indexes?
I have a django model with a huge number of instances (rows) in the database (Postgres). Then I'm aggregating a decimal field of the model and averaging it. My question is, would it speed up the aggregation process to set and index for that field? Example of what I'm doing: class Blog(models.Model): name = models.CharField(max_length=10) lines_per_page = models.DecimalField() Blog.objects.all().aggregate(x=Avg('lines_per_page'))[x] Would then make the following change improve the aggregation? class Blog(models.Model): name = models.CharField(max_length=10) lines_per_page = models.DecimalField(db_index=True) Blog.objects.all().aggregate(x=Avg('lines_per_page'))[x] As I said my database is huge, only the table of the model I'm working with occupies ~6GB. -
No name 'path' in module 'django.urls'
I'm trying to set up a Django project using AWS Cloud9 - this is the first time I have used Cloud9 since it moved to AWS, although I had used it for projects previously. I thought I had created the project with no problems, but I am getting a error in urls.py relating to the import of 'path' from django.urls. I am using a virtual environment with Python 3.6.8 and Django 2.2.4, but currently I cannot run the project because of this error. On a previous Cloud9 based project, I was using Django 2.1 with Python 3.6 and had no errors with this code. This is all that is currently in urls.py: from django.contrib import admin from django.urls import path urlpatterns = [ path('admin/', admin.site.urls), ] Trying to run the project, I get this error: Traceback (most recent call last): File "/home/ec2-user/environment/project/urls.py", line 17, in <module> from django.urls import path ImportError: cannot import name path -
How to reformat a date from an api
i am trying to get data from a weather api and save in my database using django, and whenever i want to send the date from the api to the database i get an error related to the format of the data. Django datefield expects 'YYYY-MM-DD' format. this is my models.py class Weather_data(models.Model): date = models.DateField(blank=True, null=False) min_temp = models.IntegerField(default=0) max_temp = models.IntegerField(default=0) wind = models.IntegerField(default=0) rain = models.CharField(max_length=10, null=True) def __str__(self): return self.id this is my views.py def index(request): url = "http://weather.news24.com/ajaxpro/Weather.Code.Ajax,Weather.ashx" headers = {'Content-Type': 'text/plain; charset=UTF-8', 'Host': 'weather.news24.com', 'Origin': 'http://weather.news24.com', 'Referer': 'http://weather.news24.com/sa/capetown', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) ' 'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36', 'X-AjaxPro-Method': 'GetForecast7Day'} payload = {"cityId": "77107"} r = requests.post(url, headers=headers, data=json.dumps(payload)) weather_data = r.json() print(weather_data) for i in range(0, 7): api_data = { 'date': weather_data['value']['Forecasts'][i]['Date'], 'min_temp': weather_data['value']['Forecasts'][i]['LowTemp'], 'max_temp': weather_data['value']['Forecasts'][i]['HighTemp'], 'wind': weather_data['value']['Forecasts'][i]['WindSpeed'], 'rain': weather_data['value']['Forecasts'][i]['Rainfall'], } Weather_data.objects.create(**api_data) context = { 'objects': Weather_data.objects.all() } return render(requests, 'weather_app/index.html', context) i am expecting to get the date in 'YYYY-MM-DD' format but the date that i have from the api is '/Date(1565301600000)/' format, i am not sure on how to reformat this date into django datefield(YYYY-MM-DD). the error that i get is this: django.core.exceptions.ValidationError: ["'/Date(1565301600000)/' value has … -
Why images can't upload them with a django2 form?
I'm trying to make a form, with the ModelForm class, for people to be recruited by a small company. So I need photo of their identity card (face and back) and their life card. The problem is that when I send the form, after selecting the photos from my computer, it does not register in the database (not even the path), and they do not a copy to the desired media folder. By cons, if I do it from the admin, it works, I can even open the image in my browser. However, they still do not upload to the media folder. models.py : from django.db import models from django.contrib.auth.models import User class UserExtention (models.Model): user = models.OneToOneField(User, on_delete = models.CASCADE, null=True, verbose_name='utilisateur') phone_number = models.CharField (max_length = 10, null = True, blank=True, verbose_name='numéro de téléphone') postal_code = models.IntegerField (null = True, blank=True, verbose_name='code postal') town = models.CharField (max_length=50, null=True, blank=True, verbose_name='ville') address = models.CharField (max_length=500, null=True, blank=True, verbose_name='adresse') id_card_recto = models.ImageField (upload_to = 'pictures/id_card_recto', null=True, blank=True, verbose_name="photo du recto de la carte d'identité") id_card_verso = models.ImageField (upload_to = 'pictures/id_card_verso', null=True, blank=True, verbose_name="photo du verso de la carte d'identité") vital_card = models.ImageField (upload_to = 'pictures/vital_card', null=True, blank=True, verbose_name="photo de la … -
Django object create with one or more items (dynamically)
Is there a way to use model.objects.create(<dict>) Say my model has many optional fields. I would like to just pass a dict with whatever is there instead of manually assigning each field like: Model.objects.create(thing=data['prop'],...) Here's a more clear (pseudo code) example: Say i've got a model thats got class MyModel(models.Model): thing=models... // all these fields null=True, blank=True another=... possibly_another=... ... data = {'thing': 'value for thing', 'another': 'value for another'} MyModel.objects.create(data) In this example my data doesn't have possibly_another and maybe more. I have tried doing this but i'm getting a positional arg error... I did some google-foo and i must not have my terms correct. (I'm more of a node/js guy) Is there a way to just pass the dict and have the create method sort out what's there and not? -
No access to static files on AWS S3
On the django project I use Nginx to access static files placed on AWS S3. After successful completion of the command collectstatic the styles still didn't apply to the project. When I activate the debbugger in my browser, I can see that the requests for static files are on the right path, but they are not accessible (index):18 GET https://mysite-staging.s3.amazonaws.com/static/admin/css/icons.css net::ERR_ABORTED 403 (Forbidden) (index):37 GET https://mysite-staging.s3.amazonaws.com/static/lifeline/css/global.css net::ERR_ABORTED 403 (Forbidden) (index):24 GET https://mysite-staging.s3.amazonaws.com/static/material/js/jquery.js net::ERR_ABORTED 403 (Forbidden) How do I access it? Do you need to change Nginx settings for this purpose? My current nginx config location /s3/ { proxy_http_version 1.1; proxy_set_header Connection ""; proxy_set_header Authorization ''; proxy_set_header Host mysite-staging.s3.amazonaws.com; proxy_hide_header x-amz-id-2; proxy_hide_header x-amz-request-id; proxy_hide_header x-amz-meta-server-side-encryption; proxy_hide_header x-amz-server-side-encryption; proxy_hide_header Set-Cookie; proxy_ignore_headers Set-Cookie; proxy_intercept_errors on; add_header Cache-Control max-age=31536000; proxy_pass https://mysite-staging.s3.amazonaws.com/; } -
Combine network host and bridge for Nginx and Django
I am dockerizing a Django application, using also Nginx as proxy. My problems is that the DB is running (non dockerized) on the same machine of the where the dockers are hosted. Therefore, i have to use network_mode: "host" for the django app in order to connect to the db using localhost. On the other side, if I do so, the nginx image is not able to reach the Django app anymore and gives nginx: [emerg] host not found in upstream My docker compose file is the following: version: '3.4' services: web: build: . command: sh /start.sh networks: - db_network - web_network volumes: - static_volume:/allarmi/src/AllarmiWs/static expose: - 8001 environment: - DEBUG=0 - DJANGO_SETTINGS_MODULE=AllarmiWs.settings.deploy nginx: build: ./nginx ports: - 8000:80 depends_on: - web volumes: - static_volume:/allarmi/src/AllarmiWs/static networks: - web_network volumes: static_volume: networks: web_network: driver: bridge db_network: driver: host How can I do it -
which database is best suited for django Mongodb or Mysql
help me with which database best suits for django , so that it will not affect its performance -
JavaScript MIME type warning on Firefox
I am loading the java-script file in Django template: <script type="application/javascript" src="{% static 'online-v3.js' %}"></script> It is loading properly on Chrome. But, on Firefox I get the following warning: The script from “http://127.0.0.1:8000/static/myscript.js” was loaded even though its MIME type (“text/plain”) is not a valid JavaScript MIME type. I fear that due to this problem, on some browser the JS file might not load at all. What is the possible reason for this and how can I solve this issue? -
How to append two separate forms to the end of a url in Django
I am attempting to create a django web app, and I'm running into an issue with forms. I have a simple index.html set up that has two separate regular html forms on the page. One for filtering and the other for sorting. Currently, I can get either filtering, or sorting to work, but not both at the same time. I think this is because I'm missing a fundamental understanding of django somewhere. Yes, I've done the tutorials. I've attempted manually appending the URL to my urlconfig, but that didn't work as intended. <form action="" method="get"> {% for filter in view.all_filters %} <label> <input type="checkbox" name="filter" value="{{ filter }}"> {{ filter }} </label> {% endfor %} <input type="submit" value="Apply Filters"> </form> <form action="." method="get"> <label> Sort By <select name="order_by"> <option value="name">Name</option> <option value="description">Description</option> <option value="cvssBaseScore">Cvss Base Score</option> <option value="cvssV3BaseScore">Cvss V3 Base Score</option> </select> </label> <input type="submit" value="Submit"> </form> I would like the url to be able to append something like ?filters=one&filters=two&order_by=name or something as such. -
How integrate beautifulsoup4 library into django?
Everybody knows the great library BeautifulSoup4, but how to use it with django2? The task was to create a web application that helps programmers find work. So that all logic and interface are based on django, and scraper BeautifulSoup collects information on vacancies on job search sites and displays them to the user. I couldn't find any explanation for how to put them together anywhere on the network. I know about scrapy, but it doesn't support django 2 at the moment. BeautifulSoup's documentation does not provide an answer. Thank for your attention! -
Display in HTML answers to MultiSelectField (checkboxes) without forms.py - multiselectfield.db.fields.MSFList
I created a website where a user can upload a project and answer some questions related to it. One of the questions, the initial one, involves the user to select options among two check boxes. models.py class Initialquestion(models.Model): INITIAL_ONE_CHOICES = ( ('Diagnostic', 'Diagnostic'), ('Therapeutic','Therapeutic'), ('Population health','Population health'), ('Care-based','Care-based'), ('Triage','Triage'), ('Self-care','Self-care'), ('Health promotion','Health promotion'), ('Remote Monitoring','Remote Monitoring'), ('Remote Consultation','Remote Consultation'), ('Other','Other'), ) INITIAL_TWO_CHOICES = ( ('Primary Care', 'Primary Care'), ('Secondary Care','Secondary Care'), ('Tertiary Care','Tertiary Careh'), ('Individual Care of Self','Individual Care of Self'), ('Triage','Triage'), ('For the purposes of population screening','For the purposes of population screening'), ('Other','Other'), ) initial_one = MultiSelectField(choices=INITIAL_ONE_CHOICES) intial_two = MultiSelectField(choices=INITIAL_TWO_CHOICES) developer = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) project = models.OneToOneField(Project, on_delete=models.CASCADE) views.py @login_required def initialquestionstoanswer(request, project_id): project = get_object_or_404(Project, pk=project_id) if request.method == 'POST': # if request.POST['initial_one']: question = Initialquestion() question.initial_one = request.POST.getlist('initial_one[]') question.initial_two = request.POST.getlist('initial_two[]') question.developer = request.user question.project = project question.save() messages.success(request, 'Initial questions are created') return redirect('/projects/allprojects') # else: # return render(request, 'initialquestions/initialquestionstoanswer.html', {'error':'All fields are required.'}) return render(request, 'initialquestions/initialquestionstoanswer.html', {'project':project}) This allows me to save into the database the answer to initial_one and initial_two. In fact, if I check with the superuser, both fields are populated with the right value of the checkboxes. I want now to display … -
I want to replace one form field with another when the value of another field is equal to something
The thing I have here doesn't work. It will just get rid of the field once choose US and doesn't go back to the choices even if choose something else. teacher_signup.html {% block content %} <h2>Sign Up As Teacher</h2> <form method="post"> {% csrf_token %} {% for field in form.visible_fields %} {{ field | as_crispy_field}} {% if field.name == "country" %} <input type="button" value="cube" onclick="getcube()"/> {% endif %} {% endfor %} <button class="btn btn-success" type="submit">Sign Up</button> </form> <script> function getcube(){ var county=document.getElementById("id_country").value; alert(county); } $(document).ready(function() { $("#id_country").change(function(){ if (this.value=="US"){ $("#id_state").replaceWith(); } }); }); </script> {% endblock content %} forms.py class TeacherSignUpForm(SignupForm): country=CountryField(blank_label='(select country)').formfield() # this is just doing the same thing as country=forms.CharField(max_length=20, widget=forms.Select(choices=COUNTRY_CHOICES), required=True) state=forms.CharField(max_length=20,required=True) I want to replace the state field with state=forms.CharField(max_length=20, widget=forms.Select(choices=STATE_CHOICES), required=True, strip=True) if the country=="US" and if they choose something else, then it will just show the text field. -
Employee login page should redirect based on the designation.included the models and forms code
Here I added the my models. department and designation foreign key from Department and Designation models Once the Employee login with credential page should redirect based on the employee Designation and Department models.py class Department(models.Model): Name = models.CharField(max_length=50) def __str__(self): return self.Name class Meta: db_table = 'department' class Designation(models.Model): Name = models.CharField(max_length=50) department = models.ForeignKey(Department, on_delete=models.CASCADE) def __str__(self): return self.Name class Meta: db_table = 'desingnation' class Emp_Profile(AbstractUser): Mobile_Number = models.IntegerField(null=True,blank=True) department = models.ForeignKey(Department, null=True, blank=True, on_delete=models.CASCADE) designation = models.ForeignKey(Designation, null=True, blank=True, on_delete=models.CASCADE) def __str__(self): return self.username class Meta: db_table = 'emp_table' forms.py This is my user extended Users class UserForm(UserCreationForm): class Meta(UserCreationForm.Meta): model = Emp_Profile fields = UserCreationForm.Meta.fields + ('Mobile_Number','department','designation') -
Django Admin change list Hide one of the choices option for users
I have a model with an integer field. This field has choices option. As you can see Request has 4 available statuses. I want to display only three of them on the edit template and celery task will change status from 3 to 4th state every 12 hours. So when a user in the admin panel can change the status only to 1, 2 or third status but not to 4th one. Model code UNPROVEN = 1 IN_PROGRESS = 2 IN_LINE_FOR_DELETE = 3 DELETED = 4 _STATUS = [ (UNPROVEN, "Unproven"), (IN_PROGRESS, "In progress"), (IN_LINE_FOR_DELETE, "In line for deletion"), (DELETED, "Deleted") ] delete_user = models.ForeignKey('BoosteroidUser', on_delete=models.SET(get_deleted_user), related_name='%(class)s_delete') delete_reason = models.TextField(max_length=1024) status = models.IntegerField(default=1, choices=_STATUS, blank=False) responsible_user = models.ForeignKey('BoosteroidUser', on_delete=models.SET(get_deleted_user), null=True, blank=True, default=None)``` Code from admin ```@admin.register(UserDeleteRequest) class UserDeleteRequest(admin.ModelAdmin): list_display = ("status", "responsible_user") fields = ("delete_user", "status", "responsible_user", "delete_reason") readonly_fields = ("responsible_user", "delete_user", "delete_reason") def has_add_permission(self, request): return False def has_delete_permission(self, request, obj=None): return False def save_model(self, request, obj, form, change): if obj.status == 3 or 2: obj.responsible_user = request.user super().save_model(request, obj, form, change)``` So I expected that any user in the admin panel will be able to see and choose only first 3 statuses but not the 4th one [Expected … -
Issue with Filter code and using switch function call within class method, Got AttributeError when attempting to get a value for field
Got AttributeError when attempting to get a value for field. Kindly help resolve. Issue is withing the filters code as plain serialization is working well views.py class Job_Application_StateList(generics.ListCreateAPIView): serializer_class = Job_Application_StateSerializer def get_queryset(self): queryset = Job_Application_State.objects.all() request_queries = self.request.query_params if(request_queries): user = self.request.user queryset = Job_Application_State.objects.filter(user = user) status = request_queries.get('status', None) queryset = self.statusFilter(queryset, status) return queryset def statusFilter( self, queryset, args ): switcher = { 'saved': queryset.filter(saved = True), 'applied':queryset.filter(applied = True), 'shortlisted':queryset.filter(shortlisted = True), } return switcher.get("Invalid Status: ", args) models.py class Job_Application_State(models.Model): job = models.ForeignKey(Job, on_delete=models.PROTECT, related_name='applicant_status') user = models.ForeignKey(User, null=True, on_delete=models.PROTECT, related_name='application_status') saved = models.BooleanField() applied = models.BooleanField() shortlisted = models.BooleanField() Error: Got AttributeError when attempting to get a value for field saved on serializer Job_Application_StateSerializer. The serializer field might be named incorrectly and not match any attribute or key on the str instance. Original exception text was: 'str' object has no attribute 'saved'. -
Populating models inner classes from the same table
I had a database composed by: Table1: columns: a1, b1, c1 Table2: columns: a2, b2 And for the models I had: class Table1(models.Model): a1 = models.IntegerField(id) b1 = models.CharField() c1 = models.ForeignKey(Table2) class Table2(models.Model): a2 = models.IntegerField(id) b2 = models.CharField() So to access instances of Table2 all my system worked around this: table1.table2.b2 Bu that database has been reestructured to: Table1: columns: a1, b1, a2, b2 Hence my model became: class Table1(models.Model): a1 = models.IntegerField(id) b1 = models.CharField() table2_a2 = models.IntegerField(id) table2_b2 = models.CharField() So now in order to access the old value b2 I need to: table1.table2_b2 Is it possible to do something like to following model? class Table1(models.Model): class Table2(models.Model): a2 = models.IntegerField(id) b2 = models.CharField() a1 = models.IntegerField(id) b1 = models.CharField() table2 = Table2() table2.a2 = models.IntegerField(id) table2.b2 = models.CharField() -
Django dependencies reference nonexistent parent node when making model changes
I have a Django project deployed on aws server.I made some changes in the models on my machine and pushed the changed by Github and on the server, I pulled the changes by git command but the app isn't working so when I tried running python manage.py makemigrations it returns errors like Django: dependencies reference nonexistent parent node I tried removing the file mentioned in the error and tried removing the .pyc files but still the same problem so what can I do here and how should I do this in the future to avoid these problems. here's the traceback Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv self.execute(*args, **cmd_options) File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute output = self.handle(*args, **options) File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped res = handle_func(*args, **kwargs) File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py", line 89, in handle loader = MigrationLoader(None, ignore_no_migrations=True) File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__ self.build_graph() File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 273, in build_graph raise exc File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/db/migrations/loader.py", line 247, in build_graph self.graph.validate_consistency() File "/home/ubuntu/Eyelizer/eyenv/lib/python3.6/site-packages/django/db/migrations/graph.py", line 243, in validate_consistency [n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)] … -
Load result from requests.get into django template (tableau)?
I've got a super tiny (one view) django application that loads a view from a tableau server. I've got it working with the trust app method of connection and if I just put the URL into a browser it loads up okay without issue. When I try to render that same page inside of a django template however - django tries to load all the resources as if they existed locally (which doesn't work). The view looks like this: def index(request): url = os.environ.get("tableau_HOST") username = request.user.username ticket = get_tableau_ticket(url, username) if ticket: data = requests.get(url+ticket+'/views/SIPPlan/DashboardView', data={'username': username}) print(data.text) else: # Handle the error - not implemented yet r = ticket return render( request, "tableau/index.html", { "tableau_data": data.text, }, ) Inside my template it looks like this: {% extends "myapp/base_template.html" %} {% load static %} {% block content %} {% autoescape off %} {{ tableau_data }} {% endautoescape %} {% endblock %} When I load the view - I see it trying to load the resources from my local machine (which it shouldn't, they exist on the tableau server). [09/Aug/2019 08:26:28] "GET /vizql/v_201921906211547/javascripts/formatters-and-parsers.en_US.js HTTP/1.1" 404 3610 Not Found: /vizql/v_201921906211547/javascripts/vqlweb.js 2019-08-09 08:26:28,639 - django.request WARNING Not Found: /vizql/v_201921906211547/javascripts/vqlweb.js [09/Aug/2019 08:26:28] "GET … -
How to save the number of registered users in mongodb?
I have a problem and I am looking for a solution. I want to save the number of users registered in mongodb. For example, in django, the admin page has the number of registered users, and all other data is saved there. I want it to be saved in mongodb database instead of showing it on admin page, because my other data is also saved in mongodb. How do I do this? Should I make separate a class in models.py or something else. -
How to list the id with getlist method in Django checkbox
html file Here I list the client and Process in the input tag And select the and submit {% for client in form %} <tr> <td> <input type="checkbox" name="cname[]" value="{{ client.id }}"> {{ client.Name }} </td> <td> {% for process in client.clients %} <input type="checkbox" name="process[]" value="{{ process.id }}"> {{ process.process }}<br /> {% endfor %} </td> </tr> {% endfor %} views file The below code is get the selected in checkbox. The getlist method return nothing if request.method == "POST": cname = request.POST.getlist('cname[]') print("cname", cname) process = request.POST.getlist('process[]') print("process", process) -
Implementation of allauth FB auth, "breaks" others urls in Django?
I'm following this answer, but when I add, these lines to settings.py, cannot load localhost:8000/admin/login anymore: 'django.contrib.sites', 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.facebook', Error: Site matching query does not exist. Same error for localhost:8000/users/login but when hit localhost:8000/users urls are there: -
How do i create views.py with Django queryset filter to compare Specific value of two different tables in django?
JOB_TYPE = ( ('1', "Full time"), ('2', "Part time"), ('3', "Internship"), ) class Job(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) title = models.CharField(max_length=300) description = models.TextField() location = models.CharField(max_length=150) type = models.CharField(choices=JOB_TYPE, max_length=10) category = models.CharField(max_length=100) last_date = models.DateTimeField() skillRequired1 = models.CharField(max_length=100, default="") skillRequired2 = models.CharField(max_length=100, blank=True, null=True) work_experience = models.IntegerField(default=0) company_name = models.CharField(max_length=100) company_description = models.CharField(max_length=300) website = models.CharField(max_length=100, default="") created_at = models.DateTimeField(default=timezone.now) filled = models.BooleanField(default=False) def __str__(self): return self.title class EmployeeProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) title = models.CharField(max_length=300) location = models.CharField(max_length=150) type = models.CharField(choices=JOB_TYPE, max_length=10) work_experience = models.IntegerField(default=0) category = models.CharField(max_length=100) emailContact = models.CharField(max_length=100, default="") skill1 = models.CharField(max_length=100) skill2 = models.CharField(max_length=100) skill3 = models.CharField(max_length=100, blank=True) skill4 = models.CharField(max_length=100, blank=True) about_me = models.TextField() images = models.ImageField(upload_to='employeeProfiles', default='default.jpg') def __str__(self): return f'{self.user.first_name} Profile' i have created two database tables 'Job' and other is "employeeProfile".. I want to Compare and match 'title' of both and want to show only those 'title' which is present in Job but not in 'employeeProfile'.These two tables are in two different Models.