Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Connecting multiple Reddit accounts associated with one user in Python-Django
I want to create a website like postpone using Django and PRAW and I want to create a service that user can connect his/her multiple Reddit accounts and he/she can create schedule posts on reddit so far, I did this. I created custom user model: # customers/models.py import uuid from django.db import models from django.contrib.auth.models import AbstractBaseUser, BaseUserManager class CustomerManager(BaseUserManager): def create_user(self, email, password=None): if not email: raise ValueError('Users must have email') user = self.model(email=self.normalize_email(email)) user.set_password(password) user.save(using=self._db) return user def create_superuser(self, email, first_name, last_name, password=None): user = self.create_user(email=self.normalize_email(email), password=password) user.is_admin = True user.is_staff = True user.is_superuser = True user.save(using=self._db) return user class Customer(AbstractBaseUser): email = models.EmailField(max_length=60, unique=True) data_joined = models.DateTimeField(auto_now_add=True) last_login = models.DateTimeField(auto_now_add=True) is_active = models.BooleanField(default=True) is_admin = models.BooleanField(default=False) is_staff = models.BooleanField(default=False) is_superuser = models.BooleanField(default=False) USERNAME_FIELD = 'email' objects = CustomerManager() def __str__(self): return self.email def has_perm(self, perm, obj=None): return self.is_admin def has_module_perms(self, app_label): return True And I added my reddit account informations such as client_id, client_secret and user_agent: # customers/reddit_conf.py import praw from django.http import HttpResponse from django.shortcuts import redirect from oauthlib.oauth2 import WebApplicationClient from django.contrib.auth import get_user_model import requests import secrets User = get_user_model() # Reddit App Configuration client_id = "****************", client_secret = "**************", redirect_uri='http://127.0.0.1:8000', user_agent="****** by u/******", … -
In Django how can i execute multiple if/else conditions in a function and print their result to a div?
I would like to execute some multiple conditions (if/else) in the def function_check function and print their multiple result in a grey div, for example like this: Initially i had all the code in the same function, now i have divided it into two functions and mentioned the difficulties, so i want to continue using 2 separate functions: def function_input_user and def function_check. Precisely, the app checks if there are words in a textarea (user_input.html). If there are, then I would like to print a message in the grey div. I'm new to Django, my difficulties are with context and return JsonResponse(context, status=200), because i can't return all multiple condition results and print them in the colored div. I get error: raise TypeError( TypeError: In order to allow non-dict objects to be serialized set the safe parameter to False. index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>University</title> {% load static %} <link rel="stylesheet" type="text/css" href="{% static 'css/a.css' %}"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> </head> <body> <div class="test"> <div>Input User</div> <div class="editor"> <pre class="editor-lines"></pre> <div class="editor-area"> <pre class="editor-highlight"><code class="language-html"></code></pre> <textarea class="editor-textarea" id="userinput" data-lang="html" spellcheck="false" autocorrect="off" autocapitalize="off"> &lt;!DOCTYPE html> &lt;html> &lt;head> &lt;title>Page Title&lt;/title> &lt;/head> &lt;body> &lt;div … -
Django Restframework designs are not working After Hosting?
i hosted a application but the restframework design like the redcolor form alignments are not working , without design only texts are there , how to get the restframework design need to show the restframework design and also the ststicfiles will be working properly -
Django: creating form with unknown amount of select input
i have form in my template that works well but i want to "convert" this form to django form. In my class register i have form with unknown amount of selects because in one class i can have 12 students in other 18. Here is my code: html <form method="post"> {% csrf_token %} <table class="table"> <thead> <tr> <th>ID</th> <th>first name</th> <th>last name</th> <th>January</th> <th>February</th> <th>March</th> <th>April</th> </tr> </thead> {% for student in students %} <tbody> <!-- Grades --> <tr> <td>{{ student.id }}</td> <td>{{ student.student.first_name }}</td> <td>{{ student.student.last_name }}</td> <td> <!-- Grades for January - for testing purpose --> {% for grade in grades %} {% if grade.student.id == student.id and subject == grade.subject %} {{ grade.display_value }} {% endif %} {% endfor %} </td> <td></td> <td></td> <td></td> <td></td> <td> <div class="form-group grade-select"> <select class="form-select" id="id_grade_{{student.id}}" name="grade_{{student.id}}"> <option value="0" selected disabled hidden>Grade</option> <option value="1">1</option> <option value="1+">1+</option> <option value="2">2-</option> <option value="2">2</option> <option value="2+">2+</option> <option value="3-">3-</option> <option value="3">3</option> <option value="3+">3+</option> <option value="4-">4-</option> <option value="4">4</option> <option value="4+">4+</option> <option value="5-">5-</option> <option value="5">5</option> <option value="5+">5+</option> <option value="6-">6-</option> <option value="6">6</option> </select> </div> </td> </tr> </tbody> {% endfor %} </table> <div class="form-group grade-select"> <select class="form-select" id="id_assigment" name="assigment"> <option value="0" selected disabled hidden>assigment</option> {% for assigment in assigments %} … -
In Django, i can't print a simple string message that contains the > and < characters. The characters are ignored and not printed
In Django i'm trying to print a simple message as a return of a function. if '<html>' in file2_processed: context["message"] = "CORRECT: <html> found" else: context["message"] = "ERROR: <html> not found" PROBLEM: The problem is that <html> is not printed, so the printed output is: CORRECT: found or ERROR: not found ATTEMPTS: I tried using repr(text) or text.encode().decode('raw_unicode_escape'), but it doesn't work. How can I solve it and print CORRECT: <html> found or ERROR: <html> not found ? -
Docker containers not able to communicate to each other
I'm trying to prepare a docker-compose.yml file to serve a django app. I have two services: the web server (using gunicorn) the database (Postgres) this is my docker-compose.yml file version: '3' services: db: image: postgres:latest container_name: db ports: - "5433:5433" volumes: - ./postgres_data:/var/lib/postgresql/data environment: - POSTGRES_HOST_AUTH_METHOD=trust - POSTGRES_DB=postgresdb - POSTGRES_USER=admin - POSTGRES_PASSWORD=admin web: image: django-app:latest build: context: . dockerfile: Dockerfile ports: - "8000:8000" volumes: - .:/app depends_on: - db volumes: postgres_data: My Dockerfile file: # Use the official Python image as a base image FROM python:3.11-slim-buster # Set environment variables ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 ENV BUD_DATABASE_HOST postgresql.test ENV BUD_DATABASE_PORT 5433 ENV BUD_DATABASE_NAME postgresdb ENV BUD_DATABASE_USER admin ENV BUD_DATABASE_PASSWORD admin ENV DJANGO_SETTINGS_MODULE app.settings.dev # Instalación de paquetes adicionales RUN apt-get update && apt-get install -y \ postgresql-client build-essential libpq-dev \ && rm -rf /var/lib/apt/lists/* # Set the working directory WORKDIR /app # Install dependencies COPY requirements.txt . RUN pip install --upgrade pip && pip install -r requirements.txt # Copy the Django project files COPY . . # Run migrations and collect static files RUN python manage.py migrate RUN python manage.py collectstatic --noinput # Start the Django development server CMD ["gunicorn", "app.wsgi:application", "--bind", "0.0.0.0:8000"] And app/settings/dev.py file: from app.settings.base import … -
Access blocked: authorisation error Gcloud
When using this docker command docker-compose -f docker-compose-deploy.yml run --rm gcloud sh -c "gcloud auth login", then it gives this error on clicking the URL: Cloud Authorization error which reads "The version of the app you're using doesn't include the latest security features to keep you protected. Please make sure to download from a trusted source and update to the latest, most secure version." "Error 400: invalid_request" Here's the screenshotError Screenshot Note: While using normal "gcloud auth login", without docker it logins successfuly -
Google OAUTH2: error_description: 'Invalid client_id parameter value with 400 error
this is my login.jsx import axios from "axios"; import {Navigate} from "react-router-dom"; import {useState} from "react"; import GoogleLogin from "react-google-login"; import {gapi} from "gapi-script"; import {useEffect} from "react"; import 'bootstrap/dist/css/bootstrap.css'; export const Login = () => { const clientId = "252855945185-0fm1oqq2945rkv2sak6satjgvopiiv1o.apps.googleusercontent.com"; const onSuccess = async (res) => { console.log('succzddgsfgess:', res.accessToken); const user = { "grant_type":"convert_token", "client_id":"", // <==== replace with google client_id from google console "client_secret":"", // <==== replace with google client_secret from google console "backend":"google", "token": res.accessToken }; console.log("hi") console.log(user) const {data} = await axios.post('http://localhost:8000/api-auth/convert-token/', user ,{headers: { 'Content-Type': 'application/json' }}, {withCredentials: true}); <=== where error caused console.log('API Response:', data); console.log(data, data['access_token']) axios.defaults.headers.common['Authorization'] = `Bearer ${data['access_token']}`; localStorage.clear(); localStorage.setItem('access_token', data.access_token); localStorage.setItem('refresh_token', data.refresh_token); try{ window.location.href = '/' }catch(error){ console.error("error", error); } } const onFailure = (err) => { console.log('failed:', err); }; return( <div className="Auth-form-container"> <GoogleLogin clientId={clientId} buttonText="Sign in with Google" onSuccess={onSuccess} onFailure={onFailure} cookiePolicy={'single_host_origin'} /> </div> ) } this is my settings.py """ Django settings for config project. Generated by 'django-admin startproject' using Django 4.2.7. For more information on this file, see https://docs.djangoproject.com/en/4.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.2/ref/settings/ """ from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = … -
Try to Display Number of Choice Selected at Any Time on Django Form MultipleChoiceField
I am building an application for a real estate project. As part of this, I have "listing" items in my database that I filter and display on my SearchTool.html page. One of the search functions includes a button that says "Select Property Type" on it. When you click the button, a small popup displays all of the multiple-choice field options from my Django form. I want the button to show how many choices are selected so that if the popup is closed you don't have to reopen it to know how many are active. Currently, it seems to mostly work. The popup works great. But, the counter has some problems. When I select exactly on the checkbox then the counter works fine but when I select the text to toggle the choice the counter doesn't catch it. When I click on the text like this, the backend still registers it because it sorts my listings correctly. So, there is an issue with the html/js not registering when I select the text vs the box itself. I am new to Django so please let me know if this question has been answered or if I am missing something obvious. Here is … -
Problem understanding serializer.data structure
I need some help from someone with better knowledge than myself, to understand this. I have a queryset of data and some context data that I send into a rather complex ModelSerializer. The Modelserializer adds (using the context data) fields to the data that doesn't come from the model itself. When I then look at serializer.data it looks like [OrderedDict([('field1', value1), ('field2', value2),....]),OrderedDict([('field1', value1), ('field2', value2),....])] when I drill down into next level for item in serializer.data: print(item) Output: OrderedDict([('field1', value1), ('field2', value2),....]) how can I access value1, value2 ? if I iterate in next level it only generates the key values,'field1','field2' etc for i in item: print(i) Output: 'field1' I understand there might be much better functions. But I'm doing it this very simple way to try to understand the structure of the data (without success aparantly). I hope someone understands my question and is able to explain to me. I've been playing around with deserialisation but I suspect the structure of the modelserializer doesn't allow it to be used. Is it correct that deserialisation only work on datasets that are 100% generated from the model in the Modelserializer in question? -
Seperated Django frontend and Django backend?
So I am creating my first django project for work and I think I am getting familar with it. I designed my views and URLs strongly oriented to REST principles. But since I render html and use forms to manipulate data, it is actually not REST in terms of pushing or pulling data. I have actually no desire to create a separated frontend in a different framework running at a different adress. But I wondered if it would be a reasonable idea to create an app frontend in my project and make all the other apps serve and receive json to make them restfull. Then I could use the frontend app to render the templates and query the data from the other endpoints. But maybe it's a stupid idea for reasons I don't see or I am unsure about. -
There is no method named delay() in celery shared_task decorator, how to fix it?
# orders/tasks.py from celery import shared_task from django.core.mail import send_mail from .models import Order @shared_task def order_created(order_id): order = Order.objects.get(id=order_id) subject = f'Order nr.{order.id}' message = f'Dear {order.first_name},\n\n You have successfully placed an order. Your order ID is {order.id}.' mail_sent = send_mail(subject, message, 'admin@myshop.com', [order.email]) return mail_sent # orders/views.py from django.shortcuts import render from .models import OrderItem from .forms import OrderCreateForm from cart.cart import Cart from .tasks import order_created def order_create(request): cart = Cart(request) if request.method == 'POST': form = OrderCreateForm(request.POST) if form.is_valid(): order = form.save() for item in cart: OrderItem.objects.create( order=order, product=item['product'], price=item['price'], quantity=item['quantity'] ) cart.clear() order_created.delay(order.id) return render(request, 'orders/order/created.html', {'order': order}) else: form = OrderCreateForm() return render(request, 'orders/order/create.html', {'form': form}) i imported celery in my project , and want to create an asynchronous task, after reading celery docs i think i do everything right , and still delay method does not exist Django==5.0.1 celery==5.3.6 -
Django Filter an String as Integer?
I have a problem when I need to make my filter: I need that Django compare a String field as Integer (Almost the entire table are Integers) This don't work, because only return the entry with 9, not with 12 or 13. queryset = Cards.objects.extra(select={'stars': 'CAST(stars AS INTEGER)'}).filter(stars__gte= 9) I tried also this: Cards.objects.annotate(stars_integer=Cast('stars', output_field=IntegerField())).filter(stars__gte= 9) With the same result, and I can't change the field to Integer because some values are Strings like "?" and "X" class Cards(models.Model): # CARD NAME name = models.CharField( max_length=128, null=False, unique=True, ) # AMMOUNT OF STARS stars = models.CharField( max_length=2, null=True, unique=False, default="", verbose_name="Stars" ) Thanks -
My django is returning a blank page after trying to go to a page with a form
I am new on django, so it may be a easy thing to solve, but I just can't see it myself. I am working on a Django project. It was already on, and I am just working on implementations. One of those implementations is to create a form for user to register allowed people. There is a page called "Persons", that permits user to search for someone and also displays a list of people already registered. I put a button, on that page for user click on it an go to the fom, add new allowed people. That button redirects to a page with this form, where user will type "name" and "userid" of the person. But everytime I trie to go to the page, it shows a blank page. I saw in some of the responses I found in my search, that since the page was not found, it is being redirect to home.html, that is in the web folder( that is empty). I will also put the code for a secondary problem, there is a button in home page, that when clicked redirects to a pdf file(tutorial). But the path is not recognized, this was implemented by the … -
Accessing a field in a through table in Django
I am using a through table on a many to many field and I am trying to get information to automate the submission of a form. I am having trouble accessing the fields in the through table. Here are my models: class ClientInformation(models.Model): client_id = models.AutoField(primary_key=True) client_custom_id = models.CharField(max_length=100, unique=True, null=True, blank=True) client_first_name = models.CharField(max_length=50) #required client_middle_name = models.CharField(max_length=50, blank=True, null=True) client_last_name = models.CharField(max_length=50) #required client_dob = models.DateField() #required client_street_address = models.CharField(max_length=100) #required client_unit_address = models.CharField(max_length=100, blank=True, null=True) client_city = models.CharField(max_length=50) #required client_state = models.ForeignKey('USStates', related_name="usstates", on_delete=models.SET_NULL, null=True) client_zip = models.CharField(max_length=10) #required client_telephone_number = models.CharField(max_length=100) #required client_email = models.EmailField(max_length=100, blank=True, null=True) client_service_branch_id_fk = models.ForeignKey('ServiceBranches', on_delete=models.SET_NULL, null=True) client_ssn = models.CharField(max_length=11, blank=True, null=True) client_admission_date = models.DateField() #required client_primary_diagnosis = models.ForeignKey('ICDDiagnoses', related_name='primarydiagnosis', on_delete=models.SET_NULL, null=True) client_secondary_diagnoses = models.ManyToManyField('ICDDiagnoses', related_name='secondarydiagnoses', through='ClientToSecondaryICD', blank=True) client_surgical_diagnoses = models.ManyToManyField('ICDSurgicalDiagnoses', related_name='surgicaldiagnoses', through='ClientToSurgicalICD', blank=True) client_date_of_injury = models.DateField() #required client_gender_fk = models.ForeignKey('Genders', on_delete=models.SET_NULL, null=True) #required client_race_fk = models.ForeignKey('RaceCategories', on_delete=models.SET_NULL, null=True) client_marital_status_fk = models.ForeignKey('MaritalStatus', on_delete=models.SET_NULL, null=True) client_preferred_hospital_fk = models.ForeignKey('Hospitals', on_delete=models.SET_NULL, null=True) client_drug_allergies = models.ManyToManyField('SimplifiedMedicineNames', related_name="drug_allergies", blank=True) client_other_allergies = models.CharField(max_length=1000, blank=True, null=True) client_referral_date = models.DateField() #required client_last_hospitalization_note = models.CharField(max_length=500, blank=True, null=True) client_last_hospitalization_discharge_date = models.DateField() #required client_claim_source_fk = models.ForeignKey('ClaimSource', on_delete=models.SET_NULL, null=True) client_image = models.TextField(null=True, blank=True) client_pharmacy_fk = models.ForeignKey('Pharmacies', related_name="pharmacy", blank=True, null=True, on_delete=models.SET_NULL) client_last_update = models.DateTimeField(default=timezone.now) … -
Django orm query fails in Postgresql
I am trying to perform a makeshift spatial join in django between 2 unrelated tables in a postgis database. An example query would be to locate points in one table within a certain distance of points in a second table. the first query could be cafes found using the following query: q1 = Pois.objects.filter(tags__amenity__contains = "cafe") for the next query, I would like to use the 1st to return objects within a certain dist or ideally return only the distance between the closest objects. In sql this looks like: select stops.id, stops.the_geom as geom, min(dist/(1.3*60)) as wlk_time from ways_vertices_pgr stops, lateral ( select st_distance(st_transform(stops.the_geom, 4326)::geography, st_transform(p.geom, 4326)::geography, false) as dist from pois p where p.tags @> '{"sport":"soccer", "leisure":"pitch"}'::jsonb ) as dist where dist < 400 group by stops.id, stops.the_geom; In django orm, when using the manager.raw() to execute a facsimile query with the q1 as an insertion into the query, the function fails when attempting to pass the results of q1 into the second query. Based on the documentation for the spatial queries, I need to pass the results of q1 or the q1.query string into the second query is a specific way but I am not sure how this … -
How to use properly Postgres group by year, month in Django raw query?
This is my first project when I'm using Postgres. Before I used sqlite3 and the syntax is different sometimes. I have this query that works well in pgAdmin4: SELECT auth_user.id, COUNT(coachregiszter_latogatoi_stat.id) AS count_id, DATE_TRUNC('year', datetime) AS year, DATE_TRUNC('month', datetime) AS month FROM auth_user LEFT JOIN coachregiszter_latogatoi_stat ON coachregiszter_latogatoi_stat.user_id = auth_user.id WHERE user_id=1 GROUP BY year, month, auth_user.id If I implement it to my project I get SyntaxError: invalid syntax. I know it points to this part DATE_TRUNC('year', datetime) AS year, DATE_TRUNC('month', datetime) AS month specially the '' marks at year and month but I can't find the solution what or how to use it in the project. -
How to better handle/save Python (3.x) exception traces that aren't immediately raised?
I have an exception class I created that I find extremely handy when dealing with multiple errors, and I would like to improve it. I call it AggregateErrors. Background Basically, it buffers exception objects. (The code that uses it is left to deal with addressing cascading errors so that the script can otherwise proceed, e.g. skip a row of input data). I wrote it because we have a scientific data submission interface and the data is always prone to many user errors (improper formatting, data conflicts, missing data, and a whole host of data-specific issues). The loading script takes a long time to run, and to have to restart the load after encountering individual errors can be a weeks long process. With my AggregatedErrors class, all errors and warnings are buffered, and eventually summarized at the end of the run. We have a data validation interface that re-uses the same loading code and provides the error summary to the researcher for them to be able to fix issues on their own and then attempt to revalidate. The Original Problem Since the exceptions are raised later, you don't get a trace of where the exception was caught and buffered. Mitigation of … -
How to use the Field API and Field attribute in django
How to use the Field API like get_internal_type() get_prep_value(value) from_db_value(value, expression, connection) and get the value from Field attributes like Field.auto_created Field.concrete Field.is_relation -
Python Django: make strftime return german language, not english
In my Django project, I'm using strftime, specifically %b to get the abbreviated month name. Those names are returned in english. My settings contain the following: LANGUAGE_CODE = 'de' # also tried 'de_DE' USE_I18N = True USE_TZ = True Why does strftime still return english language? -
403 Error when try to test Stripe CLI in windows
hello I am trying to Test Stripe CLI on my windows machine i am download the stipe.exe and i add it to the PATH i read Dcoumnet and but unfortunately when i tring to login with : stripe login i get 403 Error like this : unexpected http status code: 403 We're sorry, but we're unable to serve your request. I try also run the command in Powershell and i run both of cmd and powershell with adminstaration access but result is same any idea how can i fix this problem ? thank you so much -
Issue deploying webpage [Angular(v17) / Django(v4) / Nginx Proxy Manager / Portainer]
Well my problem is that I need to deploy a webpage which I used Angular v17 as frontend and Django v4 as backend, I'm pushing my application to seperated docker containers example-client-1:4200 and example-api-1:8000. In my nginx proxy manager, I set it up to work with example.com > http | example-client-1 | 4200 and api.example.com > http | example-api-1 | 8000. Well my Django application works, but my Angular application doesn't. So what I found out, when I pause the backend in nginx, my frontend works fine, well except my requests to the api fails (obviously). If I have both running, my frontend end up in 504 Gateway Time-out error and I don't get anything in nginx logs or from the frontend container. Anyone have an Idea what it could be? I had yesterday tried it on a dev. domain, and I got it somehow working, well today I wanted to deploy it to the real domain, did everything exactly like before, but doesn't work, I'm missing something I guess. Domains are hosted on a plesk server which got an A dns to point to my linux machine where my portainer is located. I've tried a few things (can't tell … -
How to patch ViewSet.filterset_class to return None?
I have this test @mock.patch("app.views.MyViewSet.filterset_class", return_value=None) def test_filter_chat_request_management_status(self, mock_filterset_class): query_parameter = "status=accepted" response = self.client.get(URL + "?" + query_parameter) assert 1 == 1 With filterset_class, query_parameter variable does change the behaviour of the MyViewSet (which I do not want), therefore it changes the response. That is why I used @mock.patch to disable filterset class so it does not influence for the response. However, when I debug my test (in local test_filter_chat_request_management_status scope), MyViewSet.filterset_class does not return None as I expect, but returns magic mock object instead. >>> print(MyViewSet.filterset_class) <MagicMock name='filterset_class' id='4894544640'> Therefore, in rest_framework.backends.py, in class DjangoFilterBackend, in get_filterset_class() method, while executing filterset_class = getattr(view, "filterset_class", None) line of code, filterset_class variable contains <MagicMock name='filterset_class' id='4894544640'> object instean of None. How can I force MyViewSet.filterset_class return None? -
Cannot specify the url in template. NoReverseMatch
I tried to create blog with Django and now i have 2 models Publications and Comments(ForeignKey). My URLconf in blog app: from django.urls import path from . import views app_name="publications" urlpatterns = [ path("", views.index, name="index"), path("<int:pk>/", views.detail, name="detail"), path("<int:publication_id>/comments/", views.comment, name="comment") ] The URLconf of my project: from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path("publications/", include("publications.urls")) ] My template for page with comments: {% extends "publications/base.html" %} {% block content %} <h1>{{ title }}</h1> <p>{{ text }}</p> <small><i>Publicated : {{ pub_date }}</i></small> <a href="{% url 'publications:comment' publication.id%}">comment</a> {% endblock %} Now when I try to open http://127.0.0.1:8000/publications/1/ Django raises Reverse for 'comment' with arguments '('',)' not found. 1 pattern(s) tried: ['publications/(?P<publication_id>[0-9]+)/comments/\Z'] Error during template rendering. When i remove the link to comment from my template it works fine. My function for comments in views.py now is just a plug: def comment(request, publication_id): return HttpResponse("Hello comment") Also can you give me some links where i can read more about url routing in Django I tried to specify the app_name for my URLconf. I tried to change my view name and the name for URL in URLconf. -
How do you have a class that inherits elements from another in Django?
I have a Customers class that has the attributes (corporate name....) and another that has Customer Data. It is a textfield, but does not appear as a textfield. And I'm calling it in the clients class with models.ForeignKey(OutraClasse, on_delete=models.CASCADE). Am I doing it wrong? What is missing?