Coder Social home page Coder Social logo

wsvincent / djangoforprofessionals Goto Github PK

View Code? Open in Web Editor NEW
624.0 27.0 266.0 2.48 MB

Source code for Django for Professionals 4.0

Home Page: https://djangoforprofessionals.com/

License: MIT License

Dockerfile 0.18% Python 10.17% HTML 2.17% CSS 39.98% JavaScript 47.51%
django python django-tutorial

djangoforprofessionals's Introduction

djangoforprofessionals's People

Contributors

wsvincent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

djangoforprofessionals's Issues

A question relating to resolve()

def test_homepage_url_resolves_homepageview(self):
    view = resolve('/')
    self.assertEqual(view.func.__name__, HomePageView.as_view().__name__)

I've just finished the 4th chapter and a question arose in my mind. Could any one explain step-by-step what happens when we pass in '/' as an argument to resolve()? I'm not a native speaker nor do I have experience in coding though in web terms "resolver" is a kind of an interpreter URLs to IP addresses. I've tried to print the view and here's what I got:
ResolverMatch(func=pages.views.HomePageView, args=(), kwargs={}, url_name=home, app_names=[], namespaces=[], route=)

I figured out what we do next in self.assertEqual, but it's obscure how we get HomePageView from '/". Does it look for the path in pages.urls.py and then get the view of the path? It's like a reverse() method interpreting name='home' to the path.

Thanks for any assistance.

python: can't open file '/code/manage.py'

Unable to get the docker running, followed all the steps. Using windows

$ docker-compose up Recreating code_web_1 ... done Attaching to code_web_1 web_1 | python: can't open file '/code/manage.py': [Errno 2] No such file or directory code_web_1 exited with code 2

Heroku Django media not loading

Django for Professional is a great book.
Only three things I would have added are:

  • a related_name explanation (around page 224)
  • a mention to django_cleanup in ch 12 File/Image uploads
  • the automatic creation in Heroku of the config var DATABASE_URL that explains your settings of DATABASE in settings.py.

However, a big thing is missing: Heroku does not allow to handle media as explained here: https://stackoverflow.com/questions/61894188/heroku-django-images-not-loading
I think you should at least mention the fact that there is 0MB in Heroku for your media.

PS: also a pdf-version-after-buy of the book would be cool as it would help with quick search of specific things (e.g. DATABASE_URL.....)

Chapter 3 pg45 - issue with Volumes in Docker-Compose.yml

Below is the problem if I try to "docker-compose up -d --build":
"Named volume "postres_data:/var/lib/postgresql/data:rw" is used in service "db" but no declaration was found in the volumes section"

Have tried the suggested solutions but no luck. Please help

Chapter 8 ENV SECRETE_KEY in docker-compose

It seems that some characters have problems being paste-in to the docker-compose file. Searched around and people either have to use ENV in Dockerfile or .env then reference it in docker-compose via ${}.

$ docker-compose down
WARNING: The s variable is not set. Defaulting to a blank string.
ERROR: Invalid interpolation format for "environment" option in service "web": "SECRET_KEY="

Just want to make a note of it if somebody else come across the same issue.

Chapter 16 issues with CSRF tokens

When I turn on the CSRF settings in configs/settings.py, the user can't log in, the page looks like it's refreshing but it goes back to the log in form. Same with admin pages. This also happens to the deployed version on Heroku

login problems when used:
CSRF_COOKIE_SECURE
SESSION_COOKIE_SECURE

As a smaller issue, the HSTS settings shows a "The connection for this site is not secure" error, and the terminal says the browser is trying to force the https in development server, which causes the error

Anyway, thank you for the amazing book that finally got me started on Django, which I thought I couldn't ever

book (hard copy) and repo is very different

is it possible to get a copy of the latest book? I bought my book at the beginning of August and the code matched but now I see when I want to get clarification the code is different and I can't make sense of it? For example the bookstore_project in chapter 3 now it is called books and has accounts and I have no idea how that came to be?

docker-compose-prod.yml vs docker-compose.prod.yml

I have some questions because deployment fails because there are no config vars picked up other than those set in heroku config vars manually
I bought v3.0 and v3.1 of the DFP books and there is a difference with regards to the volumes being left in on 3.1 but removed 3.0.
I realise no one else is having the same issue as no issue raised but I would like to understand better.

