Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Error when installing a chart library in ReactJS @16.13.1
I am trying to install a chart library in a react app, but I am getting the same error. I am using version @16.13.1 for ReactJS, for python @3.8.2 and django @3.2.10 and "@material-ui/core": "4.9.14". Could you help me, please, to find out which is the problem and which library I should use with the versions listed above? Thank you gyp verb `which` failed Error: not found: python2 -
Updating manytomanyfield unchecks previous objects
My project consists of a Book model which holds all sorts of different genres of books. For example romance, horror, sci-fi and so on. Each user then has a reading list. Which is a model that looks like this: class Readinglist(models.Model): user = models.OnetoOnefie(User, on_delete=models.CASCADE) books = models.ManyToManyField(Books) The reading list is then presented to each user by category. To be able to add books to each category, have I created unique views (the categories are not that many). The horror view looks like this: class UpdateReadingListHorror(UpdateView): model = ReadingList form_class = ReadingListHorrorForm The ReadingListHorrorForm looks like this: class ReadingListHorrorForm(forms.ModelForm): book = forms.ModelMultipleChoiceField(queryset=Books.objects.filter(genre='Horror'),widget=forms.CheckboxSelectMultiple, label='') class Meta: model = ReadingList fields = ['books',] All the other views and forms for the other genres look the same, only the query set in the form is changed to match it. The problem is that when I update the Horror category, the books in the other categories get unchecked and are no longer tied to the user's reading list. I can't understand why this is happening. How can I prevent this from happening? -
Python requests cannot resolve Docker-Compose services
I have 2 docker-compose set ups in separate repos. When I run them I want them to talk to each other on the same network. Both apps are up and running and are on the same network by using docker inspect. But when I try to make requests from nhec_ter_app to vtn_app using python requests it's not able to resolve. docker-compose.yml 1 version: '3.2' services: vtn_app: &app tty: true cap_add: - SYS_PTRACE build: context: . args: requirements: requirements/development.txt container_name: vtn environment: - DEBUG=False - PYTHONUNBUFFERED=1 - TESTING_USER=oh_hey_there - SQL_USER=postgres - SQL_HOST=postgres - SQL_PASSWORD=postgres - SQL_DB=postgres - SQL_PORT=5432 restart: always volumes: - .:/app:delegated depends_on: - postgres ports: - 8000:80 - 8080:8080 - 8081:8081 command: make adev networks: - nhec-ter_ter-web-net postgres: image: postgres:10 container_name: vtn_postgres environment: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres - POSTGRES_DB=postgres ports: - 5432:5432 networks: - nhec-ter_ter-web-net networks: nhec-ter_ter-web-net: external: name: nhec-ter_ter-web-net docker-compose.yml 2 version: "3.9" services: nhec_ter_app: build: . command: python manage.py runserver 0.0.0.0:8000 container_name: nhec_ter environment: - DEBUG=True - PYTHONUNBUFFERED=1 - TER_BASIC_AUTH_USER=pricesAdmin - TER_BASIC_AUTH_PASSWORD=Barry0325! - CELERY_BROKER_URL=redis://broker:6379/0 - VTN_API_URL=http://vtn_app/ - VTN_API_TOKEN=NHEC_UTILITY volumes: - .:/code ports: - "9000:8000" depends_on: - db - celery-worker - broker networks: - nhec-ter_ter-web-net nhec_ter_test: build: . command: python manage.py test container_name: nhec_ter_test environment: - DEBUG=True - … -
how to pass data from Django to react without database
I am doing a dashboard app using Django and react. The user 's data is from Dynamics CRM API. I created a function in python to fetch all the info I need for the dashboard from the api. What I want to do is to pass the user 's data (business orders) from Django -
Class Based Views Form neither Valid nor Invalid (Django)
I'm new to Django Class Based Views and I can't get my form to pass through neither form_valid() nor form_invalid(). I have taken most of this code from the Django allauth module, so I extend some mixins (AjaxCapableProcessFormViewMixin & LogoutFunctionalityMixin) that I do not know well. This form is meant to allow users to change their passwords upon receiving an email. As it is now, users are able to change their password but since the form_valid() function is never triggered, they do no get redirected to the success URL as is intended. Instead the password change is registered but the users stay on the same page. The functions dispatch(), get_form_kwargs() & get_form_class() are all triggered and behave in the way that they should. Still, it's unclear to me why they execute in the order that they do (dispatch() is triggered first, then get_form_class() and finally get_form_kwargs(). I suppose they implicitely have an order as presented in this documentation: https://ccbv.co.uk/projects/Django/4.0/django.views.generic.edit/FormView/) I am lacking some intuition about how this works, therefore I don't know if there is a way to redirect to the success URL without passing through form_valid() because that would also solve my problem. Here is my code: class PasswordResetFromKeyView(AjaxCapableProcessFormViewMixin, … -
why django command not working in vscode?
when I create new commande in my terminal (in vsCode) or cmd .. the command it doesn't work nothing happens -
how can i get an object in templates by using django sessions?
so basically im making an E-commerce website. and i want to implement sessions in it. i stored product.id as a key and product.quantity as a value in a dictionary called cart and stored in the session request.session['cart'] = cart if i print request.session['cart'], it prints keys and values like this {'10': 2, '15': 1, '11': 1} as it should be but i wanna do is to get product object in templates by this session. i wanna get all the product details(name,price, etc) by its id in cart.html is there any way i can do that? should i use custom template filter and how can i use that? Code id = request.POST.get('id') obj_id = Product.objects.get(id=id) cart = request.session.get('cart') if cart: quantity = cart.get(id) if quantity: cart[id]= quantity+1 else: cart[id] = 1 else: cart={} cart[id] = 1 request.session['cart'] = cart print(cart) return redirect('index') what i was doing is store product obj as key in cart but it showed an error.. -
django web app and recording and storing video on server
I'm creating a Django exam portal web-app which will access user's camera and record user for monitoring his activity during exam and once he finishes his exam I want to store the recording into server's media folder in video format. I've tried mediaStream API of javascript and it works fine but I'm not able to store the data in server. Does anyone have any idea or knows any framework in python which I can use to complete my webapp? -
How can I create proper m2m signals in Django for get notifications?
My motive is to create a signal for ProductREVIEWS so that when a user gives a review on a particular product then the seller will get a notification like ' user given feedback on your product'. I created a signal but it didn't work. Please check it up and give me a relevant solution. signals.py: @receiver(m2m_changed, sender = ProductREVIEWS.product) def send_notification_when_someone_give_feedback(instance, pk_set, action, *args, **kwargs): pk = list(pk_set)[0] user = User.objects.get(pk=pk) if action == "post_add": Notification.objects.create( content_object = instance, user = instance.user, text = f"{user.username} given feedback on your product.", notification_types = "ProductREVIEWS" ) models.py: class Products(models.Model): user = models.ForeignKey(User, related_name="merchandise_product_related_name", on_delete=models.CASCADE, blank=True, null=True) product_title = models.CharField(blank=True, null=True, max_length = 250) class ProductREVIEWS(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='userREVIEW',on_delete=models.CASCADE) product = models.ForeignKey(Products, related_name='productREVIEWrelatedNAME',on_delete=models.CASCADE) feedBACK = models.TextField(blank=True, null=True) views.py: def user_notifications(request): notifications = Notification.objects.filter( user = request.user, is_seen = False ) for notification in notifications: notification.is_seen = True notification.save() return render(request, 'notifications.html') context_processors.py: from notification.models import Notification def user_notifications(request): context = {} if request.user.is_authenticated: notifications = Notification.objects.filter( user = request.user ).order_by('-created_date') unseen = notifications.exclude(is_seen = True) context['notifications'] = notifications context['unseen'] = unseen.count() return context templates: {% if notification.notification_types == 'ProductREVIEWS' %} <a href="{% url 'quick_view' notification.content_object.id %}"> {{ notification.text }} </a> {% endif … -
Using session data ion custom permissions Django
I want to validate session data in custom permission, when i tried to access session data inside permissons it is showing None.Please help on this. class IsEmployee(permissions.BasePermission): def has_permission(self, request, view): if (request.session.get(request.user) and request.session[self.request.user.email].get("project_id")) is not None: project_id = request.session.get("project_id") if Employee.objects.filter(user_id=self.request.user, project_id=project_id, status="A", project__status='A'): return True else: return False Result throws None -
hasattr(value, "contribute_to_class") returns KeyError: 'contribute_to_class' (Django 4.0.6)
A Django 1.1 / Python 2.7 project that I'm attempting to run on Python 3.10 / Django 4.0.6. A Python related error (i.e. old import) or a django code error (i.e. missing field that's now mandatory) pops up, I fix it and rerun. The current error, however, is coming from django/db/models/base.py, from this function - def _has_contribute_to_class(value): # Only call contribute_to_class() if it's bound. return not inspect.isclass(value) and hasattr(value, "contribute_to_class") I found this ticket - https://code.djangoproject.com/ticket/30309 that explains that hasattr is unreliable, but seems to be ignored. Has anyone encountered this issue, and managed to find a solution other than staying on Django 1.1? -
Django Add Related in Custom Form
Django Admin Add-related I would want to have the highlighted functionality in my custom form. What steps should i take? That is, from my Add Contact form, select a registrar if existing or add one and have the id as an input in the registrar field. -
Trouble Building OpenShift from Private Git Repository
I'm using OpenShift 4.10.20 to host/build a Django project (v4) I'm running into trouble building the application. These are the errors that I get when I build: Error: ErrImagePull Failed to pull image "visibility-testing-application:latest": rpc error: code = Unknown desc = reading manifest latest in docker.io/library/visibility-testing-application: errors: denied: requested access to the resource is denied unauthorized: authentication required Error starting build: an image stream cannot be used as build output because the integrated container image registry is not configured I'm using a source secret to pull the code from my private git repository to my image. I used the 'Import from Git' wizard for this. Import from git How I can fix this? -
How to filter based on a field in the custom through model using rest serializer?
I have two models with many to many relation. The many2many table is created and linked to the parent tables by the 'through' attribute. ModelA(modles.Model): name = charfield() ModelB(models.Model): subject = charfield(default=1, choices = [1,2,3]) people = ManyToManyField(ModelA, through="MOdelAB") ModelAB(models.Model): status = integerfield() modela_id = foreignkey() modelb_id = foreignkey() ModelB_Serializer(serializers.Serializer): modela = ModelASerailizer(many=True) class Meta: model = ModelB exclude = ... fields = ... depth = 1 This returns all the A objects in the through table, but I want to filter only the ones with status=99. Is there a nice way to do that? -
Django: How to add a foreign key that references itself and also sets a field on the referenced object
Sorry for the terrible title. I'm not even sure what I'm looking for. Basically, I would like to create the following: Model comprised of Ethernet switch interfaces (ex. ge-0/0/1, po4096, etc.) Be able to connect Ethernet switch interfaces TOGETHER (so, a foreign key to its own model) This is what I currently have: class EthernetSwitchInterfaces(models.Model): """ Represents interfaces on switches (ex. ge-0/0/1, ae1001, po1001, xe-1/1/1, eth1/101, etc.) """ interface = models.CharField(max_length=32, blank=False, null=False, help_text='Interface name (ex. xe-1/1/1, eth1/101, po1001, etc.)') switch = models.ForeignKey(EthernetSwitches, to_field='id', on_delete=models.CASCADE, help_text='Switch') # Note the speed of that interface link_bandwidth_in_gbps = models.IntegerField(blank=False, null=False, help_text='Total interface bandwidth in Gbps') # Account for port channel interfaces is_port_channel = models.BooleanField(default=False, blank=False, null=False, help_text='Is this a port channel interface?') number_of_links = models.IntegerField(blank=False, null=False, default=1, help_text='Number of links (if port channel)') switch_to_switch = models.ForeignKey('self', blank=True, null=True, help_text='Switch-to-switch connection', on_delete=models.SET_NULL) def __str__(self): return "{} - {}".format(self.switch, self.interface) class Meta(object): unique_together = ('interface', 'switch',) This almost works. I create an interface, create a second interface, and set the second interface's switch_to_switch field to the original interface. This works great except the original interface has a blank switch_to_switch value. Any help would be greatly appreciated! I've been stuck on this for a week now … -
Ariadne graphql displaying Django choices in query
I have a django model with Integer Choice fields class issue_status(models.IntegerChoices): '''Status''' Open = 1 Pending = 2 Completed = 3 class Issue(models.Model): person = models.ForeignKey('Person', on_delete=models.CASCADE, blank=False, null=False) name = models.CharField(max_length=100, null=True, blank=True) status = models.IntegerField(choices=issue_status.choices, blank=True, null=True) def __str__(self): return self.name I have my graphql types and resolver defined like this from ariadne import gql type_defs = gql(""" enum Status { Open Pending Completed } type Issue { id: ID person: Person! name: String status: Status } input IssueInput { id: ID person: PersonInput! name: String status: Status } input IssueUpdate { id: ID! person: PersonInput name: String status: Status } type Query { Issues(id: ID, name:String, ): [Issue] } """) query = QueryType() @query.field("Issue") def resolve_Issue(*_, name=None, id=None,): if name: filter = Q(name__icontains=name) return Issue.objects.filter(filter) if id: filter = Q(id__exact=id) return Issue.objects.filter(filter) return Issue.objects.all() When I do a gql query I get null values in the status field: { "data": { "Issues": [ { "person": { "name": "Test1" }, "id": "1", "name": "Things", "status": null }, { "person": { "name": "Test1" }, "id": "2", "name": "Clown and clown", "status": null } ] }, "errors": [ { "message": "Enum 'Status' cannot represent value: 1", "locations": [ { "line": … -
Django Models. User - Marks
Good afternoon! I'm trying to figure out the models on the example of a training site in Django. Question: Is it possible to make a "filter" in the model so that users from the Members table with the role of "teacher" come to T_Member? Or is it not possible to do this at the model level? second question: did i define the fields correctly? :) Thanks to There is a class "Users" student = 'ST' parent = 'PA' teacher = 'TE' SCHOOL_CHOICES = [ (student, 'Student'), (parent, 'Parent'), (teacher, 'Teacher'), ] user_id = models.AutoField(verbose_name='User ID', auto_created=True, primary_key=True) username = models.CharField(verbose_name='username', max_length=255, blank=True) dob = models.DateField(verbose_name='date of birthday', blank=False, default=date.today) role = models.CharField(max_length=2, choices=SCHOOL_CHOICES, default=student ) and class Marks: class Marks(models.Model): mark_id = models.AutoField(verbose_name='User ID', auto_created=True, primary_key=True) d_of_publ = models.DateField(verbose_name='Дата оценивания', blank=False, default=date.today) subject = models.ManyToManyField(Subject, verbose_name='Subjects') T_Member = models.ManyToManyField(Members, verbose_name='Teachers') S_Member = models.ManyToManyField(Members, verbose_name='Students') mark = models.IntegerField(verbose_name='Marks', blank=False, default=2) -
django template render pagination
I want to set dynamic pagination to my template but the problem is that when i change the page, the pagination will reset view is: def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['paginate'] = [1, 2, 4] context['CurrentPaginate'] = self.request.GET.get('paginate') return context template is : <select name="paginate" class="form-select form-select-sm" aria-label=".form-select-sm example" onchange="if(this.value != 0) { this.form.submit()};"> {% for option in paginate %} {% if option != currnetPaginate %} <option selected="selected" value={{ option }}> Pagination{{ option }} </option> {% elif option == currnetPaginate %} <option selected="selected" value={{ option }}>Pagination {{ option }} </option> {% endif %} {% endfor %} </select> the IF statement won't work correctly. -
how do i convert this function based view to a class based view?
i recently created a category system but the problem is that when ever i go to another page that isn't the home page, all the categories go away because i haven't referenced them. i found that by adding def get_context_data(self, *args, **kwargs): cat_menu = Category.objects.all() context = super(CategoryView, self).get_context_data(*args, **kwargs) context["cat_menu"] = cat_menu return context below each view then it would allow the categories in all my pages. but because for a few views i used function based views and since i can't for example do: def CategoryView(request, cats): category_posts = Post.objects.filter(category=cats) return render(request, 'blog/categories.html', {'cats':cats, ' category_posts':category_posts}) def get_context_data(self, *args, **kwargs): cat_menu = Category.objects.all() context = super(CategoryView, self).get_context_data(*args, **kwargs) context["cat_menu"] = cat_menu return context i need to convert def CategoryView(request, cats): category_posts = Post.objects.filter(category=cats) return render(request, 'blog/categories.html', {'cats':cats, ' category_posts':category_posts}) to a class based view. i first tried doing this: class CategoryView(ListView): template_name = 'blog/categories.html' model = Post context_object_name = "category_posts" def get_queryset(self): return super().get_queryset().filter(category=self.kwargs.get('cats')) def get_context_data(self, *args, **kwargs): cat_menu = Category.objects.all() context = super(CategoryView, self).get_context_data(*args, **kwargs) context["cat_menu"] = cat_menu return context but when i rendered out the template i lost the {{cats}} - categories any help would be appreciated -
How to use Django Simple Pagination?
Hello bros Im using Django Simple Pagination from github. Everything is quite simple but there are two issues. 1: Simple Pagination is not showing current links. 2: It is not using link's template (Which I want to be used to edit pagination). Module name: simple_pagination models.py #!/usr/bin/python # -*- coding: utf-8 -*- """Ephemeral models used to represent a page and a list of pages.""" from __future__ import unicode_literals from django.template import loader from django.utils.encoding import iri_to_uri from simple_pagination import settings from simple_pagination import utils # Page templates cache. _template_cache = {} class EndlessPage(utils.UnicodeMixin): """A page link representation. Interesting attributes: - *self.number*: the page number; - *self.label*: the label of the link (usually the page number as string); - *self.url*: the url of the page (strting with "?"); - *self.path*: the path of the page; - *self.is_current*: return True if page is the current page displayed; - *self.is_first*: return True if page is the first page; - *self.is_last*: return True if page is the last page. """ def __init__( self, request, number, current_number, *args, **kwargs ): total_number = kwargs.get('total_number') querystring_key = kwargs.get('querystring_key', 'page') label = kwargs.get('label', None) default_number = kwargs.get('default_number', 1) override_path = kwargs.get('override_path', None) self._request = request self.number = number … -
ConfingExeption while Sending a job signal to kubernetes inside django to activate a pod
I have made a C++ program and set it up with docker/kubernetes inside google cloud using Github actions. I have 3 active pods inside my cluster and my c++ program basically takes a json as an input from a django application and gives an output. My goal right now is to trigger a pod inside django. Right now i wrote some code using the official kubernetes django package but I'm getting an error: Here is what i wrote up until now: from kubernetes import client, config, utils import kubernetes.client from kubernetes.client.rest import ApiException # Set logging logging.basicConfig(stream=sys.stdout, level=logging.INFO) # Setup K8 configs # config.load_incluster_config("./kube-config.yaml") config.load_kube_config("./kube-config.yaml") configuration = kubernetes.client.Configuration() api_instance = kubernetes.client.BatchV1Api(kubernetes.client.ApiClient(configuration)) I don't know much about the kube-config.yaml file so i borrowed a code from the internet: apiVersion: batch/v1beta1 kind: CronJob metadata: name: test spec: schedule: "*/5 * * * *" jobTemplate: spec: template: spec: containers: - name: test image: test:v5 env: imagePullPolicy: IfNotPresent command: ['./CppProgram'] args: ['project.json'] restartPolicy: OnFailure But when i call this via a view i get this error on the console: kubernetes.config.config_exception.ConfigException: Invalid kube-config file. No configuration found. Is my load_kube_config call at fault or is my yaml file wrong? If so is there an example … -
django - BaseSerializer.save() takes 1 positional argument but 2 were given
The following error occurred while implementing signup.. When it is a get request, the value of the field appears well, but when i send a post request, the following error occurs. [ BaseSerializer.save() takes 1 positional argument but 2 were given ] What should I do? Help me please.. ㅠ_ㅠ <serializers.py> from .models import User from dj_rest_auth.registration.serializers import RegisterSerializer from rest_framework import serializers class SignUpSerializer(serializers.ModelSerializer): class Meta: model = User fields = ['email', 'password', 'realname', 'nickname', 'address', 'phone', 'height', 'weight'] def save(self, request): user = super().save(request) realname = self.data.get('realname') nickname = self.data.get('nickname') address = self.data.get('nickname') phone = self.data.get('phone') height = self.data.get('height') weight = self.data.get('weight') if realname: user.realname = realname if nickname: user.nickname = nickname if address: user.address = address if phone: user.phone = phone if height: user.height = height if weight: user.weight = weight user.save() return user <models.py> class User(AbstractUser): username = None email = models.EmailField(max_length=255, unique=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = UserManager() realname = models.CharField(max_length=50, blank=True) nickname = models.CharField(max_length=50, blank=True) address = models.CharField(max_length=200, blank=True) phone = models.CharField(max_length=100, blank=True) height = models.DecimalField(max_digits=4, decimal_places=1, default=0) weight = models.DecimalField(max_digits=4, decimal_places=1, default=0) def __str__(self): return self.email <setting.py> REST_AUTH_REGISTER_SERIALIZERS = { 'REGISTER_SERIALIZER': 'accounts.serializers.SignUpSerializer' } -
Django : Adding pagination and searchbar to filter the listing of a FormView (ClassView)
I use a FormView from the ClassView available in Django to upload and display listing of files. In the FormView there is no get_queryset and pagination methods to list easily data. So I used the te get_context_data and the get method combined with a pagination method that I wrote to do my file table listing.This part works I want to add a searchbar to filter the results and change the pagination too. However I do not manage to add this fonctionnality to my code. I think that the code is not well structured between the "get_context_data", "get" and "pagination" and I do not see how to change it. I think the problem is more with how I use the "get_context_data" and "get". Can anyone help me ? There is no interest to look to the post method of the code, it is to upload the files. views.py class DocumentUpload(FormView) : model = Documents template_name = 'upload/upload.html' form_class = FilesForm def pagination(self, page_number, list_files): paginator = Paginator(list_files, 10) try: list_files_page = paginator.page(page_number) except PageNotAnInteger: list_files_page = paginator.page(1) except EmptyPage: list_files_page = paginator.page(paginator.num_pages) return list_files_page def get_context_data(self, *args, **kwargs): # Call the base implementation first to get a context context = super(DocumentUpload, … -
python manage.py runserver won't run after git cloning my repo
Please I am having issues running python manage.py runserver after git cloning my project repo, creating a virtual environment and installing all required requirements. Please response is needed urgently (.venv) PS C:\Users\ASUS\desktop\project\file-comp-107> python manage.py runserver Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). Exception in thread django-main-thread: Traceback (most recent call last): File "C:\Users\ASUS\desktop\project\file-comp-107.venv\lib\site-packages\django\db\backends\base\base.py", line 244, in ensure_connection self.connect() File "C:\Users\ASUS\desktop\project\file-comp-107.venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "C:\Users\ASUS\desktop\project\file-comp-107.venv\lib\site-packages\django\db\backends\base\base.py", line 225, in connect self.connection = self.get_new_connection(conn_params) File "C:\Users\ASUS\desktop\project\file-comp-107.venv\lib\site-packages\django\utils\asyncio.py", line 26, in inner return func(*args, **kwargs) File "C:\Users\ASUS\desktop\project\file-comp-107.venv\lib\site-packages\django\db\backends\postgresql\base.py", line 203, in get_new_connection connection = Database.connect(**conn_params) File "C:\Users\ASUS\desktop\project\file-comp-107.venv\lib\site-packages\psycopg2_init_.py", line 122, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync) psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: fe_sendauth: no password supplied The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\threading.py", line 1009, in _bootstrap_inner self.run() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\threading.py", line 946, in run self._target(*self._args, **self._kwargs) File "C:\Users\ASUS\desktop\project\file-comp-107.venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "C:\Users\ASUS\desktop\project\file-comp-107.venv\lib\site-packages\django\core\management\commands\runserver.py", line 137, in inner_run self.check_migrations() File "C:\Users\ASUS\desktop\project\file-comp-107.venv\lib\site-packages\django\core\management\base.py", line 576, in check_migrations executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) File "C:\Users\ASUS\desktop\project\file-comp-107.venv\lib\site-packages\django\db\migrations\executor.py", line 18, in init self.loader = MigrationLoader(self.connection) File "C:\Users\ASUS\desktop\project\file-comp-107.venv\lib\site-packages\django\db\migrations\loader.py", line 58, in init … -
Foreign key relationship with boolean values
I'm working on a feature. I've three different car types (Sedan, Hatchback, SUV): Category(models.Model): id- name- image- I've 6 features in total. Feature(models.Model): id- name- detail- image- Out of 6, 4 features are their in every car. The second car category has 5 and the third has all the 6 features. Here where I'm getting stuck: I've to send all the 6 features in all the categories to the frontend so that if someone clicks on the first category, they should be able to show them all 6 with 2 non-available feature strike down or disabled or something. So basically there should be some boolean value which shows that this feature in this category is True or False. How can I design the tables?