Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django set relation between two models fields
I need to create relation between two model fields (without using ForeignKey method), for example: class Client(models.Model): login = models.CharField(max_length=100, blank=True, null=True) class StatClient(models.Model): client_login = models.CharField(max_length=100, blank=True, null=True) The relation need to by 1 to 1. I mean login need to by equal to client_login in another model and vice versa. To make this work i can overwrite for each model save() method: def save(self, *args, **kwargs): from * import StatClient data = StatClient(client_login=login) data.save() super().save(*args, **kwargs) Problem is when the data is changed based on php code direct in mysql. Then Django is not aware of any changes have been made! In this case one option is to monitor all data every 1 second but this can't be done because of performance. Is there any solution to do this without touching php code? -
What is Python function call with 'or None' as argument
I have been following this Django tutorial on youtube and they use this class call there: form = ContactForm(request.POST or None) What is (request.POST or None) part? I have never seen anyone do this and I am unable to formulate my question clearly enough for google to understand. How does 'or None' work? When is this used? What is the alternative way to call this class? -
You are trying to add a non-nullable field 'password' to user without a default; we can't do that
I am building a custom User class in django to use in creating a signup application and I keep on getting the error above every time I try to makemigrations.As far as I can see, my code is per django documentation here.I also have AUTH_USER_MODEL correctly placed in my settings configurations. Here's my models.py # from __future__ import unicode_literals from django.contrib.auth.models import AbstractUser from django.contrib.auth.base_user import BaseUserManager from django.db import models from django.utils.translation import ugettext_lazy as _ from django.core.validators import RegexValidator class UserManager(BaseUserManager): """Define a model manager for User model with no username field.""" use_in_migrations = True def _create_user(self, email, password, **extra_fields): """Create and save a User with the given email and password.""" if not email: raise ValueError('The given email must be set') email = self.normalize_email(email) user = self.model(email=email, **extra_fields) if password: user.set_password(password) user.save(using=self._db) return user def create_user(self, email, password=None, **extra_fields): """Create and save a regular User with the given email and password.""" extra_fields.setdefault('is_staff', False) extra_fields.setdefault('is_superuser', False) return self._create_user(email, password, **extra_fields) def create_superuser(self, email, password, **extra_fields): """Create and save a SuperUser with the given email and password.""" extra_fields.setdefault('is_staff', True) extra_fields.setdefault('is_superuser', True) if extra_fields.get('is_staff') is not True: raise ValueError('Superuser must have is_staff=True.') if extra_fields.get('is_superuser') is not True: raise ValueError('Superuser must have … -
Django confirmation with sweetalert before post
I have a problem with submit buttons in Django 2. In the beginning, I had two buttons. One button accepts something, another redirect to form with choose changes. Template: <form action="event\" method="post" id="systemForm"> {% csrf_token %} <button type="submit" name="akcept" value={{zami.id}} form="systemForm" class="akceptacja" data-toggle="tooltip" data-html="true" data-placement="top" title="<b>Tooltip</b> on top">Akceptacja</button> <button type="submit" name="system" value={{zami.id}} form="systemForm" class="akceptacja"> Do poprawy</button></form> View: def event(request): if request.method == 'POST' and 'system' in request.POST: system = request.POST.get('system', None) zamowienie = Order.objects.filter(id=system) context = {'zamowienie': zamowienie} context['system'] = system sesja_zamowienie = context['system'] request.session['zamowienie'] = sesja_zamowienie elif request.method == 'POST' and 'akcept' in request.POST: akcept = request.POST.get('akcept', None) zamowienie = Order.objects.filter(id=akcept) for zami in zamowienie: zami.akcept = True zami.wyslane = True zami.save() numer_zamowienia = zami.numer_zamowienia pozycja_zamowienia = zami.pozycja_zlecenia nazwa_tow = zami.nazwa receiver_email = "email" if zami.rodzaj_zlecenia == "PART": wysylka_czesciowa(numer_zamowienia,pozycja_zamowienia, nazwa_tow, receiver_email) context={} return redirect('/') else: context={} return render(request, 'event.html', context) Now i would like to submit button after second confirm button from sweetalert js </script> <script type="text/javascript"> function JSalert(){ swal({ title: "TITLE", text: "Accept?", type: "warning", showCancelButton: true, cancelButtonColor: "#DD6B55", confirmButtonColor: "#5cdd55", confirmButtonText: "Accept", cancelButtonText: "Quit", closeOnConfirm: false, closeOnCancel: false }, function(isConfirm){ if (isConfirm) { swal("Accepted!", "Action ...", "success"); event.preventDefault(); return true; } else { swal("Cancel", "Cancel...", "error"); return … -
How to get value of upload file in Ckeditor?
I am new to ckeditor, and need some guideline from everyone. Currently i'm implementing a custom plugin with feature upload file or docs to editor. I successfully display the UI file field however i have problem in get back the file uploaded content after i press green button 'OK'. Image below is my UI, Click ME to view ME Below are my code, CKEDITOR.dialog.add('attachFileDialog', function (editor) { return { title: 'Attach File', minWidth: 400, minHeight: 150, contents: [ { id: 'tab-attach-file', label: 'Attach File', elements: [ { type: 'text', id: 'filename', label: 'File Name', }, { type: 'hbox', className: 'hbox-v-bottom', widths: ['75%', '25%'], children: [ { type: 'file', id: 'upload', label: 'Select a file', }, { type: 'fileButton', id: 'fileId', label: 'Upload file', 'for': ['tab-attach-file', 'upload'], filebrowser: { onSelect: function (fileUrl, data) { alert('Successfully uploaded: ' + fileUrl); } } }, ] }, ] }, ], Next part is, I have added file browser plugin into ckeditor and this, filebrowserBrowseUrl: 'aapx/static/lib/ckeditor_4.13.0_full/fileupload.js', filebrowserUploadUrl: 'aapx/static/lib/ckeditor_4.13.0_full/fileupload.js', However, i have no idea what to write in the js file. Any good sample or guidelines. Deeply apologise for my bad english and noobness. And Thank You. -
Maximum number of database queries per view
I am currently working on a view that has multiple database queries in it (currently 10 but in the end it will be most likely 50 or more) -> My aim is to built a html page with a large table for monthly reporting purposes with all kind of data from the database (kind of a dashboard). My question 1: Is my approach of putting 50 or more queriesin a view sensible or will it make the page loading time very slow. If it is not sensible, what is the best practice to built a view with a lot of data from various sources (Eg. build only a few large queries that somehow chain together multiple smaller queries (in order to query the database less often) and then separate and slice and dice the data from the queryset via python? My question 2: Does it make any difference in efficiency whether I design my queries like this: data = Testdata3.objects.all() data1 = data.filter(key__regex=r'abc123$').order_by('date').values('date','performance') data2 = data.filter(key__regex=r'def456$').order_by('date').values('date','performance') data3 = data.filter(key__regex=r'ghi789').order_by('date').values('date','performance') or like this: data1 = Testdata3.objects.filter(key__regex=r'abc123$').order_by('date').values('date','performance') data2 = Testdata3.objects.filter(key__regex=r'def456$').order_by('date').values('date','performance') data3 = Testdata3.objects.filter(key__regex=r'ghi789').order_by('date').values('date','performance') My assumption would be that the first way is more efficient since I hit the database only once and … -
Is there an entity relationship diagram of Django default authentication database models?
The Django 2.2 default authentication uses User objects (username, password, email, first_name, last_name). However it's not clear to me how users are related to Django 2.2 default permissions and Django 2.2 groups. Is there an entity relationship diagram of the default, means a typical default database models in the docs or somewhere else? -
Django, how to write SQL or ORM to sum something?
I want to count something like this: input list: AAA female 1 AAA female 2 BBB male 2 BBB male 1 AAA male 1 output list: AAA male 1 AAA female 3 BBB male 3 Sorry, my english is not good, thanks for everyone who help me. -
How to filter for all in Model.objects.filter?
I'm wanting to set up a database table filter for my django template. The way I've done it is using Javascript in my template to send back the selected item in a select tag back to my view as a POST request. I have an "All" option in my drop down box which allows for no filter to be applied, but I'm not sure what to do with this. My plan was to filter the output by using Model.objects.filter(variable1 = {select}option1, etc, etc). But is there a way to write variable1 = all or variable1 = *? -
Impossible to scrape this website anymore
I am currently realising a project for school (torrents stream website like netflix) with Python/Django/NodeJS. Since the begin of project, i am scrapping the IMDb website to get data about movies (synopsis, casting, rate etc.). It worked well. Then, since few days I just can't scrape anymore. My request returns me an Error 503. At first, I thought about IP ban, but when i'm trying to scrap with Curl, it works fine. Actually I'm asking myself if the problem doesn't come from IMDb's robots.txt file ? How to be sure ? If it's the case, there are a way to bypass this ? Do you know any alternative ? Thanks for your help. Bye :) -
Display django chartit x-axis in right order with PivotDataPool
When I use Chartit PivotDataPool the month number is not in the right order. Chartit PivotDataPool graph is in this order 1, 10, 11, 2, 3, 4, 5, 7, 8, 9. I want to have right order like 1, 2, 3, 4 , 5, 6, 7, 8, 9, 10, 11. ![Graph image][1] ![1]:(https://imgur.com/UPBZY8G) ds = \ PivotDataPool( series= [{'options': { 'source': DerangementAdsl.objects.filter(annee=year), 'order_by': ['mois'], 'categories' : ['mois'], 'legend_by': ['sous_traitant'], }, 'terms': { 'total': Count('id') } } ]) pivcht = PivotChart( datasource=ds, series_options=[{ 'options': { 'type': 'column', 'stacking': True, 'order_by': 'mois', }, 'terms': ['total'] }], chart_options={ 'title': { 'text': 'Répartition dérangements relevés / structure' }, 'xAxis': { 'title': { 'text': 'Semaine' } } } ) -
Django createsuperuser function: no error but not working
I was trying to create a superuser a while back in Django, but I encountered a problem while doing so. Django won't create a superuser on its own but nor did it return a problem, leaving me no clue of what is going on in the backend. Screenshots: image 1: superuser's names are unique, but Django ignored it image 2: nothing was written into the database Settings.py: """ Django settings for pymun project. Generated by 'django-admin startproject' using Django 3.0b1. For more information on this file, see https://docs.djangoproject.com/en/dev/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/dev/ref/settings/ """ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '%m9@%@uhw99kbpfubd8um1svt&t2dp$daden_favr0o((&ng6_' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ 'accounts.apps.AccountsConfig', 'core.apps.CoreConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'pymun.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': … -
Unable to mailmerge into a template word document when launched on heroku
I am working on a django application in which users input is inserted into a template word document. I used the mailmerge library to achieve this. It was all working fine on my local server but when I deployed the app to heroku it started giving me errors. The error I get on the heroku logs is: File "/app/input/merge.py", line 69, in merge 2019-12-02T07:55:48.252446+00:00 app[web.1]: document.write('documents/'+name+'.docx') 2019-12-02T07:55:48.252449+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/mailmerge.py", line 120, in write 2019-12-02T07:55:48.252451+00:00 app[web.1]: with ZipFile(file, 'w', ZIP_DEFLATED) as output: I don't understand why it is giving me this error. The documents generated are saved into a folder named documents in the root directory of the project. -
Confusion about the django permission and group model?
For example I create permission like this: Permission.objects.create(name='Can add',codename='can_add',content_type=1) Now if I want to apply this permission in some view I need to use permission_required decorator like this @permission_required('app.can_add', raise_exception=True) def some_view(request): ... Here I need to exactly match the permission code_name in the decorator in order to apply the permission . But what if admin(not developer) created new permission with different codename than the codename which is used in a view? We should go manually to the code and edit the codename ? Or is there any better solutions?How can admin apply the newly created permission in the view without manually going in the code? I am thinking it from the normal user perspective, after we gave the project to the client.How can he/she manage such things? -
How can you call commands in django project?
I want to run a command on a django project but don't know how to call it from cmd I have a class Command(BaseCommand) and a handle method inside my class the python file name is assign_tasks.py. How to call this command on cmd -
django-auth-ldap failed to map the username to a DN after switching to LDAPS
I'm building a django project for my company, I had settings like below when I just use simple bind without SSL: AUTH_LDAP_SERVER_URI = 'ldap://some.example.server:389' AUTH_LDAP_BASE_DN = 'some-base-dn' AUTH_LDAP_BIND_DN = 'some-bind-dn' AUTH_LDAP_BIND_PASSWORD = 'some-password' AUTH_LDAP_USER_SEARCH = LDAPSearch( AUTH_LDAP_BASE_DN, ldap.SCOPE_SUBTREE, '(sAMAccountName=%(user)s)') and it worked perfectly. However, due to the security enhancement of our company's LDAP server, we're asked to use LDAP over SSL. So I get a certificate and change my code like this: AUTH_LDAP_GLOBAL_OPTIONS = { ldap.OPT_X_TLS_REQUIRE_CERT: True, ldap.OPT_X_TLS_DEMAND: True, ldap.OPT_REFERRALS: 0, ldap.OPT_X_TLS_CACERTFILE: '/etc/ssl/certs/mycertfile.pem' } AUTH_LDAP_SERVER_URI = 'ldaps://some.example.server:636' AUTH_LDAP_BASE_DN = 'some-base-dn' AUTH_LDAP_BIND_DN = 'some-bind-dn' AUTH_LDAP_BIND_PASSWORD = 'some-password' AUTH_LDAP_USER_SEARCH = LDAPSearch( AUTH_LDAP_BASE_DN, ldap.SCOPE_SUBTREE, '(sAMAccountName=%(user)s)') It no longer works. It keeps saying search_s(xxx) returned 0 objects: Authentication failed for : failed to map the username to a DN. But if I change the filter string for the LDAPSearch() from '(sAMAccountName=%(user)s)' to '(sAMAccountName=<hard-coded-id>)' it works. I've been trying to dig out why this happens and so far no luck. Does anyone have any idea why this is happening? Much Appreciated. -
How to raise error message if data does not exist in django table
I have my table and filter all set up and working but I wish to have an error functionality added to it in such a way that when I query a data which exist in the db, it should show me the result normally, however, when I input a qs which does not exist, it should show me a message on the table that says "record does not exist" instead of a blank table. Here is my view: from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User from django.shortcuts import render from django_tables2 import RequestConfig from django_tables2.export import TableExport from .models import Employee from .models import EmployeeFilter from .tables import EmployeeTable @login_required() def employees(request): filter = EmployeeFilter(request.GET, queryset=Employee.objects.all()) table = EmployeeTable(filter.qs) RequestConfig(request).configure(table) count = Employee.objects.all().count() male_count = Employee.objects.filter(gender__contains='Male').count() female_count = Employee.objects.filter(gender__contains='Female').count() user_count = User.objects.all().count() export_format = request.GET.get("_export", None) if TableExport.is_valid_format(export_format): exporter = TableExport(export_format, table) return exporter.response("table.{}".format("csv", "xlsx")) return render(request, "employees/employees.html", { "table": table, "filter": filter, "count": count, "male_count": male_count, "female_count": female_count, "user_count": user_count, }) -
Specific URL calling
when I call any of URL from urls.py so only the top one URL's result is returned. like I call the second URL name = 'test' or name = 'detail', it will return only the first URL name = 'list', not which I want. urlpatterns = [ url(r'',views.SchoolListView.as_view(),name = 'list'), url(r'',views.TestView.as_view(), name = 'test'), url(r'^(?P<pk>[-\w]+)/$', views.SchoolDetailView.as_view(),name = 'detail'), ] -
Can we send the HttpResponse of django `render()` in a python dictionary?
What my use case is I need whole render() data into a dictionary which will be having other key values too and finally I can return it as a normal Response. Let suppose my code is: from django.shortcuts import render def my_view(request): # View code here... return render(request, 'myapp/index.html', { 'foo': 'bar', }, content_type='application/xhtml+xml') Now what we are doing here is: render is basically returning a HttpResponse which we are returning. What I need is: Save the return response in a variable x = render(request, 'myapp/index.html', { 'foo': 'bar', }, content_type='application/xhtml+xml') Then can we save it in a dictionary to return as a Response? Like this y = {} y = {name: 'testing', render_response: x} return y -
owner is required in Django template
I have two identical views in which I am editing an existing model record Views.py def edit_product(request, pk): instance = get_object_or_404(Product, pk=pk) form = Producteditform(request.POST or None, instance=instance) if form.is_valid(): form.save() return redirect('employee:products_table') return render(request, 'packsapp/employee/employeeProductEditForm.html', {'form': form}) def edit_warehouse(request, pk): instance = get_object_or_404(Warehouse, pk=pk) form = Warehouseeditform(request.POST or None, instance=instance) if form.is_valid(): form.save() return redirect('employee:warehouse_table') return render(request, 'packsapp/employee/warehouseEditForm.html', {'form': form}) Forms.py class Producteditform(forms.ModelForm): class Meta: model = Product fields = '__all__' class Warehouseeditform(forms.ModelForm): class Meta: model = Warehouse fields = '__all__' Models.py class Warehouse(models.Model): owner = models.ForeignKey(Employee, on_delete=models.CASCADE, related_name='employee_warehouse_owner') warehouse_name = models.CharField(max_length=500, default=0) warehouse_email = models.EmailField(max_length=500, default=0) warehouse_contact = models.CharField(max_length=500, default=0) class Product(models.Model): product_id = models.IntegerField(default=0) product_quantity = models.IntegerField(default=0) product_hsn_code = models.IntegerField(default=0) product_owner = models.ForeignKey(Employee, on_delete=models.CASCADE, related_name='product_owner') When I edit a product it saves the form without any error but when i try to do the same with warehouse it refreshed without any error and was not proceeding. Then with {{ form.errors }} it says : owner This field is required. Why does it need owner in the warehouse edit form but not in the product edit form ? -
django-storages EndpointConnectionError
Sorry for the noise but I think I am missing something and I can't find my solution. When running my collectstatic, I get the following error: botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "http://localhost:1212/test/static/gis/css/ol3.css" Here is the following setup: docker-compose.yaml . . . s3server: image: scality/s3server:latest restart: unless-stopped ports: - "1212:8000" volumes: - s3data:/usr/src/app/localData - s3metadata:/usr/src/app/localMetadata environment: SCALITY_ACCESS_KEY_ID: newAccessKey SCALITY_SECRET_ACCESS_KEY: newSecretKey SSL: "FALSE" settings.py # AWS settings AWS_ACCESS_KEY_ID = env.str('AWS_ACCESS_KEY_ID') AWS_SECRET_ACCESS_KEY = env.str('AWS_SECRET_ACCESS_KEY') AWS_S3_REGION_NAME = env.str('AWS_S3_REGION_NAME') AWS_STORAGE_BUCKET_NAME = env.str('AWS_STORAGE_BUCKET_NAME') AWS_S3_ENDPOINT_URL = env.str('AWS_S3_ENDPOINT_URL') AWS_DEFAULT_ACL = None AWS_S3_OBJECT_PARAMETERS = { 'CacheControl': 'max-age=86400', } AWS_QUERYSTRING_AUTH = False # s3 static settings AWS_STATIC_LOCATION = 'static' STATIC_URL = f'http://{AWS_S3_ENDPOINT_URL}/{AWS_STATIC_LOCATION}/' STATICFILES_STORAGE = 'backend.storages.StaticStorage' # s3 media settings AWS_MEDIA_LOCATION = 'media' MEDIA_URL = f'http://{AWS_S3_ENDPOINT_URL}/{AWS_MEDIA_LOCATION}/' DEFAULT_FILE_STORAGE = 'backend.storages.PublicMediaStorage' dev.env AWS_STORAGE_BUCKET_NAME=test AWS_ACCESS_KEY_ID=newAccessKey AWS_SECRET_ACCESS_KEY=newSecretKey AWS_S3_REGION_NAME=us-east-1 AWS_S3_ENDPOINT_URL=http://localhost:1212 backend/storages.py class StaticStorage(S3Boto3Storage): location = settings.AWS_STATIC_LOCATION default_acl = "public-read" class PublicMediaStorage(S3Boto3Storage): location = settings.AWS_MEDIA_LOCATION default_acl = 'public-read' file_overwrite = False I really don't understand why as the following script works just fine: script.py import logging import boto3 from botocore.exceptions import ClientError s3_client = boto3.client( 's3', aws_access_key_id="newAccessKey", aws_secret_access_key="newSecretKey", endpoint_url='http://localhost:1212', region_name="us-east-1", ) def create_bucket(bucket_name): try: s3_client.create_bucket( Bucket=bucket_name, CreateBucketConfiguration={'LocationConstraint': "us-east-1"}, ) except ClientError as e: logging.error(e) return False return True if __name__ == "__main__": create_bucket("test", region="us-east-1") … -
AsyncWebsocketConsumer VS AsyncConsumer
I'm trying to use Channels2 in my project. it's the first time that I meet channel in Django :) I have two main useful and almost complete sources here: 1)video on youtube DJANGO CHANNELS 2 Tutorial (V2) - Real Time 2)document of Channel in Read The Doc as I don't know what will happen in the future of my code I need you to help me choose using between AsyncWebsocketConsumer as mentioned in source #1, or AsyncConsumer that is used in source # 2 for starting Django channel app that including by this way: from channels.generic.websocket import AsyncWebsocketConsumer from channels.consumer import AsyncConsumer explanation: class AsyncConsumer: """ Base consumer class. Implements the ASGI application spec, and adds on channel layer management and routing of events to named methods based on their type. """ class AsyncWebsocketConsumer(AsyncConsumer): """ Base WebSocket consumer, async version. Provides a general encapsulation for the WebSocket handling model that other applications can build on. """ my goal of using channel: trying to integrated real-time chat, notification/alert/transfer_data to the clients for the specific situations. (now the app working without Websocket with DRF) and if you have any suggestions, ideas or notices I will be very happy to listen.thank you so … -
Django-2.2 NoReverseMatch error. Cannot redirect to next page
After submission of a create form in my web app it should redirect in to a single page where it displays the new product that is entered. instead of that, it shows : Reverse for 'category' with keyword arguments '{'pk': UUID('e3ec4273-22c9-450f-87c9-d12973dce3c1')}' not found. 1 pattern(s) tried: ['app/products/category/<int:pk>'] views.py def create_category(request): if request.method=='POST': form = CategoryForm(request.POST,request.FILES) if form.is_valid(): data = form.save(commit=False) data.creator = request.user data.updater = request.user data.auto_id = get_auto_id(ProductCategory) data.save() return HttpResponseRedirect(reverse('products:category',kwargs={"pk":data.pk})) else: ... else: ... def category(request,pk): instance = get_object_or_404(ProductCategory.objects.filter(pk=pk)) context = { 'title': "Category : " + instance.name, 'instance' : instance, } return render(request,'products/category.html',context) urls.py from django.urls import path from . import views app_name = 'products' urlpatterns = [ path('categories',views.categories,name='categories'), path('category/create',views.create_category,name='create_category'), path('category/<int:pk>',views.category,name='category'), path('category/edit/<int:pk>',views.edit_category,name='edit_category'), path('category/delete/<int:pk>',views.delete_category,name='delete_category'), ] Th thing is the form is submitted and the values are added to database. But it doesn't move to the next step. I am new to django 2 so not very sure on how to pass pk in urls/path -
Page is not showing on ID
In Django when I click on the link which returns an id but the page is not showing in return. here is url, url(r'^(?P<pk>[-\w]+)/$', views.SchoolDetailView.as_view(),name = 'detail') View.py class SchoolDetailView(DetailView): context_object_name = 'school_detail' model = models.School template_name = 'basic_app/school_detail.html' HTML view {% for school in schools %} <h2><li><a href="{{school.id}}">{{school.name}}</a></li></h2> {% endfor %} -
Django 2.2 : How to change verbose_name of default auth app "Authentication and Authorization"?
How can change verbose_name of default auth app in Django Admin, by default it's showing Authentication and Authorization. I just want rename this with Staff Management? Thanks