Next question: if using heroku.yml is it in place of docker-compose-prod.yml and therefore volumes left in the file isn't an issue?

What am I doing wrong or have I missed something?
In 3.0 ENVIRONMENT == 'production' but in 3.1 not inlcluded and ENVIRONMENT added to heroku manually doesn't pick up ENVIRONMENT in config.settings and django complains it is undefined as well, anyway.

Mainly my question is : How do the ENV vars in docker-compose-prod.yml get copied over or do I completely forget about the docker-compose files and add them myself i.e. Email settings, stripe keys etc?

Any comments would be appreciated because I urgently need to complete this step in the correct manner

chapter 2, problem when changed the database settings

all worked fine but when i tried to change database from sqlite3 to postgresql and went to django local host page it still saying Problem reloading the page (Note: i followed all command till the topic: New Database of chapter 2). Also, i recieved this error when i ran this command -> docker-compose logs

Attaching to pgresql_web_1, pgresql_db_1
web_1 | Watching for file changes with StatReloader
web_1 | Performing system checks...
web_1 |
web_1 | System check identified no issues (0 silenced).
web_1 | Exception in thread django-main-thread:
web_1 | Traceback (most recent call last):
web_1 | File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
web_1 | self.connect()
web_1 | File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 195, in connect
web_1 | self.connection = self.get_new_connection(conn_params)
web_1 | File "/usr/local/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 178, in get_new_connection
web_1 | connection = Database.connect(**conn_params)
web_1 | File "/usr/local/lib/python3.6/site-packages/psycopg2/init.py", line 126, in connect
db_1 | Error: Database is uninitialized and superuser password is not specified.
web_1 | conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
db_1 | You must specify POSTGRES_PASSWORD to a non-empty value for the
web_1 | psycopg2.OperationalError: could not translate host name "db" to address: Name or service not known
db_1 | superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".
web_1 |
db_1 |
web_1 |
db_1 | You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
web_1 | The above exception was the direct cause of the following exception:
db_1 | connections without a password. This is not recommended.
web_1 |
db_1 |
web_1 | Traceback (most recent call last):
db_1 | See PostgreSQL documentation about "trust":
web_1 | File "/usr/local/lib/python3.6/threading.py", line 916, in _bootstrap_inner
web_1 | self.run()
db_1 | https://www.postgresql.org/docs/current/auth-trust.html
web_1 | File "/usr/local/lib/python3.6/threading.py", line 864, in run
web_1 | self._target(*self._args, **self._kwargs)
web_1 | File "/usr/local/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper
web_1 | fn(*args, **kwargs)
web_1 | File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 120, in inner_run
web_1 | self.check_migrations()
web_1 | File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 453, in check_migrations
web_1 | executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
web_1 | File "/usr/local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in init
web_1 | self.loader = MigrationLoader(self.connection)
web_1 | File "/usr/local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in init
web_1 | self.build_graph()
web_1 | File "/usr/local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 212, in build_graph
web_1 | self.applied_migrations = recorder.applied_migrations()
web_1 | File "/usr/local/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 73, in applied_migrations
web_1 | if self.has_table():
web_1 | File "/usr/local/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 56, in has_table
web_1 | return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
web_1 | File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 256, in cursor
web_1 | return self._cursor()
web_1 | File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 233, in _cursor
web_1 | self.ensure_connection()
web_1 | File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
web_1 | self.connect()
web_1 | File "/usr/local/lib/python3.6/site-packages/django/db/utils.py", line 89, in exit
web_1 | raise dj_exc_value.with_traceback(traceback) from exc_value
web_1 | File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
web_1 | self.connect()
web_1 | File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 195, in connect
web_1 | self.connection = self.get_new_connection(conn_params)
web_1 | File "/usr/local/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 178, in get_new_connection
web_1 | connection = Database.connect(**conn_params)
web_1 | File "/usr/local/lib/python3.6/site-packages/psycopg2/init.py", line 126, in connect
web_1 | conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
web_1 | django.db.utils.OperationalError: could not translate host name "db" to address: Name or service not known
web_1 |

CH8 - Environment Variables - Import environs could not be resolved

