Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Using Django Templates to get data from the database in Javascript
So I am using AJAX to get a response on a form data submitted. I initially used to do it using an HTTP request but then due to other reasons, I shifted to using AJAX where I am thrown with several errors. So firstly from my views.py, I send a JsonResponse back to JS. data = list(Trips.objects.all().values()) return JsonResponse({"noOfTrips":len(data), "trip":data}) And now previously my template.html looks like this... <a class="text-decoration-none text-dark ModalSelector" id="linkTripModalBtn" data-bs-target="#linkTripModal"> <div class="passengerTripListCont font3 p-2 mt-2"> <div class="row1 d-flex align-items-center container-fluid px-0"> <img class="rounded-circle mx-2" width="50" height="50" src="{{trip.user.profiledriver.your_picture.url}}" alt="profPic"> <div> <p class="mb-0"><strong class="driverName">{{trip.user.first_name}} {{trip.user.last_name}}</strong> (#<span class="driverID">{{trip.user.id}}</span>)</p> <small class="text-muted"><span class="driverVehicle">{{trip.vehicle_used.model}}</span> <strong>{{trip.vehicle_used.vehicle_number}}</strong></small><br> <small>Trip refernece: #<strong class="tripID">{{trip.id}}</strong></small> </div> </div> <div class="row2 mt-2 border-top border-dark pt-1"> <p class="text-center mb-1 travelPoints d-flex align-items-center"> <span class="tripDeparture">{{trip.departure}}</span> <svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" fill="currentColor" class="bi bi-arrow-right-circle mx-1" viewBox="0 0 16 16"> <path fill-rule="evenodd" d="M1 8a7 7 0 1 0 14 0A7 7 0 0 0 1 8zm15 0A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM4.5 7.5a.5.5 0 0 0 0 1h5.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3a.5.5 0 0 0 0-.708l-3-3a.5.5 0 1 0-.708.708L10.293 7.5H4.5z"/> </svg> <span class="tripArrival">{{trip.arrival}}</span> </p> </div> <div class="row3"> {% if tripsUserData.period == None %} <h6 class="text-center">Travelling <strong class="tripDate">{{trip.date}}</strong> … -
Can you get the django form id from django template using id_fieldname?
I am using a model form that has 3 fields - name, country and city. My template looks like this- <form method="post" id="personForm" data-cities-url="{% url 'ajax_load_cities' %}"> {% csrf_token %} {{form}} <input type="submit" value="Submit"> </form> Following this is a bit more jQuery code that fetches the id for the "country" field using a code like this - $("#id_country").change(function ().... Two things I need to mention here, no where in my code I have id_country except from this jQuery code. Also I haven't set the id attribute for the country field anywhere. So my question is , is this a thing in django or in jQuery where you can get the id for a field using id_ in front of the field name? I read the django documentation, haven't seen anything like this. What am I missing here? Thanks for any input. -
Como puedo descargar una imagen con URL blob en Django?
Tengo una url tipo blob:http://localhost:4200/1d2d99a2-cdb4-4784-bbc6-1047acc0be57 y quisiera poder descargarla, pero simplemente no funciona, ya probé varios métodos def responder(request): body_unicode = request.body.decode('utf-8') body = json.loads(body_unicode) content = body['imagen'] url=content[0]['webviewPath'] #url blob -
Solve python ValueError: max_workers must be <= 61 when running pre-commit?
I am using Django to develop an ERP and I want to use pre-commit with my project. I have installed pre-commit, black, flake8, flake8-black. and this is my .pre-commit-config.yaml file configurations content repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v2.3.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/psf/black rev: 19.3b0 hooks: - id: black language_version: python3.7 When I commit my code it gives me this error Check Yaml...............................................................Passed Fix End of Files.........................................................Failed - hook id: end-of-file-fixer - exit code: 1 - files were modified by this hook Fixing vms/movement/test/test_model.py Fixing vms/payment/test/test_forms.py Trim Trailing Whitespace.................................................Passed black....................................................................Failed - hook id: black - exit code: 1 Traceback (most recent call last): File "C:\Program Files\Python37\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "C:\Program Files\Python37\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\Diaa\.cache\pre-commit\repo4t4vqwkg\py_env-python3\Scripts\black.EXE\__main__.py", line 7, in <module> File "c:\users\diaa\.cache\pre-commit\repo4t4vqwkg\py_env-python3\lib\site-packages\black.py", line 3754, in patched_main main() File "c:\users\diaa\.cache\pre-commit\repo4t4vqwkg\py_env-python3\lib\site-packages\click\core.py", line 1137, in __call__ return self.main(*args, **kwargs) File "c:\users\diaa\.cache\pre-commit\repo4t4vqwkg\py_env-python3\lib\site-packages\click\core.py", line 1062, in main rv = self.invoke(ctx) File "c:\users\diaa\.cache\pre-commit\repo4t4vqwkg\py_env-python3\lib\site-packages\click\core.py", line 1404, in invoke return ctx.invoke(self.callback, **ctx.params) File "c:\users\diaa\.cache\pre-commit\repo4t4vqwkg\py_env-python3\lib\site-packages\click\core.py", line 763, in invoke return __callback(*args, **kwargs) File "c:\users\diaa\.cache\pre-commit\repo4t4vqwkg\py_env-python3\lib\site-packages\click\decorators.py", line 26, in new_func return f(get_current_context(), *args, **kwargs) File "c:\users\diaa\.cache\pre-commit\repo4t4vqwkg\py_env-python3\lib\site-packages\black.py", line 435, in main executor = ProcessPoolExecutor(max_workers=os.cpu_count()) File "C:\Program Files\Python37\lib\concurrent\futures\process.py", … -
How to make offline wallet and add money for joining the tournaments in django
my project is based on User Join to the paid Tournaments. after User signup they want to join the Tournament. So I add offline payment function. But it doesn't work Properly. WHAT I NEED: if I adding money using add balance function, When user add balance it stored directly, for example: I have 20rupees in my wallet, so I need to add money for join the tournament. So I add 100 rupees in my wallet, finally in 120rupees my wallet right. But my wallet shows only 100rupees. I mean add balance input directly stored to balance without adding instance. I need instance money + add balance in my wallet.. default balance wallet image Adding 100rupees more image It show 100rupees instead of 120rupess Models.py class Profile(models.Model): user = models.OneToOneField(User,null=True, on_delete=models.CASCADE) pubg_id = models.PositiveIntegerField(null=True,blank=True) pubg_name = models.CharField(max_length=15,null=True,blank=True) phone_no = models.PositiveIntegerField(null=True,blank=True) balance = models.PositiveSmallIntegerField(default="0",verbose_name= _('Enter Amount')) def __str__(self): return str(self.user) def create_user_profile(sender,instance,created,**kwargs): if created: Profile.objects.create(user=instance) post_save.connect(create_user_profile,sender=User) Views.py class AddBalanceView(SuccessMessageMixin,UpdateView): template_name = 'bgmiapp/add_balance.html' fields=('balance',) success_message = "Balance added Successfully" success_url= reverse_lazy('home') def get_object(self): return self.request.user.profile templates {% extends 'bgmiapp/base.html' %} {% load static %} {% block title %} Add_Balance {% endblock %} {% block content %} <h3>Add Balance</h3> <form method="POST"> {% csrf_token %} … -
Generic view for different models in django
To summarize the project, I am working on a website that categorizes electronic devices. Each electronic device has a category (Phone, Tablet, Computer, etc...), a manufacturer (Apple, Samsung, Dell, etc...) and the device itself (iPhone 6, iPhone X, Samsung S21, etc...). I have a single template for the 3 different models (Category, Manufacture, Device) and I am looking to simplify the views which are currently just a copy and paste. Here is the current code: @login_required(login_url="/login/") def show_category(request): groups = Category.objects.all() return render(request, "groups/group.html", {'group': 'Category', 'groups': groups}) @login_required(login_url="/login/") def show_manufacturer(request): groups = Manufacturer.objects.all() return render(request, "groups/group.html", {'group': 'Manufacturer', 'groups': groups}) @login_required(login_url="/login/") def show_device(request): groups = Device.objects.all() return render(request, "groups/group.html", {'group': 'Device', 'groups': groups}) Additionally, I have some POST functions which are also copy pastes of the same function for the different models to the same template. I have been able to find examples where multiple models are used at the same time for one template, but I cannot for the life of me seem to find an example of using different models for the same template. Can someone link me to an example or the docs that explains how to accomplish this ? I feel like I have missed … -
I am trying to register users in django but the form fields are not showing up. What is wrong with my code?
this is my forms.py: from django.forms import ModelForm, fields from django.contrib.auth.forms import UserCreationForm from django import forms from django.contrib.auth.models import User class CreateUserForm(UserCreationForm): class Meta: model = User fields = ['username', 'email', 'password1', 'password2'] This is my views.py: from django.shortcuts import render from django.contrib.auth.forms import UserCreationForm from .forms import CreateUserForm def RegisterPage(request): form = CreateUserForm() if request.method == 'POST': form = CreateUserForm(request.POST) if form.is_valid(): form.save() context = {'form':form} return render(request, 'register.html', context) this is my html template: <div class="col-lg-4 login-bg"> <h4 class="reg-title"><strong>Get Started...</strong></h4> <p class="login-reg">Already have an account? <a class="log-reg-link" href="login.html">Log In </a> here</p> <hr> <form class="" action="/Dashboard/" method="post"> {% csrf_token %} <p class="reg-field-title"><strong>Username*</strong></p> <div>{{form.username}}</div> <p class="reg-field-title"><strong>Email ID*</strong></p> <div>{{form.email}}</div> <p class="reg-field-title"><strong>Password*</strong></p> <div>{{form.password1}}</div> <p class="reg-field-title"><strong>Password Confirmation*</strong></p> <div>{{form.password2}}</div> <button type="submit" class="btn btn-dark btn-lg col-lg-10 reg-btn">Register</button> </form> What am I doing wrong because the form fields are not showing up on the page? I followed a youtube tutorial and went step by step but I don't understand the problem now. -
TypeError at /review/1 __init__() got an unexpected keyword argument 'id'. I am creating a online book buying and selling project
I have added int:id as primary key to the views url of 'review'and also passed it to views of 'review', but it is still showing the error. project/urls.py ''' from django.contrib import admin from django.urls import path,include from home import views urlpatterns = [ path('', views.home, name='home'), path('signup/', views.signup_view, name='signup_view'), path('login/', views.login_view, name='login_view'), path('logout/', views.logoutUser, name='logout'), path('add_product/', views.addproduct, name='add_product'), path('contact/', views.contactus, name='contactus'), path('prod_detail/<int:id>',views.prod_detail,name='prod_detail'), path('review/<int:id>',views.review,name='review'), ]''' ///views.py This is the project/views.py of my project ''' def review(request,id): rform=ReviewForm(id=id) if request.user.is_authenticated: #prod = request.user if request.method == "POST": form = ReviewForm(request.POST) if form.is_valid: user = form.save(commit=False) user.posted_by = request.user user.save() return render(request,'review.html',{'rform': rform}) else: return render(request,'/login.html') ''' ///review.html ''' <div class="card card-outline-secondary my-4"> <div class="card-header"> Product Reviews </div> <div class="card-body"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis et enim aperiam inventore, similique necessitatibus neque non! Doloribus, modi sapiente laboriosam aperiam fugiat laborum. Sequi mollitia, necessitatibus quae sint natus.</p> <small class="text-muted">Posted by Anonymous on 3/1/17</small> <hr> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis et enim aperiam inventore, similique necessitatibus neque non! Doloribus, modi sapiente laboriosam aperiam fugiat laborum. Sequi mollitia, necessitatibus quae sint natus.</p> <small class="text-muted">Posted by Anonymous on 3/1/17</small> <hr> <a href="{% url 'review' rev.id %}" class="btn btn-success">Leave … -
How to write CSS inline with django variable?
I created a progress bar with bootstrap. Which is where there is a style attribute to set the progress width. I linked the progress to the models to retrieve the value. As follows. {% for k in kelas %} <div class="col-sm-6"> <div class="progres"> <div class="kelas mb-2">{{ k.namaKelas }}</div> <div class="progress"> <div class="progress-bar" role="progressbar" style='width:{{k.get_percent}}%' aria-valuenow="{{ k.get_percent }}" aria-valuemin="0" aria-valuemax="100">{{ k.get_percent }}%</div> </div> </div> </div> {% endfor %} But at this point style='width:{{k.get_percent}}%' no response on progress width. And in html file it show red color because there is a code that is considered wrong. How can i get a variable to include django in that style? -
django get() got an unexpected keyword argument 'pk'
Using Django version 3.2.4 I'm following the django documentation https://www.django-rest-framework.org/tutorial/3-class-based-views/ rest > urls.py from django.urls import path from rest import views from rest_framework.urlpatterns import format_suffix_patterns urlpatterns = [ path('', views.SnippetList.as_view()), path('<int:pk>/', views.SnippetList.as_view()), ] urlpatterns = format_suffix_patterns(urlpatterns) rest > views.py class SnippetDetail(APIView): """ Retrieve, update or delete a snippet instance. """ def get_object(self, pk): try: return Snippet.objects.get(pk=pk) except Snippet.DoesNotExist: raise Http404 def get(self, request, pk, format=None): snippet = self.get_object(pk) serializer = SnippetSerializer(snippet) return Response(serializer.data) def put(self, request, pk, format=None): snippet = self.get_object(pk) serializer = SnippetSerializer(snippet, data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) def delete(self, request, pk, format=None): snippet = self.get_object(pk) snippet.delete() return Response(status=status.HTTP_204_NO_CONTENT) On request url http://127.0.0.1:8000/snippets/1/, I get this error: TypeError at /snippets/1/ get() got an unexpected keyword argument 'pk Am I missing something here? -
Django what to do when 2 people simultaneously purchase
I was wondering if anyone know what to do when I have a physical product and 2 people simultaneously purchase at the same time with the stock of 1? How do I make sure that even if they have the product in their cart they can't keep going forward with the payment process if the other person payed before them. Also if they haven't started the payment process and they just logged back into the website and they checked their cart(if they had the product in their cart already) I want it where they inform the users why they deleted the product from their cart. Something like this Ex:"Due to the product being out of stock we placed it in your wishlist...". Don't have a wishlist so just saying we deleted it from your cart. If anyone can help me with this I would be grateful because everytime I look this up I can't find any info about it. Only about other stuff and I'm thinking Im the only one going through this. Can someone explain what to do like really how to do it. This is my github if anyone just wants to help on their and check my … -
what is this Keep the license and copyright notice included in Bootstrap’s CSS and JavaScript files when you use them in your works?
I have developed a website using django and I have used getbootstrap4.3 in my website. In the offcial website ,they have stated like this: It requires you to: Keep the license and copyright notice included in Bootstrap’s CSS and JavaScript files when you use them in your works I really dont uderstand this,what is copyright notice and where i should include ??????? -
I have imported app1's models into app2's views.py and trying to create a new row to insert like this but its not showing any new rows in db..why?
import datetime curr_datetime=datetime.datetime.now() from subcriptions.models import childtransactions obj1=childtransactions.objects.filter(outlet_id=outlet_id).last() obj2=childtransactions(transaction_no=obj1.transaction_no,plan_subcription=obj1.plan_subcription, plan_deduction_type=obj1.plan_deduction_type,payment_status=obj1.payment_status,payment_date=curr_datetime,original_balance_amount=obj1.original_balance_amount,debit_amount=5, balance_amount=float(obj1.balance_amount)-float(obj1.debit_amount), credit_amount=obj1.credit_amount,outlet_id=outlet_id,kit_id=obj1.kit_id,remarks=obj1.remarks, is_paid=obj1.is_paid,customer_reach=obj1.customer_reach,own_transactions=obj1.own_transactions, topup=obj1.topup) obj2.save() whats wrong?? and how do i solve it? -
Trying to load multiple Cloudinary images in Django template
There is slightly complex logic in displaying images and I need to display another image if one does not exist. However, it's slow to put it on the backend because the object is currently a dictionary. Is there a way that I can find workable images with the HTML image tag? <picture> <source srcset="https://res.cloudinary.com/.../{{ object.id }}.png" > <source scrset="https://res.cloudinary.com/.../{{ object.system }}.png"> <source scrset="https://res.cloudinary.com/picture.svg"> <img src="https://res.cloudinary.com/.../{{ object.id }}.png" class="mx-auto" width="250px" alt="" /> </picture> The problem is that only the default image shows up and the other source images do not. Is there another way that I could display another image if one fails? -
Put items on top in django template for loop
The model has a field named "is_highlighted", i want to put all items on top if is_highlighted == True when iterate thru the object list. -
How to make Django Webpage run real-time data from Firebase?
I'm having problem on making real-time data temperature data on DJANGO website, I am able to retrieve the data from Firebase by using Raspberry Pi + MLX90614 IR sensor to push temperature data to Firebase and display on DJANGO webpage. website showed my mlx90614 sensor temperature data But I'm unable to make it real-time, the temperature data only updated when I refreshed the browser, I want to make it in real-time which I use the If-else statement in views, where the strings can updated instantly but not manually refreshing the browser. In below is my code VIEWS & TEMPLATES (HTML): Sample Code Sample Code2 I'm making a E-health website for my Final Year Project with DJANGO & Raspberry Pi. Please give me some advice to me, Thank you! (>_<) -
Django nested model rest frame wrok
Models.py class Persion (models.Model): name = models.TextField(max_length=300) age = models.IntegerField() class Address(models.Model): city = models.TextField(max_length=300) state = models.TextField(max_length=300) Serializer.py: class AddressSerializer(serializers.ModelSerializer) : class Meta: model = Address fields ='__all__' class PersionSerializer(serializers.ModelSerializer): address = AddressSerializer( required= True) class Meta: model = Persion fields = ['name', 'age' , 'address'] Error Message: Got AttributeError when attempting to get a value for field address on serializer PersionSerializer. The serializer field might be named incorrectly and not match any attribute or key on the Persion instance. Original exception text was: 'Persion' object has no attribute 'address'. What am i missing? I need output like this [ { name:"nikhil", age: 24, address:{ city:"coimbatore", } }] -
Django form validation ran before calling to_python
Background: I have a model with a CharField that should be limited to let's say 100 characters. I render it with Textarea, which allows for newlines as expected. However, different browsers handle the maxlength attribute and newline character differently, sometimes posting them as \r\n (2 characters) but counting as only 1 character when entered. To deal with this, I want my server to strip \r from the field before validating to standardized across different browsers and for a better user experience, i.e. allow users to enter the full 100 characters, counting newlines as only 1 character. After reading Django documentation on Form and field validation and various stackoverflow posts, it seems pretty clear that Field.to_python(self, value) on the model is run before ANY form validations. Thus, it would be the best place for me to do this and keep my code DRY. However, it seems like there are some other validation running that I wasn't able to track down, before the call to to_python. Since if I pass exactly 100 characters in the browser (when newline is still counted as \r\n), I still get the error Ensure this value has at most 100 characters (it has 109). To test out … -
Redirect to login view when logout button is clicked in different app
There are two apps in my Django project: account and boards. In account, I have login and logout views as following: #account/views.py from django.shortcuts import render, redirect from django.contrib.auth import authenticate, login, logout from .forms import LoginForm def user_login(request): login_msg = "" if request.method == 'POST': login_form = LoginForm(request.POST) if login_form.is_valid(): cleaned_data = login_form.cleaned_data user = authenticate(request, username=cleaned_data['username'], password=cleaned_data['password']) if user is not None: if user.is_active: login(request, user) return redirect('boards:home_board') else: login_form = LoginForm() return render(request, 'account/login.html', {'login_form': login_form, 'login_msg': login_msg}) def user_logout(request): logout(request) return redirect('login') #account/urls.py from django.urls import path from . import views app_name = 'account' urlpatterns = [ path('login/', views.user_login, name='login'), ] There is only a login template, no logout template. The intention is to redirect back to the login template when logout event happens. In the other app boards, in the template home_board, there is a Logout button as following: home_board.html <div id="nav-bar">&nbsp; <button id="logout-button" class="nav-bar-button">Logout</button> </div> How do I call the view function account/logout when this button is clicked, either through Javascript or inline onclick? There is no url to pass to an onclick here. Note that if I do this: <button id="logout-button" class="nav-bar-button" onclick="location.href='{% url 'account:login' %}'"> Logout </button> It will redirect to the … -
Error when returning multiple return statements in a Django view, 'tuple' object has no attribute 'get.'| cs50 web project 4 (network)
I am working on CS50 Network and am supposed to design a Twitter-like social network website for making posts and following users. In my view's return statement I am trying to render a page and a jsonrespone. The JsonResponse is so javascript can access it. The error I get is: 'tuple' object has no attribute 'get.' view (this shows a page of all the posts specific to a user. When a logged in user clicks on the username of a post it passes values. This is how the parameters in the view gets its values.): def profile(request, user_id, username): # list number of followers and following profiles = Profile.objects.all() # get all posts and order them posts = Post.objects.filter(user=user_id).order_by('-timestamp') # pagination pagination = Paginator(posts, 10) page_num = request.GET.get('page') try: pages = pagination.page(page_num) except EmptyPage and PageNotAnInteger: pages = pagination.page(1) # serialize json_posts = serializers.get_serializer("json")().serialize(posts) return render(request, "network/profile.html", { "posts": pages, "user_id": user_id, "username": username, "profiles": profiles, "currentUser": request.user, }), JsonResponse(json_posts, safe=False) models: from django.contrib.auth.models import AbstractUser from django.db import models from django.utils import timezone class User(AbstractUser): pass class Profile(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="Followers_user") followers = models.ManyToManyField(User, blank=True, null=True, related_name="Followers_followers") following = models.ManyToManyField(User, blank=True, null=True, related_name="Followers_following") def __str__(self): return str(self.user) … -
Navigating Django Apps with home page buttons and page buttons
Quick question and I don't know why this isn't easier to find but how do I switch between the home page index to another app's index page. My current setup: kkquit/index.html - homepage pack/index.html - page I want to link What is the proper way to label a button to go from my index home page to another apps index page? -
AWS EC2 ubuntu python pypi server not getting ConnectTimeoutError
I have a ec2 instance of ubuntu and i am running a dockerized django application. every setup is okey but i see pypi server not getting. Can anyone please tell me what is the possible solution to fix it? I don't have any issue with docker. Also i tried to run pip3 install django outside out docker, yet it's not working. Can anyone please tell me what is the possible solution for this? -
Django project with Javascript function doing nothing
I'm trying to create some Javascript functions to manipulate an HTML page within a Django project, but literally nothing is happening when I create my functions and I can't understand why. I have the feeling it's something extremely basic that I'm missing - I'm brand new to working with Javascript within a Django project. The code below mostly provided by the instructor for a course I'm in and it all works just fine. But when I try to add to the javascript file, I can't get it to do anything. Specifically I'm just trying to create a button that will run a function (compose_email). The function in question has been created for me by the course instructor, and works just fine when the "compose" button is clicked. When I try creating a "test" button to call the compose_email function, literally nothing happens when I click the button. Any tips on what I'm missing here? Again, I feel like it's probably something simple I'm overlooking. Here is the button I added to the HTML file: '<button class="btn btn-sm btn-outline-primary" id="test">TEST</button>' Here is the full HTML file: ''' {% extends "mail/layout.html" %} {% load static %} {% block body %} <h2>{{ request.user.email … -
django-ajax-selects - How to keep the selected option
I was able to successfully deploy django-ajax-selects. When I search for a value on my form I'm able to find it and "lock" that value on the below "display deck" (that's how it's called in the documentation), save everything as expected when I submit the form, however as you can see the text field goes empty. Therefore, the fact that the value I selected disappears from the actual text field is quite confusing to the average person, so I'd like guidance on how I could keep the selected value in both, the "display deck" and the actual text field. I would also like to delete the selected value from both places after clicking on the trash icon (if i needed to). This is how it currently looks when I have selected a value from the dropdown and it's ready to be submitted. Can anyone please provide guidance on how to do that please? My guess is that a customization needs to happen in the Customizing Template documentation. Here's my fairly standard forms.py class StartConversationForm(forms.ModelForm): class Meta: model = Conversation fields = ('circle','conversation', 'detail','conversation_type') circle = AutoCompleteSelectField('circles', required=True, help_text=None) Thanks so much in advance -
'opts = self.remote_field.model._meta' 'AttributeError: 'str' object has no attribute '_meta''
I am somewhat new to django, and I'm trying to build an airbnb clone to better understand django. I keep receiving an error when I attempt to start my server. I'm confused on how to resolve the error. It traces back to my virtual environment file, but I have never wrote any code directly into it. I have found that if I delete the contents of my admin.py file and my models.py file, it silences the error, and my server starts. I assume this suggests the error could be coming from one of those files. Here is the error code: Exception in thread django-main-thread: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 954, in _bootstrap_inner self.run() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 892, in run self._target(*self._args, **self._kwargs) File "/Users/AUTH_SYSTEM/backend/venv/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "/Users/AUTH_SYSTEM/backend/venv/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run self.check(display_num_errors=True) File "/Users/AUTH_SYSTEM/backend/venv/lib/python3.9/site-packages/django/core/management/base.py", line 419, in check all_issues = checks.run_checks( File "/Users/AUTH_SYSTEM/backend/venv/lib/python3.9/site-packages/django/core/checks/registry.py", line 76, in run_checks new_errors = check(app_configs=app_configs, databases=databases) File "/Users/AUTH_SYSTEM/backend/venv/lib/python3.9/site-packages/django/contrib/admin/checks.py", line 54, in check_admin_app errors.extend(site.check(app_configs)) File "/Users/AUTH_SYSTEM/backend/venv/lib/python3.9/site-packages/django/contrib/admin/sites.py", line 92, in check errors.extend(modeladmin.check()) File "/Users/AUTH_SYSTEM/backend/venv/lib/python3.9/site-packages/django/contrib/admin/options.py", line 122, in check return self.checks_class().check(self, **kwargs) File "/Users/AUTH_SYSTEM/backend/venv/lib/python3.9/site-packages/django/contrib/admin/checks.py", line 648, in check *self._check_list_filter(admin_obj), File "/Users/AUTH_SYSTEM/backend/venv/lib/python3.9/site-packages/django/contrib/admin/checks.py", line 804, in _check_list_filter return list(chain.from_iterable( File "/Users/AUTH_SYSTEM/backend/venv/lib/python3.9/site-packages/django/contrib/admin/checks.py", line 805, …