Reputation: 75
Hey guys so I been looking into making a site and was going to learn php for it but after a lot of research I saw how I can use Django for the backend of the site so I already started creating a site with HTML/css/js before I decide to use Django. Is there any possible way you can connect HTML/css to Django or do I need to re write everything in Django. I did look at some tutorials and saw how all the HTML was in django and I also did try looking it up too but couldn't find the right answer I'm looking for. If anyone could tell me I'll be very appreciated!! Thanks!
Upvotes: 0
Views: 1760
Reputation: 5428
All you need to move from your old project to new one created with django-admin startproject are:
After it you need to replace old href attributes to something like <a href="{% url "Index" %}">
and insert correct paths (includes static url) of css/img/js files to hmtl
Upvotes: 1
Reputation: 707
You can connect it. Django is a backend framework, all it does in the frontend is print data.
Read about templates in Django. Templates are basically html files with dynamic content.
Take the template my_template.html:
My first name is {{ first_name }}.
You render it like this:
from django.template.loader import render_to_string
rendered = render_to_string('my_template.html', {'first_name': 'Cesar'})
It will output:
My first name is Cesar.
Make sure to read the whole intro tutorial to Django.
Note: There are many ways to use a template, this was just a little example.
Upvotes: 3