Hi, I am working on Mac and have been able to follow along up to this point. I installed environs in Zsh using

docker-compose exec web pipenv install 'environs[django]==8.0.0'

The installation proceeds without issues. However, when I try to import environs into the settings.py file, I get an error saying "Import environs could not be resolved Pylance (report missing imports)". Any idea on why it's not being recognized?

Any workarounds for Windows 10 Home?

I'm greatly enjoying all three books on Django, but I'm on Windows 10 Home, so the required Docker install is proving quick tricky. With the Django for Beginners book, I got the demos to run using virtualenv instead of pipenv, so I'm hoping for some sort of similar workaround, even if remotely, for this book, which otherwise is outstanding. Anyone have any ideas?

Remove the file db.sqlite3 from the repo

The SQLite database file shouldn't be committed in the repo. Also, I believe SQLite isn't used anymore after chapter 1, but the file is there in every chapter's directory here.

Ch13 - Failing tests

Hello! After adding LoginRequired and PermissionRequired mixins to your views, some tests began to fail because of redirection (302 code instead of 200) and forbidden error (403 code instead of 200).

Chp3 Books: Accounts migration failing

I am using Version 3.1 and I am a novice.

I am working through Chapter 3 and the books example. On Page 48, The makemigrations accounts works. I am attempting the second migrate but it fails. Thinking it was me, I started over and walked through the steps as outlined in the book and did not jump around and used a separate directory

Screen Shot 2021-02-21 at 3 38 52 PM

This is preventing me from creating the superuser:
Screen Shot 2021-02-21 at 3 40 32 PM

I can connect into Docker Container for the Database so I know the container appears good.
Screen Shot 2021-02-21 at 3 42 02 PM

When I go the Admin on the server, I get the login screen.

Thanks,

Russ

chapter 10 ValueError

raise ValueError('badly formed hexadecimal UUID string').
I am not able to resolve it. can you tell me, how to resolve it? please
I do a project on windows (pycharm) not using Docker

Chapter 1 working directory path in docker-compose.yml

Hi William,

https://github.com/wsvincent/djangoforprofessionals/blob/master/ch1-hello/docker-compose.yml

Should the following file path be-
command: python /code/hello/manage.py runserver 0.0.0.0:8000
instead of-
command: python /code/manage.py runserver 0.0.0.0:8000

This is how my directory looks like as per the book-
[ code ]
| - [ hello ]
| - - db.sqlite3
| - - docker-compose.yml
| - - Dockerfile
| - - [ hello_project ]
| - - manage.py
| - - [ pages ]
| - - Pipfile
| - - Pipfile.lock

Similarly in the-
https://github.com/wsvincent/djangoforprofessionals/blob/master/ch1-hello/Dockerfile
Should the WORKDIR, COPY and COPY . be /code/hello instead of /code.

Chapter 8: Environs import not working

So, I ran into this bug after installing environs using

docker-compose exec web pipenv install 'environs[django]==8.0.0'

and the import in the settings file is not working, showing an import could not be resolved error.

The thing is, environs is most definitly installed. This is my Pipfile:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
django = "==4.0.1"
psycopg2-binary = "==2.9.3"
django-crispy-forms = "*"
django-allauth = "*"
environs = {version = "==8.0.0", extras = ["django"]}

[dev-packages]

[requires]
python_version = "3.10"

I tried restarting the docker container to no avail. I also tried cloning the chapter 8 folder into my machine and trying there, but I ran into the same issue.

Chapter 8 ENV SECRET_KEY

At the end of this section, after updating the SECRET_KEY

You state to run docker-compose down and this destroys the database. Did you mean docker-compose stop?

You should be able to navigate to the webpage again, refresh it, and everything still works as before. - No it doesn't I have to recreate a superuser

Traceback from homepage

Exception Value: | relation "django_session" does not exist LINE 1: ...ession_data", "django_session"."expire_date" FROM "django_se...
-- | --
Command Line
$ docker-compose down
$ docker-compose up -d

All set. You should be able to navigate to the webpage again, refresh it, and everything
still works as before. If the environment variable hadn’t loaded you’d see an error since
a SECRET_KEY is required for any Django project. If that’s the case run docker-compose
logs from the command line to diagnose the issue.

Media Files directory

Hi Will,

