Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
No command runs in Subprocess
I have used a subprocess to convert Docx file to Pdf file in Django. On the server when I run the project with python manage.py runserver command. All things working file but if I run the application with Gunicorn my subprocess not work. Simple "ls" command is also not working. My server has ubuntu 18.04. -
Web service inside django
I have built a basic webapp in Python Django (2.1) which manages all domains and subdomains (dns) purchased through Google and Godaddy. What I am trying to do is to make use of Google and Godaddy's REST API so that i can automate the process of adding/updating/deleting it from my webapp. E.g. When i add (purchase) a new domain, i should enter all the details in a webform, then it should query the REST API (using google-cloud/godaddypy modules) and according to the response, it should proceed: if it exists, throw an error, otherwise add it to the local database (mariadb). The problem is that i tried doing it in models.py (overriding save() function), forms.py and views.py but with no success, i keep on getting import errors and so on. Any ideas? I have gone through the documentation, nevertheless i could not find anything relevant. -
Disallowed Host at / , InValid HTTP_POST Header
I have deployed a Django project in VPS.The problem I am facing is when I browse the application using VPS IP then everything works fine but when I add the domain name and point the domain to the VPS IP then it says the following error (see screenshot) Steps I have done : 1. Point the domain to the VPS IP 2. Add domain name in ALLOWED_HOSTS in settings.py 3. Also if I put DEBUG = False, the same message shows as attached screenshot. Which may not be the usual case. Can anyone help? -
Making API robust and flexible
I have two models... Business and User. I want to find if an API can handle a flexible JSON request body. The API I want is to be intelligent enough to work with parameters, if enough are available. That's the design goal. About my specific API: A user might be a customer or business. If a user is a business he has business attributes too. This API should be able to handle changing a few or more attributes. Also, if the request throws him a user_id, it should find the business_id itself or vice versa... class User(models.Model): name = models.CharField(max_length = 40) mobile_number = models.CharField(max_length = 10) email_id = models.EmailField(null=True) prefered_language = models.CharField( max_length=15, choices=languages, default=ENGLISH, null =True, ) class Business(models.Model): user_id = models.ForeignKey(User, on_delete=models.CASCADE) open_time = models.TimeField() close_time = models.TimeField() #open_days= minimumorder = models.SmallIntegerField(null=True, default =0) fee_below_minimumorder = models.SmallIntegerField(null=True, default = 0) distance = models.DecimalField(null=True, max_digits=5,decimal_places=2,default=1.00) class UserSettings(View): def post(self, request): if json.loads(request.body).get('user_id'): user_id = json.loads(request.body).get('user_id') if json.loads(request.body).get('business_id'): business_id = json.loads(request.body).get('business_id') if json.loads(request.body).get('prefered_language'): prefered_language = json.loads(request.body).get('prefered_language') if json.loads(request.body).get('minimumorder'): minimumorder = json.loads(request.body).get('minimumorder`') if json.loads(request.body).get('fee_below_minimumorder'): fee_below_minimumorder = json.loads(request.body).get('fee_below_minimumorder') if json.loads(request.body).get('distance'): distance = json.loads(request.body).get('distance') if json.loads(request.body).get('open_time'): open_time = json.loads(request.body).get('open_time') if json.loads(request.body).get('close_time'): close_time = json.loads(request.body).get('close_time') One solution which I have refuted is of … -
how can i do this joins and select from multi-table in django
plz can someone give me the exacte answer to this question? how can i perfome this query using django ? SELECT a.matr ,[nom] ,[prn] ,cast([dat_nais] as date) as dat_nais , (YEAR(getdate()) - YEAR(dat_nais)) as age ,cast([dat_deces] as date) as dat_deces ,cast([dat_imm] as date) as dat_imm ,cast([dat_aj] as date) as dat_j ,[cod_position] ,YEAR(dat_imm) as anne_imm ,YEAR(dat_encais) as ann_regl ,[annee] ,[cod_nat] ,cast([dat_enc] as date) as dat_regl ,[mt_encais] FROM users a left join enca e on e.matr = a.matr left join encr c on (c.cod_encais = e.cod_encais) where (YEAR(c.dat_enc) - c.annee > 3 ) and ((YEAR(getdate()) - YEAR(a.dat_nais)) between 54 and 70) and c.cod_nat = 'CN' order by a.nom_, a.prn, c.annee asc; my models are users, enca, encr. thank you very much -
django does not show value form db
I have problem. My template don't show my value from db. I think that I don't have defined model UserProduct in views.py in function product. wievs.py def index(request): context = { 'products': Product.objects.order_by('category').filter(is_published=True) } return render(request, 'offers/products.html', context) def userproduct(request): context = { 'userproduct': UserProduct.objects.filter(user_id=request.user.id), } return render(request, 'offers/userproducts.html', context) def product(request, product_id): product = get_object_or_404(Product, pk=product_id) context = { 'product': product, } return render(request, 'offers/product.html', context) models.py class Product(models.Model): product_name = models.CharField(max_length=100) category = models.CharField(max_length=50) weight = models.FloatField() description = models.TextField(blank=True) photo = models.ImageField(upload_to='photos/%Y/%m/%d/') is_published = models.BooleanField(default=True) list_date = models.DateField(default=datetime.now, blank=True) def __str__(self): return self.product_name class UserProduct(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) product_name = models.ForeignKey(Product, on_delete=models.CASCADE) price = models.FloatField() is_published = models.BooleanField(default=True) list_date = models.DateField(default=datetime.now, blank=True) def __str__(self): return str(self.user.username) if self.user.username else '' offers/product.html <div class="p-4"> <p class="lead"> {% if user.is_authenticated %} <span class="mr-1"> <p>Price</p></span> <p class="colores lead font-weight-bold">{{ product.price }} £</p> {% endif %} <p >Description</p> <p class="colores lead font-weight">{{ product.description }}</p> <p class="colores lead font-weight-bold">Weight: {{ product.weight }}kg</p> </p> {% if user.is_authenticated %} <form class="d-flex justify-content-left"> <!-- Default input --> <input type="number" value="1" aria-label="Search" class="form-control" style="width: 100px"> <button class="btn send-click btn-md my-0 p" type="submit">Add to cart <i class="fas fa-shopping-cart ml-1"></i> </button> </form> {% endif %} </div> Value … -
How to dynamically add column names to django queryset
I wanted to dynamically add the model field and search value to a Django queryset. for example if I have a field_name = "book_name" and search_value= "book name" I want to dynamically add field name and search value like below data = Books.objects.filter(book_name__icontains="some book name") I tried like this. data = Books.objects.filter("{}"__icontains="{}").format("book_name", "some book name") I was getting an error saying data = Books.objects.filter("{}"__icontains="{}").format("book_name", "some book name") ^ SyntaxError: invalid syntax Can anyone please correct me? -
Import CSV file into two separate django models
I'm having trouble parsing data from one csv file into two related tables in a django model. My view.py function. for column in csv.reader(io_string, delimiter=',', quotechar="|"): _, created = User.objects.update_or_create( card_no=column[0], first_name=column[1], last_name=column[2], mobile=column[3], email=column[4], is_active=column[5] ) _, created = UserPayment.objects.get_or_create( paid_on=column[0], valid_until=column[1], payment_status=column[2] ) This is the CSV file. file image -
Setting href attribute with templatetag in AJAX in django template
I am trying to make money tracker app. There is a 'transactions' page, where user can see all of his transactions by month. By default template is rendered with current month and it looks like this: class TransactionsView(TemplateView): template_name = 'money_tracker/transactions.html' def get_context_data(self, *args, **kwargs): month, year, month_start, month_end = range_of_current_month() context = super().get_context_data(*args, **kwargs) income = sum(Transaction.objects.filter((Q(user=self.request.user) | Q(user=None)) & Q(category__expense_or_income_choices='INCOME', date__lte=month_end, date__gte=month_start)).values_list('amount', flat=True)) expense = sum(Transaction.objects.filter((Q(user=self.request.user) | Q(user=None)) & Q(category__expense_or_income_choices='EXPENSE', date__lte=month_end, date__gte=month_start)).values_list('amount', flat=True)) income_transactions = Transaction.objects.filter((Q(user=self.request.user) | Q(user=None)) & Q(category__expense_or_income_choices='INCOME', date__lte=month_end, date__gte=month_start)) expense_transactions = Transaction.objects.filter((Q(user=self.request.user) | Q(user=None)) & Q(category__expense_or_income_choices='EXPENSE', date__lte=month_end, date__gte=month_start)) context['income'] = income context['expense'] = expense context['balance'] = income - expense context['month'] = month context['year'] = year context['income_transaction'] = income_transactions context['expense_transaction'] = expense_transactions return context But then I want to use AJAX if user wants to see transactions from different month, and my template looks like this (AJAX at the bottom): {% extends 'money_tracker/base.html' %} {% block body_block %} <section class="balance section"> <div class="balance__sheet"> <h3 class="header"><span class="arrow arrow_left">&#8678</span><span class="month">{{ month }}</span> <span class="year">{{year}}</span><span class="arrow arrow_right">&#8680</span></h3> <div> <h4 class="smaller__header">Balance: {{balance}}$</h4> </div> <div class="income_expense"> Income: {{income}}$ <div class="list_of_transactions"> <ul> {% for trans in income_transaction %} <li>{{trans.amount}}$, {{trans.date}}, {{trans.category}}, <a href="{% url 'update_expense' trans.pk %}">edit,</a><a href="{% url 'delete_transaction' trans.pk %}">delete</a></li> … -
Django ModelForm returns None instead of HttpResponse
I've been following the tutorial for 'File Upload With Model Forms' here: https://simpleisbetterthancomplex.com/tutorial/2016/08/01/how-to-upload-files-with-django.html I'm pretty sure I followed it to the letter (except using my own project). However I'm getting the error The view project.views.InspectionReportForm_Create didn't return an HttpResponse object. It returned None instead. Here is my code: models.py: class Inspection(models.Model): InspectionID = models.AutoField(primary_key=True, unique=True) PartID = models.ForeignKey('Part', on_delete=models.CASCADE, null=True) @classmethod def create(cls, partid): inspection = cls(PartID = partid) return inspection class InspectionReport(models.Model): ReportID = models.AutoField(primary_key=True, unique=True) InspectionID = models.ForeignKey('Inspection', on_delete=models.CASCADE, null=True) Date = models.DateField(auto_now=False, auto_now_add=False, null=True) Comment = models.CharField(max_length=255, blank=True) FileName = models.CharField(max_length=255, blank=True) Report = models.FileField(upload_to='docs', null=True, blank=True) Signature = models.CharField(max_length=255, blank=True) @classmethod def create(cls, inspid, date, comment, rept, sig): inspreport = cls(InspectionID = inspid, Date = date, Comment = comment, Report = rept, Signature = sig) return inspreport forms.py: class InspectionReportForm(forms.ModelForm): class Meta: model = InspectionReport fields = ('InspectionID', 'Date', 'Comment', 'Report', 'Signature') views.py: def InspectionReportForm_Create(request): if request.method == 'POST': form = InspectionReportForm(request.POST, request.FILES) if form.is_valid(): form.save() return redirect('sites/1') else: form = InspectionReportForm() return render(request, 'moorings/uploadReport.html', {'form': form }) uploadReport.html (just the form. everything else is styling and titles etc): <div id="wrapper" class="dark"> <div id="loginwrapper" class="dark"> <form method="post" enctype="multipart/form-data"> {% csrf_token %} {{ form.as_p }} <button type="submit">Create</button> … -
'user_form', expected 'endif'. Did you forget to register or load this tag?
Please go through the link to view my code -
TypeError: DisplayMarketingMessage() takes no arguments how to fix it
how to fix it TypeError: DisplayMarketing() takes no arguments -
How to perform exception handling (try-catch) inside Django template tag?
For a django requirement, i need to add exception handling inside the django template using django template tags. try: mem = e.memberOf except LDAPCursorError: mem = "" This is the requirement. I need to do this using Django template tag. -
trying to show the full blog on a new html page after clicking on read more button in the blog card in django
I am working on a blogging website in django. I have a few blogs and I am loading them in the card from my database.My card has a read more button(To go to new HTML page and dynamically fetch the contents of the particular blog). Instead of creating a new html page for every blog I am using a single html page to show the contents of the blog from the read more button clicked on card. but I am getting the following error: Reverse for 'post_detail' with arguments '('',)' not found. 1 pattern(s) tried: ['(?P[-a-zA-Z0-9_]+)\/$'] Request Method: GET Request URL: http://127.0.0.1:8000/blogs/ Django Version: 2.2.6 Exception Type: NoReverseMatch Exception Value: Exception Location: C:\django\lib\site-packages\django\urls\resolvers.py in_reverse_with_prefix, line 673** Thanks alot in advance models.py class blog(models.Model): STATUS_CHOICES=( ("scholarship","Scholarship"), ("examination","Examination"), ("career","Career"), ("fellowship","Fellowship") ) blog_image=models.ImageField(upload_to='blog_media',default="") blog_title=models.CharField(max_length=300) slug = models.SlugField( max_length=200, unique=True) blog_type = models.CharField( max_length=50, choices=STATUS_CHOICES, default="scholarship" ) blog_author_name=models.CharField(max_length=200) blog_content=models.CharField(max_length=5000) publish_date=models.DateField() urls.py: urlpatterns = [ path('',views.index,name='home'), path('blogs/',views.blogs,name='blogs'), path('about/',views.about,name='about'), path('admissions/',views.admissions,name='admissions'), path( '<slug:slug>/', views.PostDetail.as_view(), name='post_detail' ),] views.py class PostDetail(DetailView): #my model name is blog model = blog #this is the html page on which I want to show the single blog data template_name = 'buddyscholarship_html/post_detail.html' code for loading the dynamic data from django in html in a … -
How To Fix QueryDict object is not callable in Django?
When i add the recaptcha in my site i'm getting this error please help me! This is error i'm getting again and again I Want to Fix My This Issue: TypeError at /accounts/register 'QueryDict' object is not callable Request Method: POST Request URL: http://127.0.0.1:8000/accounts/register Django Version: 2.2 Exception Type: TypeError Exception Value: 'QueryDict' object is not callable Exception Location: D:\Learning\Work\Djngo\todo_app\todo\views.py in signup, line 24 Python Executable: C:\Users\Lenovo\AppData\Local\Programs\Python\Python37-32\python.exe Python Version: 3.7.0 Python Path: ['D:\\Learning\\Work\\Djngo\\todo_app', 'C:\\Users\\Lenovo\\AppData\\Local\\Programs\\Python\\Python37-32\\python37.zip', 'C:\\Users\\Lenovo\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs', 'C:\\Users\\Lenovo\\AppData\\Local\\Programs\\Python\\Python37-32\\lib', 'C:\\Users\\Lenovo\\AppData\\Local\\Programs\\Python\\Python37-32', 'C:\\Users\\Lenovo\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages'] Server time: Tue, 3 Dec 2019 08:58:29 +0000 But I Can't Here is my views.py def signup(requests): ############################### if requests.method == 'POST': reg = register(requests.POST) ############ clientKey = requests.POST['g-recaptcha-response'] secretKey = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' captchaData = { 'secret': secretKey, 'response': clientKey } r = requests.post('https://www.google.com/recaptcha/api/siteverify', data=captchaData) response = json.loads(r.text) verify = response['success'] print('Result: ' + verify) if reg.is_valid(): user = reg.save(commit=False) user.set_password(User) user.save() messages.success(request, 'You Are SuccessFully Registerd!') else: print(reg.errors) else: reg = register() return render(requests,'signup.html',{'reg':reg,}) Any Help Will Be Appreciated! Thanks! -
Best Django 2 tutorial series on youtube in english
I am looking for the best Django 2.0+ tutorial series on youtube. Help me with your thoughts. Thanks, in advance -
When i tried to run auth login api getting error : The current path, api/auth/login/, didn't match any of these
When i tried to run api http://127.0.0.1:8000/api/auth/login/, It gives me this error : Using the URLconf defined in djangoproject.urls, Django tried these URL patterns, in this order: admin/ api/(?P<version>(v1|v2))/ ^ ^users/$ [name='user-list'] ^ ^users\.(?P<format>[a-z0-9]+)/?$ [name='user-list'] ^ ^users/(?P<pk>[^/.]+)/$ [name='user-detail'] ^ ^users/(?P<pk>[^/.]+)\.(?P<format>[a-z0-9]+)/?$ [name='user-detail'] ^ ^$ [name='api-root'] ^ ^\.(?P<format>[a-z0-9]+)/?$ [name='api-root'] ^auth/ The current path, api/auth/login/, didn't match any of these. Can anyone please check my urls.py and help me why i am getting this error ? urls.py from django.contrib import admin from django.urls import path, re_path,include from rest_framework import routers from django.conf.urls import url, include from trialrisk.views import UserViewSet router = routers.DefaultRouter() router.register(r'users', UserViewSet) urlpatterns = [ path('admin/', admin.site.urls), re_path('api/(?P<version>(v1|v2))/', include('trialrisk.urls')), url(r'^', include(router.urls)), url('^auth/', include('rest_auth.urls')), ] -
Why won't my UserCreationForm render in chronological order?
I want the form to show Username Email Password Password(2) At the moment, it is showing Username Password Password (2) Email I am trying to follow this tutorial https://www.youtube.com/watch?v=q4jPR-M0TAQ. I have looked at the creators notes on Github but that has not helped. I have double checked my code and cannot see any daft typos. Can anyone provide any insight? from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm class UserRegisterForm(UserCreationForm): email = forms.EmailField() class Meta: model = User fields = ['username', 'email', 'password1', 'password2'] from django.shortcuts import render, redirect from django.contrib import messages from .forms import UserRegisterForm def register(request): if request.method == 'POST': form = UserRegisterForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') messages.success(request, f'Account created for {username}!') return redirect ('blog-home') else: form = UserRegisterForm() return render(request, 'users/register.html', {'form':form}) -
Mongodb with django?
If I use mongodb in django project with the help of djongo third-party api should I have to use commands migrate and makemigrations again n again when ever I make changes in my models?? -
Need WhatsApp chat Compatibility confirmation with ReactJS & Django
I am developing an ecommerce Web App using React & Python Django. I need to know whether GupShup API would be compatible with the above Technology Stack. -
Django Blogg App using Heroku: SyntaxError at / invalid syntax (parser.py, line 158)
I am a beginner programmer and I followed a django blog tutorial to deploy an app to Heroku. I have been stuck on the problem for quite a while now. This did not pop up on my localhost but after I deployed this app to heroku, now there is a syntax error. Can anyone help me? Environment:[enter image description here][1] Request Method: GET Request URL: https://mynewdjangoblogapp.herokuapp.com/ Django Version: 2.2.7 Python Version: 3.6.9 Installed Applications: ['blog.apps.BlogConfig', 'users.apps.UsersConfig', 'crispy_forms', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'storages'] Installed Middleware: ('whitenoise.middleware.WhiteNoiseMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware') Template error: In template /app/blog/templates/blog/base.html, error at line 0 invalid syntax 1 : {% load static %} 2 : 3 : 4 : 5 : 6 : 7 : 8 : 9 : 10 : Traceback: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" in _resolve_lookup 829. current = current[bit] During handling of the above exception ('ImageFieldFile' object is not subscriptable), another exception occurred: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner 34. response = get_response(request) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response 145. response = self.process_exception_by_middleware(e, request) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response 143. response = response.render() File "/app/.heroku/python/lib/python3.6/site-packages/django/template/response.py" in render 106. self.content = self.rendered_content File "/app/.heroku/python/lib/python3.6/site-packages/django/template/response.py" in rendered_content 83. content = template.render(context, self._request) File "/app/.heroku/python/lib/python3.6/site-packages/django/template/backends/django.py" in render 61. return … -
Django QuerySet filter get queryset by id and other column(s)
I am trying to get my user instance as well as my team members' user instances in the same query. Unfortunately, I am getting an empty query set. I am trying this : users = User.objects.filter(invited_by=request.user.id, id = request.user.id) -
rendering forms for django PolymorphicModel
Hello I am asking this coz av been stack for over 2 weeks now trying to figure out how to do it right, I hope I get help. I have a Django model that I implemented PolymorphicModel my issue is I made the forms and the forms work fine when posting the first product but posting the second product, The first product is asking for a form model to render it yet am not trying to edit it. maybe my code will explain what am tring to say my main model class Product(PolymorphicModel): product_name = models.CharField(max_length=100) product_features = models.TextField(max_length=500, blank=True, null=True) product_type = models.ForeignKey(ProductType, on_delete=models.CASCADE, null=True) post_date = models.DateTimeField() first child class PhoneTablets(Product): screen_size = models.DecimalField( "Screen size", max_digits=4, decimal_places=2, ) battery_type = models.CharField( "Battery type", max_length=200 ) battery_capacity = models.PositiveIntegerField(null=True, help_text="Battery capacity in mAh", ) second child class LaptopComputers(Product): size = models.PositiveIntegerField(null=True) weight = models.PositiveIntegerField(null=True, ) battery_type = models.PositiveSmallIntegerField(null=True, ) refurbished = models.BooleanField() my forms look like this PhonesTabsForm = polymorphic_modelformset_factory(Product, fields=product_fields, formset_children=( PolymorphicFormSetChild(PhoneTablets, fields=product_fields + ['screen_size', 'battery_type', 'battery_capacity', 'ram_storage', 'internal_storage']), )) LaptopsCompsForm = polymorphic_modelformset_factory(Product, fields=product_fields, formset_children=( PolymorphicFormSetChild(LaptopComputers, fields=product_fields + ['size', 'weight', 'battery_type', 'refurbished', 'operating_system', 'processor', 'processor_speed', 'battery_capacity', 'ram_storage', 'internal_storage'], ), )) my view is a conditional view class … -
Atom `script` add-on doesn't recognize Django Model/settings when running a script
It seems I run into some dependencies issues when trying to run a python script within my Django based web application using the atom add-on script. I would like to run the following script using the Atom script add-on: feeder.py: import zmq import time from time import sleep import uuid from models import AccountInformation context = zmq.Context() zmq_socket = context.socket(zmq.PULL) zmq_socket.bind("tcp://*:32225") time.sleep(1) while True: try: msg = zmq_socket.recv_string() data = msg.split("|") print(data) if (data[0] == "account_info"): version = data[1] DID = uuid.UUID(data[2]) accountNumber = int(data[3]) broker = data[4] leverage = data[5] account_balance = float(data[6]) account_profit = float(data[7]) account_equity = float(data[8]) account_margin = float(data[9]) account_margin_free = float(data[10]) account_margin_level = float(data[11]) account_currency = data[12] feed = AccountInformation( version=version, DID=DID, accountNumber=accountNumber, broker=broker, leverage=leverage, account_balance=account_balance, account_pofit=account_profit, account_equity=account_equity, account_margin=account_margin, account_margin_free=account_margin_free, account_margin_level=account_margin_level, account_currency=account_currency ) feed.save() # Push data to account information table else: print("no data") except zmq.error.Again: print("\nResource timeout.. please try again.") sleep(0.000001) Unfortunately it raises the following error: Traceback (most recent call last): File "C:\Users\Jonas Blickle\Desktop\dashex\Dashboard_app\feeder.py", line 5, in <module> from models import AccountInformation File "C:\Users\Jonas Blickle\Desktop\dashex\Dashboard_app\models.py", line 7, in <module> class AccountInformation(models.Model): File "C:\Program Files\lib\site-packages\django\db\models\base.py", line 103, in __new__ app_config = apps.get_containing_app_config(module) File "C:\Program Files\lib\site-packages\django\apps\registry.py", line 252, in get_containing_app_config self.check_apps_ready() File "C:\Program Files\lib\site-packages\django\apps\registry.py", line … -
Compare two different classes based on their values
i'm trying to compare two variables based on their actual values but it's just not working and i thing it's because they are from different classes here's an example : models = Model_info.objects.all() m = 'X-POWER 3' for model in models: if m == model: check = 'accepted' print(check) break else: check = 'rejected' print(check) print(f'final resulte is {check}') knowing that the value of variable "m" do exist in the queryset "models" and : type(m) = < class 'str' > type(model) = < class 'application.models.Model_info' > So is their any method to compare the value of two variables no matter what class they belong to.