What Are Django URLs?

Search for a command to run...

No comments yet. Be the first to comment.
This is a basic Django tutorial in which we will create an Authentication App, from scratch in Django 2.0 and Learn the Fundamental concepts of Django Framework.
In this section, we will learn what is Admin in Django and how to create a superuser account for your website and access the admin interface from the browser. So in our previous section, we have successfully created our URLs. Let's create a Post mode...
You've done it. I've done it. We've all done it.

Your AI Agent Has Amnesia. ByteRover Fixes It — Without Vectors Let's see how to built a customer support agent that remembers everything — using plain markdown files, BM25 search, zero embeddings, a

My GenAI cohort kicked off today, and what a first day! Right away we were reminded that AI isn’t magic — at its core, models like Generative Pretrained Transformers (GPT) are doing one simple thing:

Hello Folks👋, I Recently got Graduated🎓 in 2020, yep in the Pandemic. We all hit very hard by this Corona Pandemic and we all got stuck at home for very long. We all realize the Importance of Socializing, Fitness (Physically as well Mentally), Diet...

So after learning the basic commands of git in our previous section, let's see Git in action. If you already have a project to track your files then you can skip this section and if not then continue. Initializing a Repository from Non-existing Dire...

In this section, we will learn what are URLs in Django and how to create them and link them with the view functions that we have created in views.py file.
So in our previous section, we have successfully created our Templates. Let's create URLs for each view Function which is the last step to render our HTML templates to display them in the browser.
We want to access the Signup view via a URL. Django has its own way of URL mapping and it's done by editing your project urls.py file (social/urls.py).
When a user makes a request for a page on your web app, Django controller takes over to look for the corresponding view via the url.py file, and then return the HTML response or a 404 not found error, if not found. In url.py, the most important thing is the "urlpatterns" tuple. It's where you define the mapping between URLs and views. A mapping is a tuple in URL patterns, the url.py file looks like -
from django.contrib import admin
from django.urls import path
from django.conf.urls import url
from account import views as acccount_views
urlpatterns = [
path('admin/', admin.site.urls),
url(r"^$", acccount_views.IndexView.as_view(), name="index"),
url(r"^signup/$", acccount_views.signup, name="signup"),
]
add this line at the bottom of social/settings.py
LOGIN_REDIRECT_URL = 'index'
Now run the following command where the manage.py file is located:
python manage.py runserver
goto http://127.0.0.1:8000/
You will see the home page click on the signup button to go to the Signup page.

Fill the form and if everything is alright then you will be redirected to the home page as logged-in user.

Congratulation! We have successfully implemented the signup view in Django.