I'm working my way through Django for Professionals v4.0 and all had been going smoothly until Chapter 13.
I'm not sure whether it's due to a typo or my misunderstanding.

The text states: "We can add both of these settings after STATICFILES_FINDERS near the bottom of the django_- project/settings.py file. We’ll use the common convention of calling both media."

I have no STATICFILES_FINDERS in my settings file, so I followed the code here in GitHub and placed the lines beneath the other STATICxxx lines.

I'm not sure what you mean by "We’ll use the common convention of calling both media" since one line specifies "media" and the other specifies "static".

I set my MEDIA_ROOT = BASE_DIR / "media" since this matched the following instructions regarding the creation of a "media" directory with a "covers" subdirectory, but the project in GitHub does not contains these folders; it seems to be placing the uploaded images in "static/covers".

Could you please clarify what should be happening with regards to placing the uploaded images in either the "static" folder or the "media" folder?

[Chapter 16 - Security] Issue with DJANGO_DEBUG

Going to http://127.0.0.1:8000/debug results in a proper Not Found error in the browser. However, when running docker-compose exec web python manage.py check --deploy, I still get the warning that DEBUG is True in production. Also, it was mentioned that after building image from new docker-compose-prod.yml file, it would destroy items in my database. It didn't do that either.

Anyone able to nudge me in the right direction?

settings.py
DEBUG = env.bool("DJANGO_DEBUG")

docker-compose-prod.yml

version: '3.8'

services:
  web:
    build: .
    command: python /code/manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - 8000:8000
    depends_on:
      - db
    environment: 
      - "DJANGO_SECRET_KEY=&qhzy1r$$_9f5dks*!l_jhrg_wnm=m!q%0@(06!+^0wpxbu5k6_"
      - "DJANGO_DEBUG=False"
  db:
    image: postgres:11
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    environment:
      - "POSTGRES_HOST_AUTH_METHOD=trust"
volumes:
  postgres_data:

Commands Run

docker-compose down
docker-compose -f docker-compose-prod.yml up -d --build
docker-compose exec web python manage.py migrate

Also, if I run docker-compose exec web python then:

$ import os
$ d = os.environ.get("DJANGO_DEBUG")
$ d
'True'

Chapter 16 not passing tests

After adding the cache middlewares for the templates it doesn't pass the tests for the pages application (concretely: test_homepage_template and test_aboutpage_template). It still works well.

[ch 2] docker-compose.yml, permission denied

When using the code in the book (version 4.0, page 31), I get the following error when running docker-compose up:

web_1  | python: can't open file '/code/manage.py': [Errno 13] Permission denied
django_1_web_1 exited with code 2

Removing the last two lines from the docker-compose.yml file lets it build.

volumes:
      - .:/code

I did not see any directions to create the "code" volume, did I miss it?

Home and About AssertTemplateUsed Tests Fail Starting In Chapter 16

test_homepage_template and test_aboutpage_template both work in Ch15 but fail in Ch16 onwards.

Issues 74 and 33 seem to say the same thing.
Using Django 4.2 and django-debug-toolbar 4.0.0. I therefore think something is going on with the debug toolbar "intercepting" somehow? The debug toolbar itself shows the templates being utilized, and they render just fine.

Printing out the response as a dict shows that truly the templates are not used in Ch16 onwards.
Seems like this is probably not an issue with your code/book, but the interaction of AssertTemplateUsed and django-debug-toolbar.

psycopg2.errors.UndefinedTable: relation "users_customuser" does not exist

Have finished first book and started second one. Hagin a great time and really enjoying material but i reached the dead end and hence i am writing here.

As I was following the book and coding along i came across the error right after i enter the username after createsuperuser command.

PS C:\Users... \books> docker-compose exec web python manage.py createsuperuser
Username: dm
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: relation "users_customuser" does not exist
LINE 1: ...is_active", "users_customuser"."date_joined" FROM "users_cus...
The above exception was the direct cause of the following exception:
....

I tried to solve it myself and didnt go well. Then shut down docker and deleted the project folder and started form beginning. And then i came across the same problem. i then used the code provided here at github and same problem keeps occurring.

Any suggestions/ideas how to explore this error further and where to find resolution?

Question on Testing in Chapter 4

