Open auphof opened 7 months ago
@auphof - I now updated the blog with a section 3a where I explain about the templates and their corresponding code that will be required to bring up the landing page. Hope this helps bring up the landing page. let me know otherwise.
@SambhaviPD yes I can confirm brings up the landing page, I have some small adjustments to make work,
I used following scripts to create template structure
# Create the initial dir layout
# in the top level dir of the project run the following
mkdir -p mybookshelf/templates/{base,registration,book}
# create the initial template files
touch mybookshelf/templates/base/base.html \
mybookshelf/templates/base/navbar.html \
mybookshelf/templates/registration/login.html \
mybookshelf/templates/registration/logout.html \
mybookshelf/templates/registration/register.html \
mybookshelf/templates/book/index.html
# Now populate the files as following described in step 3a
and the following to retrieve static files from your repo
# Create the initial dir layout
mkdir -p mybookshelf/static/{css,js,images}
# Download the image from my repo
curl -L -o mybookshelf/static/images/bookshelf.png "https://github.com/SambhaviPD/mygoodreads/blob/main/mybookshelf/mybookshelf/static/images/bookshelf.png?raw=true"
# Download the main.css from my repo
curl -L -o mybookshelf/static/css/main.css "https://github.com/SambhaviPD/mygoodreads/blob/main/mybookshelf/mybookshelf/static/css/main.css?raw=true"
Then the paragraph and code for registration should have a filename
the navbar.html
needs to have the search removed as its not implemented yet. else i get the following error django.urls.exceptions.NoReverseMatch: Reverse for 'search' not found. 'search' is not a valid view function or pattern name.
doing the following changes fixed it and i get a landing page served.
and lastly I used Path
in defining TEMPLATES
in settings.base.py
as apposed to os.join
. Following the django pattern and suppress another import
'DIRS': [Path(BASE_DIR) / 'templates'],
I am just traveling so hope to run through the remainder of your blog to implement the HTMX while inflight
@auphof - Thanks a lot for the finer points. I modified section 3a to reflect those (removing search link from navbar.html and to mention the name of register.html). Yep, I generally use PATH, not sure why I used os.join, anyways I just let it be.
When time permits, I shall follow the rest of steps myself in a new workspace and see if anything will be required in the blog. I'm guessing it will be towards the end 🙄 Feel free to add your observations too.
Firstly, thank you for a good subject on the blog post https://hellosambhavi.com/django-htmx with good easy to follow style:
I have followed through step 4 and some minor issues, resolved with thinking and comparing with this repo managed to fix them. I am a relative NOOB to Django and definitely a NOOB to HTMX, so this is a great exercise, so am willing to contribute
After Step 4 I was not able to get a landing page like you display in the blog. The Step on setting up the templates seems to be missing, I was able to
makemigrations
andmigrate
butrunserver
generated errors of templates missing. Is there something I simply missed ?To get it somewhat working, I copied this repo's templates had to remove some template lines for functions not yet implemented by step4 ie (HTMX) and adjusted
settings.base.py
adding