0

I started make a website for my school project, i use Django Frameworks i want to make my homepage website, i already have html file, then what should i do to make Django read my homepage enter image description here this is my urls.py on main folder

urlpatterns = [
    path('admin/', admin.site.urls),
    path('katalog/', include('katalog.urls')),
    path('', ) #what should i write here?
]
2
  • In katalog folder, create urls.py and import your view function(if created) which renders html file and pass inside path function. Commented May 21, 2020 at 14:49
  • Simple: path('some-path/', views.path_function) Commented May 21, 2020 at 15:00

1 Answer 1

1

django doc: https://docs.djangoproject.com/en/3.0/topics/http/urls/#example, it offers the below example

from . import views

urlpatterns = [
    path('articles/2003/', views.special_case_2003),

You have to create in your apps views.py file a FBV or CBV, the easiest is a FBV like below:

def someview(request):
    context={}#if you want to add objects to the front end
    return render(request, 'yourhtmlfile', context)

and then import it in your urls.py:

from . import views

urlpatterns = [
    path('home/', views.someview),
Sign up to request clarification or add additional context in comments.

1 Comment

very easily you wrote 'yourhtmlfile' without describing its important details

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.