Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
select_related and prefetch_related django
I have these 4 models: class User(models.Model): user = ... class Subject(models.Model): subject = ... class Section(models.Model): section= ... class Profile(models.Model): user= ... class student(models.Model): student = foreignkey(User) enrolled_subjects = ManyToMany(Subject) section = foreignkey(Section) profile = foreignkey(Profile) how can I get all related objects to Student object using select_related and prefetch_related to get? -
How To Create Chained Filter Form Fields Using Django Smart Selects
I have been searching online about how to make chained selections on filter forms (not forms). What I want to do is, select district according to the city that is selected. With normal forms I can make dependent dropdowns, but when it comes to filter forms, it does not seem to work. Here is my settings.py USE_DJANGO_JQUERY = True INSTALLED_APPS = [ 'smart_selects', ] Here is my template <form method="get"> {% csrf_token %} {{ form.media.js }} {{ myFilter.form|bootstrap }} <button type="submit" class="filter filtrele">Ara</button> </form> Here is my models.py class City(models.Model): name = models.CharField(max_length=30) def __str__(self): return self.name class District(models.Model): city = models.ForeignKey(city, on_delete=models.CASCADE) name = models.CharField(max_length=30) def __str__(self): return self.name class Usta(models.Model): user = models.OneToOneField(User, null=True, on_delete=models.CASCADE) gizlilik_sozlesmesi = MultiSelectField(choices=GIZLILIK_CHOICES, max_length=1000, max_choices=1, null=True) sartlar_sozlesmesi = MultiSelectField(choices=SARTLAR_CHOICES, max_length=1000, max_choices=1, null=True) isim = models.CharField(max_length=100) ana_kategoriler= MultiSelectField(choices=ANACATEGORY_CHOICES, max_length=1000, max_choices=5, null=True) usta_kategorileri= MultiSelectField(choices=USTACATEGORY_CHOICES, max_length=1000, max_choices=5, null=True, blank=True) bakici_kategorileri= MultiSelectField(choices=BAKICICATEGORY_CHOICES, max_length=1000, max_choices=5, null=True, blank=True) temizlikci_kategorileri= MultiSelectField(choices=TEMIZLIKCICATEGORY_CHOICES, max_length=1000, max_choices=5, null=True, blank=True) city = models.ForeignKey(City, on_delete=models.SET_NULL, null=True) district = ChainedForeignKey(District, chained_field="city", chained_model_field="city",show_all=False, auto_choose=True, null=True, sort=True) website = models.CharField(max_length=200, default='ananas.website', null=True) eposta = models.CharField(max_length=200, null=True) aciklama = models.TextField(max_length=10000, null=True) telefon = models.CharField(max_length=200, null=True) # aciklama = models.TextField(max_length=1000, null=True) profil_resmi = models.ImageField(default='ananas.jpg', upload_to='profile_images') resim_1 = models.ImageField(default='ananas.jpg', upload_to='profile_images') resim_2 = … -
How to set leaflet map layer selected as default
In my django app I have a leaflet map with two layers "active_event_layer" and "inactive_event_layer". I can select wich layer I want to see in the top right menu. But when the page is loaded no layer is selected by default, so in order to see a layer I must selected it first. What i want to do is to set a layer by default, so, when the page is loaded the "Active events" layer is selected by default. Here is my code: var active_event_collection = {{ active_events|geojsonfeature:"name"|safe }}; var inactive_event_collection = {{ inactive_events|geojsonfeature:"name"|safe }}; function onEachFeature(feature, layer) { layer.bindPopup(feature.properties.name); } function map_init(map, options) { var active_event_layer= L.geoJson(active_event_collection, {onEachFeature: onEachFeature}) var inactive_event_layer = L.geoJson(inactive_event_collection, {onEachFeature: onEachFeature}) var basemaps = { "Gray scale": L.tileLayer('http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png', { maxZoom: 18, attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' }), Streets: L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19, attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' }) }; var overlayMaps = { "Active events": active_event_layer, "Inactive events": inactive_event_layer, }; var features = L.control.layers(basemaps, overlayMaps).addTo(map); map.fitBounds(active_event_layer.getBounds()); } -
AttributeError 'Model' object has no attribute 'get_FOO_dispay'
qs = Model.objects.all() q = qs.get(id=1) q.get_field_dispay() returns 'Model' object has no attribute 'get_field_dispay' Am I not using it correctly? -
unsupported operand type(s) for /: 'method' and 'method', Django
Good afternoon community, I am new to Django, thus, I apologize in advance if my question happens to be silly. I am working on an investing project and I get the following error when I try to render the following method from the model: unsupported operand type(s) for /: 'method' and 'method' Here under is the code that I wrote, models.py: class Company(models.Model): #Company data company_name = models.CharField(max_length=100) outstanding_shares = models.IntegerField() share_price = models.DecimalField(max_digits= 5, decimal_places=2) revenue = models.IntegerField() expenses = models.IntegerField() total_assets = models.IntegerField() total_liabilities = models.IntegerField() current_assets = models.IntegerField() current_liabilities = models.IntegerField() operating_cashflows = models.IntegerField() capex = models.IntegerField() #Date of creation created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now= True) def __str__(self): return self.company_name #Company methods def net_income(self): return self.revenue - self.expenses def net_assets(self): return self.total_assets - self.total_liabilities def return_on_equity(self): return self.net_income / self.net_assets HTML FILE <li>Net income: {{company.net_income}}</li> <li>Net assets: {{company.net_assets}}</li> <li>Return on equity: {{company.return_on_equity}}</li> Note that both net_income and net_assets work just fine. The error rises with the last method, return on equity. I look forward to your enlightenment. -
Saving image files in django media instead of using base64 in quill editor?
I am using django as a backend and providing the api using rest-framework,I would like to use quill editor for my wysiwyg editor? Can anyone help me out in saving the image to django media files instead of saving as base64 it to the database?Thank you By the way , I am using vue for my frontend framework -
Django custom JSONField
I got JSONFields that I have to encode and decode every trip, the problem is I got few of them, so I'm trying to make a custom field like this: class JSONField(models.JSONField): """A Field to encode & decode JSONField.""" def __init__(self, default=dict, encoder=None, decoder=None): self.encoder = encoder self.decoder = decoder self.default = default def get_prep_value(self, value: Any) -> Any: if value is None: return value return json.dumps(value, default=self.default, cls=self.encoder) def from_db_value(self, value, expression, connection): if value is None: return value return json.loads(value, cls=self.decoder) But when I use it on the model class Employee(models.Model): time_log = JSONField() I get this error AttributeError: 'JSONField' object has no attribute 'name' File "/Users/mac/Documents/Payroll/payroll/models.py", line 106, in <module> class Employee(models.Model): File "/Users/mac/Documents/Payroll/env/lib/python3.9/site-packages/django/db/models/base.py", line 161, in __new__ new_class.add_to_class(obj_name, obj) File "/Users/mac/Documents/Payroll/env/lib/python3.9/site-packages/django/db/models/base.py", line 326, in add_to_class value.contribute_to_class(cls, name) File "/Users/mac/Documents/Payroll/env/lib/python3.9/site-packages/django/db/models/fields/__init__.py", line 781, in contribute_to_class self.set_attributes_from_name(name) File "/Users/mac/Documents/Payroll/env/lib/python3.9/site-packages/django/db/models/fields/__init__.py", line 768, in set_attributes_from_name self.name = self.name or name AttributeError: 'JSONField' object has no attribute 'name' How can I fix this problem? -
Django Annotate the Sum of a Foreign Key's Duration Values
I'm trying to get 5 foo objects whose children (bar) have the longest combined duration: foo = Foo.objects.annotate( sum_of_bar_duration=Sum("bar__duration") )\ .order_by('-sum_of_bar_duration')[:5] My Models: class Foo(models.Model): name = models.CharField(max_length=30, unique=True) #REVIEW deleted blank, null = False since this is default class Bar(models.Model): foo = models.ForeignKey(Foo, on_delete=models.CASCADE) duration = models.DurationField() But I ended up getting this error: django.core.exceptions.FieldError: Unsupported lookup 'duration' for BigAutoField or join on the field not permitted. Does anyone know why? How can I fix this? -
No module named W0614 pylint (fatal)
I'm working on a Django project and this error keeps coming up on the first line of every file I work on. I recently reset my computer and this is my first time using VSCode after. Please, what should I do? -
django login showing AnonymousUser after login
def loggin(req): if req.user.is_authenticated: return redirect('home') if req.POST: username=req.POST['username'] password=req.POST['password'] usr = authenticate(req,username=username,password=password) if usr is not None: login(req,usr) return redirect(reverse('home')) return render(req,'cart/login.html') def home(req): if req.user.is_authenticated: name=req.user context = { 'name':name, } return render(req,'anon/home.html',context) My settings.py are fine and have no error in code but after successful get logged in redirection to home view shows AnonymousUser.I dont know what i am doing wrong. -
Django / Crispy Forms Inheritance Not Translating to Rendered HTML Page
I am trying to set up a template for my form in Django using forms.py and Crispy but anything I set up in my forms. Ultimately I am just trying to get two fields on one row at the moment and the form template does not show up as formatted when rendered. I believe it may be an inheritance issue but I am not 100% sure. If I take the individual objects such as {{ form.phone_number|as_crispy_field }} then I can format it with <Div> and CSS in the HTML template but this seems unnecessary. #forms.py from django import forms from .models import * from crispy_forms.helper import FormHelper from crispy_forms.bootstrap import FormActions from crispy_forms.layout import Submit, Layout, Row, Column, Hidden class CustomerCreateForm(forms.Form): customer_name = forms.CharField(max_length=100) phone_number = forms.CharField(max_length=12) business_address = forms.BooleanField(required=False, initial=True) street_address_1 = forms.CharField(max_length=255) street_address_2 = forms.CharField(max_length=255, required=False) city = forms.CharField(max_length=100) region = forms.ChoiceField(choices=REGIONS_OPTIONS) postal_code = forms.CharField(help_text="Please enter in the format 'A1A1A1'", max_length=6) country = forms.ChoiceField(choices=COUNTRY_OPTIONS) def __init__(self, *args, **kwargs): super(CustomerCreateForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = 'POST' self.helper.attrs = { 'novalidate': '' } self.helper.layout = Layout( Row( Column('customer_name', css_class='form-group col-md-2 mb-0'), Column('phone_number', css_class='form-group col-md-2 mb-0'), css_class='form-row' ), # FormActions( # Submit('submit', 'Create Me') # ) ) #formtest2.html {% … -
Use an HTML page as default Django homepage
I just learned how to create a homepage like this: from django.shortcuts import render from django.http import HttpResponse # Create your views here. def home_view(request,*args, **kwargs): return HttpResponse("<h1>Hello</h1>") To do this I made an app called pages and edited views.py. Is there a way to do the same thing but instead of returning an HttpResponse I use my own HTML page instead? Basically replace the default homepage with my own HTML page. -
django.db.utils.ProgrammingError: (1146, "Table 'lab_equipment.lab_add' doesn't exist")
I am trying to delete objects stored on the database from Django admin page and I have gotten an Error django.db.utils.ProgrammingError: (1146, "Table 'lab_equipment.lab_add' doesn't exist") Views from django.shortcuts import render, redirect, get_object_or_404 from django.http import JsonResponse, HttpResponseRedirect from django.urls import reverse from .forms import * from .models import * # Create your views here. def main(request): return render(request, 'Lab/Lab.html') def generateView(request): if request.method == 'POST': # If the form has been submitted... esrl = Esrl_form(request.POST) # Create a form instance equ = equipment(request.POST) num = count_form(request.POST) add = Add_form(request.POST) if esrl.is_valid() and equ.is_valid() and num.is_valid() and add.is_valid(): # All validation rules pass print("all validation passed") loc = esrl.save() e = equ.save(commit=False) c = num.save(commit=False) a = add.save(commit=False) # not to save and connect the Foreign key e.location_number = loc # b.foreignkeytoA = a Connecting foreign key e.save() c.equipment_name = e c.loc_num = loc c.save() a.location_number = loc a.equipment_name = e a.stock = c a.save() return HttpResponseRedirect(reverse('home')) else: print("failed") else: # if the request method is not post then create a form instance u if the request method is not post then create a form instance and loaded in the templatenloaded in the template esrl = Esrl_form equ = equipment … -
django-simple-history save history only when a certain condition is met
I'm building a project using Django. I want to use the django-simple-history package to save the history of a model for every create/update/delete. I want to save the history only when the superuser or a specific type of user (e.g. supervisor) makes a create/update/delete action, but I don't know how can I implement this condition. I've tried this to see if the current user is one of its arguments to use it, but this method seems that it doesn't work properly. Below a portion of my code: class WFEmployee(models.Model): code = models.IntegerField(unique=True) name_en = models.CharField(max_length=55) ... history = HistoricalRecords() def save_without_historical_record(self, *args, **kwargs): print(kwargs, 'from save without ') try: ret = self.save(*args, **kwargs) finally: pass return ret I get nothing in the console when I use .save_without_historical_record() it saves the instance but doesn't print anything. How can I do this? -
DRF-Object of type ManyRelatedManager is not JSON serializable
I am trying to post many-to-many fields data, it returns Object of type ManyRelatedManager is not JSON serializable. models class Professionals(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key = True, related_name='professional') first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) profilePicture = models.ImageField(upload_to='professional/profiles', default='default_img.png') skill = models.ManyToManyField(Skill) serializer class ProfessionalSerializer(serializers.ModelSerializer): profilePicture = serializers.ImageField(allow_empty_file=True, use_url='professional/profiles', required=False) skill = SkillSerializer(many=True,read_only=True) class Meta: model = Professionals fields = fields = ['first_name', 'last_name', 'profilePicture', 'skill'] views class ProfessionalProfileUpdateView(APIView): permission_classes = (IsAuthenticated,IsProfessionalUser,) def put(self, request): serializer = ProfessionalSerializer(data=request.data, instance=request.user.professional) data = {} if serializer.is_valid(): professional = serializer.save() professional.save() data['skill'] = professional.skill return JsonResponse({ 'message': "your profile hans been updated", "success" : True, "result" : data, "status" : status.HTTP_200_OK }) else: data = serializer.errors return JsonResponse(serializer.data) posting data using postman { "first_name":"jhon", "last_name":"doe", "skill":[{ "id":1 }], } -
Heroku does not find my Django app module when local version does
The problem So, I have made a website with multiple homemade apps. I now want to deploy this website using Heroku. This doesn't work, however, as I keep getting errors relating to Heroku not being able to find the apps. When I run the website locally with python manage.py runserver everything behaves as expected. When I, however, try to deploy this website using Heroku I get an error (stack trace provided underneath). Project structure towima | .gitignore | Procfile | README.md | requirements.txt | runtime.txt | tree.txt | +---media_cdn | | .DS_Store | | | \---products | \---towima | .DS_Store | db.sqlite3 | manage.py | pharma_locations.json | __init__.py | +---accounts | | admin.py | | apps.py | | forms.py | | models.py | | tests.py | | urls.py | | views.py | | __init__.py | | | +---migrations +---api | | admin.py | | apps.py | | models.py | | serializers.py | | tests.py | | urls.py | | views.py | | __init__.py | | | +---migrations | +---orders | | admin.py | | apps.py | | forms.py | | models.py | | tests.py | | urls.py | | views.py | | __init__.py | | | +---migrations | +---pharmacies | … -
pk is passed but data not dsiplayed
I have a model that contains some judgments along with their title. Now i want to display the judgement when the related title is clicked. i have written the following code: models.py class Laws(models.Model): date= models.DateField(default=timezone.now) title= models.CharField(max_length=225, help_text="judgement title") judgements= RichTextField(blank=True, null= True) law_type= models.CharField(max_length=40, choices= type_of_law) law_category= models.CharField(max_length=60, choices= category) views.py class DocView(ListView): model= Laws template_name = 'doc.html' class Doc1DetailView(DetailView): model= Laws template_name = 'doc1.html' urls.py urlpatterns=[ path('doc', DocView.as_view(), name='doc' ), path('doc1/<int:pk>', Doc1DetailView.as_view(), name='doc1' ), ] and the html files are doc.html {% for data in object_list %} <div class="tab"> <a href="{% url 'doc1' data.pk %}">{{data.title}}</a><br/> </div> {% endfor %} doc1.html <p style="color: black;">{{data.judgements}}</p> I refered to a video in youtube and wrote this code his was working and mine not. i have chamged nothing from that code still the data doesn't show up in doc1.html. No filed is empty here. please rectify my code and tell me what i am doing wrong here. -
using Foreign Key value in if condition in Django Template
I have a model that have a Foreign Key in it. like this: class Chart(models.Model): titleFA = models.CharField(max_length=200) titleEN = models.CharField(max_length=200) category = models.ForeignKey(Category, on_delete=models.PROTECT, blank=True) category related to this model: class Category(models.Model): nameEN = models.CharField(max_length=200, default="") def drawcharthome(request): allcharts = Chart.objects.all() allcats = Category.objects.all() return render(request, 'charts/drawcharthome.html',{'allcharts': allcharts,'allcats':allcats}) I need to check the equality of two parameter in my template: {% for cat in allcats %} {% for chart in allcharts %} {% if chart.category == cat.nameEN %} <li> <a href="{{ chart.api_url }}"> {{ chart.titleFA }}</a> </li> {% endif %} {% endfor %} but my inner if do not work! -
Error connecting dockerized Django with MySQL on Mac OS
I am using Dockerized Djano to connect with MySql but getting the following error: File "/usr/local/lib/python3.9/site-packages/django/db/backends/mysql/base.py", line 17, in <module> raise ImproperlyConfigured( django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient? Have tried every single possible solution on stackoverflow and google, but nothing seems to work. I suspect the MySQL driver within the docker container needs to be updated/configured correctly. Does anyone have any suggestions on what are the exact steps to undertake to fix it? THANKS! ENVIRONMENT MacOS 10.15.7. requirements.txt: Django==3.1.3 djangorestframework==3.12.2 mysqlclient==2.0.1 django-mysql==3.9 django-cors-headers==3.5.0 pika==1.1.0 Dockerfile: FROM python:3.9 ENV PYTHONUNBUFFERED 1 WORKDIR /app COPY requirements.txt /app/requirements.txt RUN pip install -r requirements.txt COPY . /app CMD python manage.py runserver 0.0.0.0:8000 docker-compose.yml: version: '3.8' services: backend: build: context: . dockerfile: Dockerfile ports: - 8000:8000 volumes: - .:/app depends_on: - db db: image: mysql:5.7.22 restart: always environment: MYSQL_DATABASE: !@#$% MYSQL_USER: root MYSQL_PASSWORD: ****** MYSQL_ROOT_PASSWORD: ****** volumes: - .dbdata:/var/lib/mysql ports: - 33066:3306 -
My Django update form is not saving and it is also not showing the instance as a patient from the details the patient uses when they sign up
My django project does not recognize the instance of the patient details when I go to that page and it is also not saving the new patient details that I enter, instead I'm brought back to the same page with the new details I have entered. When I press the submit button again the same thing happens (same page with the new details) Models.py from django.db import models from django.contrib.auth.models import AbstractUser from django.utils import timezone class User(AbstractUser): is_patient = models.BooleanField(default=False) is_doctor = models.BooleanField(default=False) class Patient(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True) first_name = models.CharField(max_length=200) last_name = models.CharField(max_length=200) insurance = models.CharField(max_length=200) insuranceID = models.CharField(max_length=200) address = models.CharField(max_length=200) date_of_birth = models.DateField(default=timezone.now) gender = models.CharField(max_length=200) phone = models.CharField(max_length=200) current_medication = models.TextField(null=True, blank=True) preexisting_medication = models.TextField(null=True, blank=True) next_of_kin = models.TextField(null=True, blank=True) def __str__(self): return self.user.username class Doctor(models.Model): user = models.OneToOneField(User,on_delete=models.CASCADE,primary_key=True) name = models.CharField(max_length=200) date_of_birth = models.DateField(default=timezone.now) gender = models.CharField(max_length=200) phone = models.CharField(max_length=200) address = models.CharField(max_length=200) speciality = models.CharField(max_length=200) npi= models.CharField(max_length=200) education = models.TextField() qualifications = models.TextField() places_worked = models.TextField() consultation_fee = models.CharField(max_length=200) venue_of_operation = models.CharField(max_length=200) def __str__(self): return self.user.username FORMS.PY from django import forms from django.contrib.auth.forms import UserCreationForm from django.db import transaction from .models import Patient,Doctor, User GENDER_CHOICES = ( ('M', 'Male'), ('F', 'Female'), … -
Back button still works after logout in Safari with Django website
I am building a website with Django that handles sensitive data. My website has a logout button that logs the user out and redirects the browser to the login page. When using Safari version 14.1.1, I am able to click the back button in the browser after being logged out and I am returned to the previous page which contains private data. From my understanding, this doesn't seem to be a Django issue, rather Safari is storing content so it does not have to make another request to the server. I have tried a couple of methods to stop caching including: @cache_control(no_cache=True, must_revalidate=True, no_store=True) def some_method(request): #do some stuff and: @never_cache def some_method(request): #do some stuff and finally I tried manually changing the request headers with: response["Cache-Control"] = "no-cache, no-store, must-revalidate" response["Pragma"] = "no-cache" response["Expires"] = "0" Also, my views are annotated with @login_required(redirect_field_name="/somelink"). Some of my research suggested that this may not be a cache issue but rather a browser history issue but I'm not sure. It is also worth nothing that Chrome has given me no issues and when I click back button after logout it does not show what the previous user was viewing. Any ideas how … -
elided_page_range paginator not functioning as expected
I implemented a paginator based on this blog post with a goal of having a paginator that looks something like this so I don't have a ton of pages being display view def home(request): page = request.GET.get('page', 1) paginator = Paginator(Post.objects.all(), 1) page_obj = paginator.get_page(page) page_range = paginator.get_elided_page_range(number=page) context = {'page_range': page_range, 'page': page, 'paginator': paginator, 'page_obj': page_obj} return render(request, 'blog/home.html', context) template <main role="main" class="container"> <div class="row"> {% for post in page_obj %} <a class="article-title" href="{% url 'post-detail' post.id %}">{{ post.year }}</a> <a class="article-title" href="{% url 'post-detail' post.id %}">{{ post.title }}</a> {% endfor %} </div> <ul class="pagination justify-content-center flex-wrap mt-2 mb-4"> {% if page_obj.has_previous %} <li class="page-item"><a class="page-link" href="?page={{ page_obj.previous_page_number }}">&laquo;</a></li> {% else %} <li class="disabled page-item"><span class="page-link">&laquo;</span></li> {% endif %} {% for i in page_range|default_if_none:page_obj.paginator.get_elided_page_range %} {% if page_obj.number == i %} <li class="active page-item"><span class="page-link">{{ i }} <span class="sr-only">(current)</span></span> </li> {% else %} {% if i == page_obj.paginator.ELLIPSIS %} <li class="page-item"><span class="page-link">{{ i }}</span></li> {% else %} <li class="page-item"><a class="page-link" href="?page={{ i }}">{{ i }}</a></li> {% endif %} {% endif %} {% endfor %} {% if page_obj.has_next %} <li class="page-item"><a class="page-link" href="?page={{ page_obj.next_page_number }}">&raquo;</a></li> {% else %} <li class="disabled page-item"><span class="page-link">&raquo;</span></li> {% endif %} </ul> </main> The … -
502 Error Docker container running in the background
I have a container running Django app with PyTorch model(s) The issue is when starting the app/container it takes time to load and download the models Running the container in the background results in a 502 error, how can I avoid this should I make a function waiting for the models to be ready first just like the one I have that waits for the DB to be ready ? how can I check the readiness of the models? -
is there a way to get the import directly by typing name of module of python in vscode
lets say i have Django in a virtual environment and activated it and now i want to use the built-in user model "User", so every time i have to look for, then type: from django.contrib.auth.models import User the same thing for every import needed is there a way to quick-fix that , instead of looking for where this module or this other or ... comes from in the docs every time, is there a way that it suggests or gives the import path?? -
what is the difference between this two django imports
I am new to django and I am a little bit confused what is the difference between: from django.views.generic.detail import DetailView and from django.views.generic import DetailView I've tried to read up on it in the documentation but I wasn't able to find the answer.