I'm a fairly novice coder and even more new to the idea of testing so there might be something really obvious that I'm missing, but my question relates to the steps in chapter 4 for "setUp Method" where we set self.response and remove the test_homepage_url_name.

I understand why we'd want to use self.response to avoid repeating code but by using self.client.get(reverse('home')) in setUp() there are now a handful of tests that will fall down if reverse('home') doesn't work and it doesn't seem like it'd be obvious from the pattern of test failures why this happened, as it would when test_homepage_url_name was still a test.

Would it not be better to use self.client.get('/') within setUp() and add a test to check something like self.client.get('/') == self.client.get(reverse('home')) so that if the former worked and the latter didn't, it'd be more clear where the failure is occurring?

App doesn't serve uploaded images in production

I don't have much information to give apart from the images 404

This is after you create a new book / upload an image.

Other static assets work as usual

Does anyone have any ideas? Or come across this, I'm pretty certain my code matches

Problem with file djangoforprofessionals/ch2-postgresql/config/settings.py

I had problems running the postgresql application in a docker container since there seems to be a typo in the settings.py file. In line 83 there is the command < 'PORT': 5432 >. For me this file was working with < 'PORT': '5432', > only. Line 83 is spelled this way in the book Django for Professionals 3.0 too, maybe one needs to correct it there too.

Best regards

Flo

Issue with docker-compose.yml

When I created the Dockerfile and docker-compose.yml files, I cannot get the docker-compose up command to work. The yml line command: python /code/manage.py runserver 0.0.0.0:8000 fails. When I changed it to command: python /code/hello/manage.py runserver 0.0.0.0:8000 I am able to run the app in docker. I am running on Mac OS X 10.15.3 with Docker version 2.2.0.3.

No guarantee that Dockerfile and piplock will be compatible, leading to error installing psychopg2

I ran into an error, which I've fixed, but that could be a trap for new users. It stems from having a system install of python 3.8, and the book (sample at least) relying on python 3.7. Admittedly your prior book does have extensive and useful dev environment set-up instructions, but not this one.

I have python 3.8 installed on my system as the user default. Therefore, the piplock file will default to:

[requires]
python_version = "3.8"

When you get to install the psycopg2 package, the error that is thrown is:

❯ docker-compose exec web pipenv install psycopg2-binary==2.8.3
Warning: Python 3.8 was not found on your system…
Neither 'pyenv' nor 'asdf' could be found to install Python.
You can specify specific versions of Python with:
$ pipenv --python path/to/python

I believe the error arises from how the Dockerfile and the piplock at this point differ, with the Dockerfile specifying 3.7. If the piplock gets changed manually to 3.7 however, then the install runs as expected.

A potential guarantee may be adding the --python 3.7 on pipenv creation.

Chapter 11: Foreign Keys

A one-to-many relationship is far more common and is the default foreign key setting within
Django. For example, one student can sign up for many classes.

Is that example one-to-many or many-to-many? Because a class may belong to more than one student.

Published link to book cover is 404

In my copy of the book v 4 from Gum Road a few months ago this line:

How about an image? You can download the book cover for Django for Professionals at this link. Save it into the directory books/static/images as dfp.png.

links to a URL that is currently 404. Tiny bug really, just an FYI. I suspect somewhere along the lines the file type got updated to jpg but the url didn't.

Thanks for the book, really enjoying it so far.

Chapter 10: Email // Clicking on the unique URL link in the email

Hi, on page 155, after I click on the unique URL link in the email it appears a 404 error:

`

Using the URLconf defined in django_project.urls, Django tried these URL patterns, in this order:

  1. admin/
  2. accounts/ signup/ [name='account_signup']
  3. accounts/ login/ [name='account_login']
  4. accounts/ logout/ [name='account_logout']
  5. accounts/ reauthenticate/ [name='account_reauthenticate']
  6. accounts/ password/change/ [name='account_change_password']
  7. accounts/ password/set/ [name='account_set_password']
  8. accounts/ inactive/ [name='account_inactive']
  9. accounts/ email/ [name='account_email']
  10. accounts/ confirm-email/ [name='account_email_verification_sent']
  11. accounts/ ^confirm-email/(?P<key>[-:\w]+)/$ [name='account_confirm_email']
  12. accounts/ password/reset/ [name='account_reset_password']
  13. accounts/ password/reset/done/ [name='account_reset_password_done']
  14. accounts/ ^password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$ [name='account_reset_password_from_key']
  15. accounts/ password/reset/key/done/ [name='account_reset_password_from_key_done']
  16. about/ [name='about']
  17. [name='home']

The current path, accounts/confirm-email/NQ:1qqfkS:quBjIsocaaYVWNKNR8Y9NGb_Iu7QZlVvKyynv5J5jqM//, didn’t match any of these.

`

