Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Get model from multiple apps at once using apps.get_model
I am creating an API that can access multiple apps in a single project and get model from from all of these apps for that I tried this: def get(self, request, **kwargs): m = request.GET['model'] depth = request.GET['depth'] print("model") model = apps.get_model('masters', str(m)) obj1 = model.objects.all() It is working fine when I wanna import model from a single app but in my project I have multiple apps linked together and for this I tried: model = apps.get_model(['masters','dockets'], str(m)) but got an error TypeError: unhashable type: 'list'. apps.get_model doesn't take list but is there any workaround to this? -
In Django version(4.1.4) I am not able to access CSS file I m beginner, searched in google tried everything but still not able to solve this problem
setting.py static file congfigured in setting.py STATIC_URL = 'static/' STATICFILES_DIRS = [ BASE_DIR / 'Ecommerce/static/css' ] store.html {% load static %} <link rel="stylesheet" type="text/css" href="{% static 'css/main.css' %}"> I am creating project Ecommerce with python and django and want to use external css, image ,JS in project but my css in not working i tryed googling it but nothing helped me i am using django 4.1.4 version -
When adding a record in django admin, when a field is selected, the other field comes automatically
In order to make the problem easier to understand, I am writing the codes as short as possible here. models.py: ---------- class Room(models.Model): room_no = models.CharField() class Unit(models.Model): unit_name = models.CharField() room = models.ManyToManyField(Room, related_name='roomunit') class Employee(models.Model): employee_name = models.CharField() unit = models.ForeignKey(Unit) room = models.ForeignKey(Room) admin.py: --------- class EmployeeAdmin(admin.ModelAdmin): list_display('employee_name', 'unit', 'room',) class RoomAdmin(admin.ModelAdmin): list_display=('room_no',) class UnitAdmin(admin.ModelAdmin): list_display=('unit_name', 'roomno',) def roomno(self,obj): r = Room.objects.get(roomunit=obj) return r admin.site.register(Employee, EmployeeAdmin) admin.site.register(Unit, UnitAdmin) admin.site.register(Room, RoomAdmin) Screenshot of the form The unit_name and room_no data have already been saved. There is ManyToMany relation between Unit and Room. Screenshot of Employee add form. This is what i want to do: When I select unit_name, I want the room_no field to come automatically according to the unit_name. -
Custom Authentication in Django Rest Framework
I have a django rest framework application with custom authentication scheme implemented. Now I want to allow external app call some methods of my application. There's an endpoint for external app to login /external-app-login which implemented like this: class ExternalAppLoginView(views.APIView): def post(self, request): if request.data.get('username') == EXTERNAL_APP_USER_NAME and request.data.get('password') == EXTERNAL_APP_PASSWORD: user = models.User.objects.get(username=username) login(request, user) return http.HttpResponse(status=200) return http.HttpResponse(status=401) Now I want to add authentication. I implemented it like this: class ExternalAppAuthentication(authentication.SessionAuthentication): def authenticate(self, request): return super().authenticate(request) But authentication fails all the time. What is the correct way to do it? I want to store login/password of external app in variables in application, not in database. -
This problem occured wile I was running my final solution in github . There is some minimal settings problem
I am working in github and while running it in final stage i get this error which I am not able to resolve . Origin checking failed - https://gagandeep141-congenial-xylophone-946j465ww4hj4g-8000.preview.app.github.dev does not match any trusted origins. I tried changing settings and expecting the solution -
How to install django-recaptcha in cpanel?
I'm tring to install django-recaptcha in cpanel but so error Unable to find from captcha.fields import CaptchaField Here is my code in django form.py from django import forms from captcha.fields import ReCaptchaField from captcha.widgets import ReCaptchaV2Checkbox class RequestForm(forms.Form): captcha = ReCaptchaField(widget=ReCaptchaV2Checkbox()) views.py from django.views.generic import FormView # Create your views here. class HomePage(FormView, ): template_name = 'AppForm/homepage.html' form_class = RequestForm def post(self, request, **kwargs): if request.method != 'POST': return redirect('/error') else: form = RequestForm(request.POST) if form.is_valid(): recaptcha_response = request.POST.get('g-recaptcha-response') url = 'https://www.google.com/recaptcha/api/siteverify' values = { 'secret' : settings.RECAPTCHA_PRIVATE_KEY, 'response' : recaptcha_response } data = urllib.parse.urlencode(values).encode("utf-8") req = urllib.request.Request(url, data) response = urllib.request.urlopen(req) result = json.load(response) print(result) if result['success']: return redirect('/thankyou') else: return redirect('/error') else: return redirect('/error') setting.py INSTALLED_APPS = [ 'captcha', ... ] RECAPTCHA_PUBLIC_KEY = '6LdfgjhkgdsfhghjdfAAAPf1mAJmKucssbD5QMha09NT' RECAPTCHA_PRIVATE_KEY = '6Ldfgjhkg3kgAA83DFJwdkjhfkjdkshjkfFR1hXqmN8q' SILENCED_SYSTEM_CHECKS = ['captcha.recaptcha_test_key_error'] In Local system it run, but in cpanel unable to install django-recaptcha Unable to find from captcha.fields import CaptchaField -
ForeignKey form search via Text as opposed to Drop-Down - Django
I am working on a flight booking website on Django. In my models.py, I have two models; one called Airport and one called Flight. The Flight class has two variable's called 'Departure' and 'Destination' which inherit from from the Airport class via ForeignKey. Ultimatelly, I want the user to be able to select a departing airport and a destination airport. Now,I am limited to the drop-down option when trying to querry airports. Can someone please explain a way to go about editing my form to where a user can type in an Airport name and the stored values will appear based on the users search. (ex: A user enters "los " and "Los Angeles" appears and can be selected. Models.py from django.db import models class Airport(models.Model): city = models.CharField(max_length=50) code = models.CharField(max_length=3) def __str__(self): return f"{self.city} ({self.code})" class Flight(models.Model): origin = models.ForeignKey(Airport, on_delete=models.CASCADE, related_name="origin") destination = models.ForeignKey(Airport, on_delete=models.CASCADE, related_name="destination") length = models.IntegerField(null=False) def __str__(self): return f"{self.id} - {self.origin} to {self.destination}" Below, in my forms.py file; I have added a widget dict which has allowed me to now enter in a value to the form as opposed to having a drop down menu. However, it does not suggest results based on … -
DJANGO - How To Use Regex for Thesis Author Format?
I have one CharField for author/s but I want the input to follow certain format. For example: Cruz, R. (for only one author) Cruz, R. and Gray, A. (for two author) Cruz, R. and et. al. (for three or more author) Here is my code in forms.py to validate the format, but it doesn't seem to be working properly especially when I add this '|' sign for or condition: def clean_author(self): pattern = '[A-Za-z][,][A-Z]{1}[.] | [A-Za-z][,][A-Z]{1}[.][and][A-Za-z][,][A-Z]{1}[.] | [A-Za-z][,][A-Z]{1,2}[.][" et. al."]' get_author = self.cleaned_data['author'] if not re.search(pattern, get_author): raise ValidationError("Invalid author format has been detected") return get_author I'm new to regex so I don't really have that much knowledge on it. -
Why does manage.py runserver showing this instead of server link?
Started this project 2 days ago, yesterday I was trying to run instead it was showing this: (env.0.5) D:\Web\ecom\mosh>python manage.py runserver Watching for file changes with StatReloader Exception in thread django-main-thread: Traceback (most recent call last): File "c:\users\shuvo\appdata\local\programs\python\python38\lib\threading.py", line 932, in _bootstrap_inner self.run() File "c:\users\shuvo\appdata\local\programs\python\python38\lib\threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "D:\Web\ecom\mosh\env.0.5\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "D:\Web\ecom\mosh\env.0.5\lib\site-packages\django\core\management\commands\runserver.py", line 125, in inner_run autoreload.raise_last_exception() File "D:\Web\ecom\mosh\env.0.5\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception raise _exception[1] File "D:\Web\ecom\mosh\env.0.5\lib\site-packages\django\core\management\__init__.py", line 398, in execute autoreload.check_errors(django.setup)() File "D:\Web\ecom\mosh\env.0.5\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "D:\Web\ecom\mosh\env.0.5\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "D:\Web\ecom\mosh\env.0.5\lib\site-packages\django\apps\registry.py", line 91, in populate app_config = AppConfig.create(entry) File "D:\Web\ecom\mosh\env.0.5\lib\site-packages\django\apps\config.py", line 193, in create import_module(entry) File "c:\users\shuvo\appdata\local\programs\python\python38\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module named 'tags' Traceback (most recent call last): File "manage.py", line 22, in <module> main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "D:\Web\ecom\mosh\env.0.5\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line utility.execute() File "D:\Web\ecom\mosh\env.0.5\lib\site-packages\django\core\management\__init__.py", line 440, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "D:\Web\ecom\mosh\env.0.5\lib\site-packages\django\core\management\base.py", line 402, in run_from_argv self.execute(*args, **cmd_options) File "D:\Web\ecom\mosh\env.0.5\lib\site-packages\django\core\management\commands\runserver.py", line 74, in execute super().execute(*args, **options) File "D:\Web\ecom\mosh\env.0.5\lib\site-packages\django\core\management\base.py", line … -
django-tinymce convert url option do not work
TINYMCE_DEFAULT_CONFIG = { 'convert_urls' : False, 'relative_urls' : False, } Even with the above settings applied, tinymce still outputs files in the format ../../../../../../../static/images/example.png, not /static/images/example.png. Get the path. Changing convert_urls setting is not possible in django settings.py? -
Configure static files for django project live on ubuntu
I've finally got my project up and running after painful sleepless nights but I now can't get my images to show on my site. I managed to get my css to show but nothing else. Ill post as many screen shots and snippets as I can to see if anyone can help me. Info for what ive done so far: I've given my self permissions on static and static files folder with chmod commands and enabled it so I can use var/www/ roots. With the commands I've done and configurations I've set I can no longer collect static due to an error given: PermissionError: [Errno 13] Permission denied: '/staticfiles' Also if i open images that i upload to my site in a new window the extension shows as mysite.com/images/images/test4.jpg Current folder mapping in settings Current folder mapping in ubuntu /var/www/ Django Roots and URLS MEDIA_URL = '/images/' MEDIA_ROOT = os.path.join(BASE_DIR, '/images') STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, '/staticfiles') CKEDITOR_UPLOAD_PATH = "uploads/" STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static') ] sites-enabled settings server { listen 80; server_name ive put my ip here; location = /favicon.ico { access_log off; log_not_found off; } location /staticfiles/ { root /var/www; } location / { include proxy_params; proxy_pass … -
libcurl link-time version (7.76.1) is older than compile-time version (7.86.0)
Whenever I start celery worker in my django project, it fails to start with the following error: "Unrecoverable error: ImportError('The curl client requires the pycurl library.') I have visited all the github issues and questions posted on stackoverflow but unable to pinpoint this issue. My pycurl installation is done successfully and if I run python -c 'import pycurl' && echo "Success". It returns me success but whenever I run celery worker it still gives me the pycurl error. I was expecting celery to run successfully but in return I get an import error. If I go to the kombu package which is installed and try to print traceback value then it outputs: pycurl: libcurl link-time version (7.76.1) is older than compile-time version (7.86.0) brew info openssl output is as follow: openssl@3 is keg-only, which means it was not symlinked into /usr/local, because macOS provides LibreSSL. If you need to have openssl@3 first in your PATH, run: echo 'export PATH="/usr/local/opt/openssl@3/bin:$PATH"' >> /Users/<>/.bash_profile For compilers to find openssl@3 you may need to set: export LDFLAGS="-L/usr/local/opt/openssl@3/lib" export CPPFLAGS="-I/usr/local/opt/openssl@3/include" For pkg-config to find openssl@3 you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig" brew info curl output is as follows: curl is keg-only, which means it … -
Simple User to User Rating function in Django
I am trying to add a field in my Django Project that will enable users to leave a review on another user's profile page. I understand that I need two ForeignKeys in my models.py, one for the user that will write the review and another for the user's profile where the review will be written on. I tried adding a Profile FK but I'm really not sure how to go about this or even what to include under the Profile class. This is what I tried so far but I am getting an error that says: ValueError at /profile/7/ Cannot assign "<User: username>": "Review.profile" must be a "Profile" instance I also need help with my views.py because as I play around the error message, I was able to finally post the review but it appears on the User's profile who wrote the review instead of the actual profile that I wanted to wrote it to. I am new to coding and tried really hard to read the django documentation about it but I can't really get past this one. models.py: class User(AbstractUser): name = models.CharField(max_length=200, null=True) email = models.EmailField(unique=True, default='') avatar = models.ImageField(null=True, default="defaultDp.jpg") location = models.CharField(max_length=200, null=True) class Profile(models.Model): … -
403 Forbidden CSRF Verification Failed React Django
Good day, i have been trying to set the csrftoken, so my login would be safe. I have followed the instructions of this stackoverflow question, but had no luck. I have done some experimenting by setting SESSION_COOKIE_SECURE to False and setting CSRF_COOKIE_SECURE to False. I've tried also tried different types of naming the X-CSRFToken in the headers to csrftoken and X-CSRFTOKEN but none of them worked. Any suggestions? views.py @ensure_csrf_cookie def login_view(request): if request.method == "POST": data = json.loads(request.body) # Attempt to sign user in username = data.get("username") password = data.get("password") settings.py SESSION_COOKIE_SECURE = True CSRF_COOKIE_SECURE=True login.js function getCookie(name) { let cookieValue = null; if (document.cookie && document.cookie !== '') { const cookies = document.cookie.split(';'); for (let i = 0; i < cookies.length; i++) { const cookie = cookies[i].trim(); // Does this cookie string begin with the name we want? if (cookie.substring(0, name.length + 1) === (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } const csrftoken = getCookie('csrftoken'); fetch('/api/login', { credentials:'include', method: 'POST', headers: { 'X-CSRFToken': csrftoken, }, body: JSON.stringify({ username: username, password: password }) }) <form onSubmit={handleSubmit}> <CSRFToken/> </form> csrftoken.js import React from 'react'; function getCookie(name) { let cookieValue = null; … -
TemplateSyntaxError at /bag/ 'bag_tools' is not a registered tag library
I know this has been asked before but none of the suggested solutions have worked for me. I have a main project directory, in this is a file called template tags, which includes the file bag_tools.py and and an init.py file. The app 'bag' is included in installed apps in settings of the main project directory. The workspace has been restarted several times. All migrations have been made. Im stumped! Any suggestions? -
Django ORM: migrate composite foreign key from 2 to latest version of django
Have limited experience with django orm, there is a project with legacy django version (2.2) and I need to migrate it to the latest one (4.1). Cannot understand, what is modern concept of something called CompositeForeignKey and CompositeOneToOneField, which was before imported from 3d party module django-composite-foreignkey (this module doesn't support django orm above version 2). So what I need is to create foreign key of multiple fields to another table. Below is example of existing definition of such composite key. from compositefk.fields import CompositeForeignKey ... # my model... study_country = CompositeForeignKey( 'StudyCountry', on_delete=models.DO_NOTHING, to_fields={'study': 'study', 'country': 'country'} ) Is there any simple way how to migrate such a code to new django orm? p.s. any raw SQL cannot be a solution in my case for specific reasons. -
Django Large File Serving
I am trying to make an app like youtube, where I need to serve huge number of files and each Video file size can be large [ 50MB or 1GB, or 2GB or more]. I am using SQLite DataBase. How can I serve these files in an efficient way? models.py class VideoContent(models.Model): contenttitle = models.CharField(max_length=300, blank=False) file = models.FileField(blank=False, verbose_name='Your Video Content', validators=[FileExtensionValidator( allowed_extensions=['MOV', 'avi', 'mp4', 'webm', 'mkv'] )]) uploaded = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) def __str__(self) -> str: return self.contenttitle.title() ** views.py ** class VideoContents(ListView): template_name = 'contents/index.html' context_object_name = 'videos' ordering = '-uploaded' model = VideoContent # def get_queryset(self): # return VideoContent.objects.all() -
Is there a way to pick variable name for msgid in django translation?
I am currently relying on django translations and I am curious to know if there is a way to pick msgid for translation based on a variable name For instance: name = _("Some Name") msgid "name" msgstr "Some Name" I want the msgid to match the variable name automatically when django picks up the variable but cannot find a way through the documentation. -
Django Signals not triggering when only using apps.py
Here I want to create a Datalog when a new Customer create an account. I want to trigger the Datalog event and save the relevant information into the Datalog table. apps.py (I could write in signals.py but I prefer to write it into directly app.py) from django.db.models.signals import post_save, post_delete from django.dispatch import receiver from .models import DataLog class LogAPIconfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'myapp' def ready(self): @receiver(post_save, sender=DataLog) def log_save_actioner(sender, created,instance, **kwargs): print("signal is sent to heatmap") action = 'create' if created else 'update' Datalog.objects.create( heatmap_type = instance.heatmap_type, status = instance.status, action = action, sender_table = sender.__name__, timestamp = instance.timestamp ) models.py class Customer(models.Model): Customer_name = models.ForeignKey(User, unique=True, primary_key=True, related_name="Customer_name") Customer_type = models.CharField(max_length=255) class Datalog(models.Model): Customer_name = models.ForeignKey(Customer, on_delete=models.CASCADE) status = models.CharField(max_length=255) comment = models.TextField(null=True, blank=True) followUpDate = models.DateTimeField(auto_now_add=True) class Meta: ordering = ['-followUpDate'] def __str__(self): return str(self.status) settings.py INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "rest_framework", "rest_framework.authtoken", "corsheaders", "django_auth_adfs", "django_filters", 'myapp.apps.LogAPIconfig', ] When I implemented this I got following error message in the terminal django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. after some search I think this is somewhat related with importing Datalog table. I want to know Is this something related because of I'm not using … -
Django - Static Files not loading
I am trying to make a Django application, and because I am very new to the process, I have been having a few issues doing it without tutorials, I have used Google and SO the whole way so far, here is my error, I am trying to load my static files, when i do that i get the following error: So upon further research, I have entered the correct information as requested, please see my: settings.py CLOUDINARY_STORAGE = { 'cloud_name': 'xxx', 'api_key': 'xxx', 'api_secret': 'xxx', } # STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/' STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'),] STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATICFILES_STORAGE = 'cloudinary_storage.storage.StaticHashedCloudinaryStorage' Then when I add it to the index.html template, I have done so like this: index.html {% load static %} <!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>Landing Page</title> {% comment %} Bootstrap {% endcomment %} <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"> </script> <link rel="stylesheet" href="{% static 'css/style.css' %}"> <script>alert('this works');</script> </head> I know I should run a collect static command at some point so when I do that i get the following error: which is just the same issue on the rendered template: Please … -
django / filter the fields of a form ane have the error 'int' object has no attribute '_meta'
on django and I have a small problem of novice if someone can guide me I will be grateful I use django-cities-light for a travel website and I would like to filter the cities in the fields ville_de_depart and ville_destination in the newBookingForm by trip.depart and trip.destination. I tried to pass the trip object in the instance of newBookingForm i override the init and I took the value of the depart and destination, I succeeded in filtering the fields but I could no longer save the newBooking, the view redirect to the alltrip page with no error but no new booking in the database I tried to replace the trip by the slug which is the same value as the id and it shows me this error 'int' object has no attribute '_meta' I searched a lot and it really tired me I can't find a solution to filter the tow fields without having any issue if anyone can help me I will be grateful models.py class trip(models.Model): depart = models.ForeignKey(default='',to=Country,on_delete=models.CASCADE,related_name='depart') destination = models.ForeignKey(default='',to=Country,on_delete=models.CASCADE) date_de_depart = models.DateField(default='') prix_kg = models.PositiveIntegerField(default='') collecte = models.BooleanField(default=False,null=False,help_text='' ) creation_date = models.DateTimeField(auto_now=True) author = models.ForeignKey(to=settings.AUTH_USER_MODEL,on_delete=models.CASCADE,default='') slug = models.SlugField(max_length=100, default='' ) #jouter slug def save(self, *args … -
How to return the user ID in HTTP response after a user log in with DRF token authentification?
My application has a /login endpoint where users can enter their login information, and after a user has been authenticated I would like to display a DRF view based on it's user ID as a parameter in the URL. What is the best way to do that ? Shall I need to include the user ID into the HTTP response and if so, how to do that ? This is how the login view and serializer look like : view.py class LogInView(TokenObtainPairView): serializer_class = LogInSerializer serializer.py class LogInSerializer(TokenObtainPairSerializer): @classmethod def get_token(cls, user): token = super().get_token(user) user_data = ManagerSerializer(user).data for key, value in user_data.items(): if key != 'id': token[key] = value return token The view I would like to display after the user login looks like this : view.py class AccountDetails(RetrieveAPIView): serializer_class = AccountSerializer queryset = Account.objects.all() urls.py router = routers.DefaultRouter() urlpatterns = [ path('', include(router.urls)), path('account/<pk>', AccountDetails.as_view()), ] -
docker endpoint for "default" not found
i did clone a project and in first step when i tried to start container,i did run windows cmd in my project root and i type this command: docker-compose up --build and this massege showen to me: docker endpoint for "default" not found. i'll be more than happy if somebody help me. when i write this command for first time i hade an internet problem it got pause, in second time started to download something then this massege printed. i tried to delete my old Containers, and also i try with my VPN on and off, and restart docker in powershell. -
"proxy_pass" directive is duplicate
Getting the error: nginx: [emerg] "proxy_pass" directive is duplicate in /etc/nginx/sites-enabled/mhprints:12 nginx: configuration file /etc/nginx/nginx.conf test failed when trying to run my django project on nginx and gunicorn. my settings in folder error points to: server { listen 80; server_name 194.146.49.249; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /home/dave/mhprints; } location / { include proxy_params; proxy_pass http://unix:/run/gunicorn.sock; } } Can't find a fix, hoping somebody knows on here. -
Question for starting django web (beginner))
I have experienced problem in creating my own page on django. I follow the tutorial but get the different results. The error is page not found and Using the URLconf defined in djangonautic.urls, Django tried these URL patterns, in this order: admin/ about/ ^$ The empty path didn’t match any of these.It would be appreciate if someone can help me: urls.py from django.contrib import admin from django.urls import path from. import views urlpatterns = [ path(r'^admin/', admin.site.urls), path(r'^about/$', views.about), path(r'^$', views.homepage), path(r'^$', views.index), ] views.py from django.http import HttpResponse from django.shortcuts import render def about(request): return HttpResponse('my name is Jacky') def homepage(request): return HttpResponse('welcome home') def index(request): return HttpResponse("Hello, world I am the king") The web page will be display normally, no 404 is found