datamade / how-to

📚 Doing all sorts of things, the DataMade way
MIT License
81 stars 12 forks source link

Updates new-django-app template, connects #227 #235

Closed hancush closed 2 years ago

hancush commented 2 years ago

Overview

This PR implements the changes enumerated in #227:

Testing Instructions

smcalilly commented 2 years ago

@hancush I'm not seeing the <meta name="robots" content="all"> after making the change.

You wrote

In your docker-compose.yml file, add the following environment variable to your app service: DJANGO_ALLOW_SEARCH_INDEXING: "on"

Does DJANGO_ALLOW_SEARCH_INDEXING need to equal on or True? I've tried both and neither work. Could it be something to do with the cache? I've tried requesting in a private browser, hard refresh, etc. But I still get noindex.

Here's my docker-compose.yml:

services:
  app:
    image: test
    container_name: test
    build: .
    # Allow container to be attached to, e.g., to access the pdb shell
    stdin_open: true
    tty: true
    ports:
      # Map ports on your computer to ports on your container. This allows you,
      # e.g., to visit your containerized application in a browser on your
      # computer.
      - 8000:8000
    depends_on:
      postgres:
        condition: service_healthy
    volumes:
      # Mount the development directory as a volume into the container, so
      # Docker automatically recognizes your changes.
      - .:/app
      # Mount the node_modules directory so that our local mount doesn't
      # clobber it.
      - test-node-modules:/app/node_modules
    environment:
      DJANGO_SECRET_KEY: reallysupersecret
      DJANGO_MANAGEPY_MIGRATE: "on"
      DJANGO_ALLOW_SEARCH_INDEXING: "True"
    entrypoint: /app/docker-entrypoint.sh
    command: python manage.py runserver 0.0.0.0:8000

and the source

Screen Shot 2021-11-18 at 11 41 19 AM

:

smcalilly commented 2 years ago

also, with that code, in my settings.py, i print out the variable:

print('allow search indexing')
print(ALLOW_SEARCH_INDEXING)

and this prints in my console:

allow search indexing
True
hancush commented 2 years ago

@smcalilly Great catch, it should be True. Thanks for testing that. I'll check out why your corrected setting didn't do the right thing.

hancush commented 2 years ago

@smcalilly I just added a missing JS map that was preventing my build but otherwise, I was able to produce the desired behavior following the testing instructions. Can you try again, being sure to stop, remove, and restart your app container after you change the value of "DJANGO_ALLOW_SEARCH_INDEXING" in your Compose file? (Changes to env vars are only recognized when a container is created.)