I made sure my code was similar to yours and I even downloaded your original code from here and I'm getting the same error.

Can you please help me?

chapter 14 (stripe error)

after creating charge function im getting Invalid request error (while working on payment section chap. 14). The error says,

InvalidRequestError at /orders/charge/

Request req_r6yTG446gAmhYr: As per Indian regulations, export transactions require a customer name and address. More info here: https://stripe.com/docs/india-exports

djangoforprofessionals/ch6-static-assets/templates/_base.html minor typos bugs

I found the following bugs/typos in your code in the directory:
djangoforprofessionals/ch6-static-assets/templates/_base.html

1- missing open h5 tagin line 16
Bookstore

2- missing closing div tags in the end of line 25-28 which i assume it should go after line 26 closing the nav tag.

Please correct those errors and if i am wrong please let me know, i am new to programing and i need to learn. Thank you.

Unable to reset database

Been following the book with the exception of doing some sidesteps when I got curious. This has led to some database problems and I am now in need of a reset.

I'm still only working locally

I've tried the reset_db command included in Django-extensions but it says there are two users using the database and therefore it can't be dropped. I guess it is the two docker containers. Don't know how to work around that.

I've also tried to follow along with this guide. Which says I should be able to reset using this command

docker-compose exec <database service name> psql -U <db_user_name> -d postgres -c “DROP DATABASE <db_name>;”

The problem with that is that I do not know the username nor the name of the database since I use these settings(introduced in chapter 8)

DATABASES = {
    "default": env.dj_db_url("DATABASE_URL",
                             default="postgres://postgres@db/postgres")
}

Any advice?

Chapter 8 aullauth logout redirect issue

Hi Will,

In chapter 8 django_project/settings.py, I think we should probably make the following changes.

-ACCOUNT_LOGOUT_REDIRECT = "home"
+ACCOUNT_LOGOUT_REDIRECT_URL = "home"

Otherwise, if we set the following, it will not redirect us to the about page.

ACCOUNT_LOGOUT_REDIRECT = "about"

Chapter 2 creating superuser in Linux (root vs current user)

For linux users this might be an issue:

When using pipenv shell I am able to create a superuser and successfully log into the 127.0.0.1:8000/admin portal.

However when using docker-compose exec I am able to create a superuser but unable to log in to the admin portal.

The issue is when using pipenv shell, the command is run by the current user but when using docker-compose exec it's run by root.

I have added myself to a new group docker to run docker as the current user.

I do not have a working solution yet so bringing it up here.
(I was hoping docker-compose exec -u ... would work but it returns nothing so wasn't successful.)

Thank you,

Matthew

Typo in the book on page 258

Hi there,
On page 258, there is one closing parenthesis missing.
DEBUG = env.bool("DJANGO_DEBUG", default=False # new

The signup page routes to an signup page

After downloading the content of chapter 9. The making an user part shows email field username field and password field. After submit the screen email and password pop up. But submit button does not submit. And the app is 'stuck'

[ page 138] template/account directory as suggested by the author results in an error

The author draws readers attention to that they should use 'account' directory in template/. I did as suggested having added a line in bookstore_project\urls.py to get the url
path('account/', include('allauth.urls'))

Everything seems to be working as expected. However, once I came to the step when a letter of email confirmation had to be proven by a new user I got an error. Instead of account there was accounts

I went back to 144th page , then to 145, 146, there was /accounts/ on each screenshot.

I thought that there must have been a typo. However, I remember that the author prompted us to make account (without 's').

Did I miss something since I printed a ebook and it's completely black&white. Unfortunately I' unable to differentiate #new code or annotations.

All in all I've changed path in urls and directory name to accounts - works perfectly well. Dunno.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.