Code Monkey home page Code Monkey logo

tutorial-extensions's Introduction

Django Girls website

Build Status codecov

This repository contains the Django application which powers DjangoGirls.org.

What's in it?

It's a simple CMS that contains 3 main models:

  • Event - a list of events and their website configuration
  • EventPageContent - blocks of content that are visible on the website
  • EventPageMenu - items of menu of every website

How to create new event?

Simply go to command line and run this command:

python ./manage.py new_event

And then follow the instructions.

How to manage your website?

Event

http://djangogirls.org/admin/core/event/

Here you can change:

  • Meta tags - title and description of the website
  • Main color - main color on the website in HEX (default is FF9400)
  • Custom CSS - customize CSS on the website
  • URL - url that goes after the domain (http://djangogirls.org/__url__)
  • Is live? - live website is available on the homepage and can be accessed by anyone

EventPageContent

http://djangogirls.org/admin/core/eventpagecontent/

Each website comes with some default content that you can adjust to your needs. Each object is a "block" on the website that you can modify in following ways:

  • Name - it's also a permalink that you can link to like this: #name
  • Content - HTML is allowed
  • Background - there are two available types of blocks: without background and with background. By uploading image you're choosing the type with background.
  • Is public - check this if you want this block to be visible

EventPageMenu

http://djangogirls.org/admin/core/eventpagemenu/add/

To manage menu available on the website, you can add objects to EventPageMenu. Available options:

  • Title
  • URL

Contributing to Django Girls website

The website is hosted on PythonAnywhere and is available here: http://djangogirls.org/

Please note that we use Python 3 only, so make sure that you use correct version when running commands below.

Setting up a development environment

First, fork and clone the repository:

git clone [email protected]:your-username/djangogirls.git

Step into newly created djangogirls directory:

cd djangogirls

Docker

If you have Docker and Docker compose installed, run docker-compose up

Non Docker

Create a new virtual environment (Python 3.10) if needed. Then, install all the required dependencies.

The dependencies are compiled by pip-tools, which compiles requirements.txt ensuring compatibility between packages.

pip install pip-tools
pip-sync

There is more information on how pip-tools work below in Using pip-tools.

Install the pre-commit hook. It's useful so we automatically format and lint code before committing any changes.

pre-commit install

Start the PostgreSQL database server and enter the psql shell (you need to have PostgreSQL installed):

psql

In the psql shell, create a database and a role with the necessary permissions:

CREATE DATABASE djangogirls;
CREATE ROLE postgres;
GRANT ALL privileges ON DATABASE djangogirls TO postgres;
ALTER ROLE postgres WITH LOGIN;

Exit the psql shell:

\q

Run the migration to create database schema:

./manage.py migrate

Load sample data to the database

./manage.py loaddata sample_db.json

Create a user so you can login to the admin:

./manage.py createsuperuser

Install dependencies for static files:

npm install

Compile CSS and JS files:

gulp watch

Run your local server:

./manage.py runserver

πŸŽ‰ You're done.

Run the tests

You can run the tests like this:

python -m pytest

Or if you want coverage reports:

python -m pytest --cov

For a coverage report with information about missing lines, run this:

python -m pytest --cov-report term-missing --cov

Static files

We're using a Stylus as our CSS pre-processor. Get styling with Stylus.

This means you shouldn't change any css files, but .styl files. They're in /static/source/css/ directory.

Autocompiling of .styl files to .css:

npx gulp watch

We're also using gulp for our static files builds (see below). To build static files for production, run this:

npx gulp build

For local development:

npx gulp local

Gulp Tasks

Static files are generated and maintained using gulp.js. To use, you'll need Node.js installed. Then, run npm install. You can now use npx gulp (note that it's np**x**), followed by one of the following commands:

  • gulp local - run a one-off local build of css & js
  • gulp watch - compile and watch static assets for changes
  • gulp build - run a one-off production build, which involves minifying code and asset revision markers
  • gulp clean - remove the results of any of the above commands

Running gulp on its own runs watch by default.

Developing Gulp Tasks

Each gulp task is a single function, which are combined using the series operator so they run as a workflow. Each are commented with what they do and why they're important.

The biggest gotcha is async completion. Each task much signal to gulp when it has finished. The easiest way to do this is using an aysnc function, but if your functionality uses gulp streams (most native gulp functionality does), then you should not use an async function. Instead, return the gulp stream from the function and it will be handled correctly.

// WRONG - uses gulp's streams in an async function; subsequent tasks won't wait for completion correctly:
const copyFiles = async () => {
    return gulp.src(...).pipe(gulp.dest(...))
}

// RIGHT - either returns a gulp stream _or_ uses an `async` function:
const copyFiles = () => {
    return gulp.src(...).pipe(gulp.dest(...))
}
const deleteFiles = async () => {
    await del(...)
}

Hosting on PythonAnywhere

Key bits of config and secrets are stored in environment variables in two places:

  • in the WSGI file (linked from the Web Tab)
  • in the virtualenv postactivate at ~/.virtualenvs/djangogirls.com/bin/postactivate

Google Apps API integration

We're using Google Apps Admin SDK for creating email accounts in djangogirls.org domain automatically.

Several things were needed to get this working:

  1. Create an app in Developer Console
  2. Create a service account to enable 2 legged oauth (https://developers.google.com/identity/protocols/OAuth2ServiceAccount)
  3. Enable delegation of domain-wide authority for the service account.
  4. Enable Admin SDK for the domain.
  5. Give the service account permission to access admin.directory.users service (https://admin.google.com/AdminHome?chromeless=1#OGX:ManageOauthClients).

Using pip-tools

The packages required by the project are in requirements.in which looks like a regular requirements file. Specific versions of packages can be specified, or left without a version in which case the latest version which is compatible with the other packages will be used.

If you are working on a feature which requires a new package, add it to requirements.in, specifying a version if necessary. It's dependencies will be included in requirements.txt by the compile process.

The only time a dependency of a third party package needs adding to requirements.in is when a version has to be pinned.

By running pip-compile the requirements are compiled into requirements.txt.

Periodically requirements should be updated to ensure that new versions, most importantly security patches, are used. This is done using the -U flag.

Once requirements are compiled, pip-sync will install the requirements, but also remove any packages not required. This helps to ensure you have the packages required, but also that there isn't something installed that's missed from requirements.txt.

For example:

pip-compile -U
pip-sync

Handling environment variables

The requirements.txt installs python-dotenv which provides the option for developers to load environment variables via a single file.

You'll see .environment-example in the project root. This contains environment variables used by the project so that you can create your own copy of this and load it with values relevant to your development environment.

To make use of this feature, create a copy of the example file and call it .environment. This file will be ignored by version control, but loaded by manage.py. So when you run django commands like manage.py runserver during development python-dotenv will load the environment variables from your .environment file so that they are available to the application.

This is an optional feature. If you do not have a .environment file then it won't impact on the application at all.

Before you Open a Pull Request

This project runs a linting check with flake8 whenever a pull request is merged. Before you create a pull request, it's advisable to fix any linting issues locally to avoid errors while merging. In order to have flake8 run in your local machine automatically you can do the following:

  1. Run pip install pre-commit to install pre-commit. This package helps setting up git hooks.

  2. Run pre-commit install to install the git hook. After this, whenever you run git commit in your local machine, flake8 will run and report any linting errors that it found.

  3. If you've already committed your changes before installing pre-commit, you can follow steps 1 and 2 and then run pre-commit run --all-files to run flake8 against all of the files.

Help with translation of the website

Join us on poeditor.com to help with translation of the website so that non-English speakers can view the website based on their locale.

Languages available for translation are;

  • French
  • German
  • Korean
  • Persian
  • Portuguese
  • Portuguese (BR)
  • Russian
  • Spanish

See issue 571- Website internationalization/translations for further details. Alternatively submit the pull request to the translations branch.

tutorial-extensions's People

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  avatar

tutorial-extensions's Issues

logging out

I'm not sure what I missed... when I click on logout it gives me an error,

Request Method: GET
http://127.0.0.1:8000/%7B%25%20url%20'logout'%20%25
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
^admin/
^accounts/login/$ [name='login']
^accounts/logout/$ [name='logout']
^$ [name='post_list']
^post/(?P\d+)/$ [name='post_detail']
^post/new/$ [name='post_new']
^post/(?P\d+)/edit/$ [name='post_edit']
^post/(?P\d+)/publish/$ [name='post_publish']
^drafts/$ [name='post_draft_list']
^post/(?P\d+)/remove/$ [name='post_remove']
The current URL, {% url 'logout' %, didn't match any of these.

Did I miss doing something here that is not explained?

We decided to rely on Django to handle login, so let's see if Django can also handle logout for us. >Check https://docs.djangoproject.com/en/1.10/topics/auth/default/ and see if you find something.

Done reading? By now you may be thinking about adding a URL in mysite/urls.py pointing to >Django's logout view (i.e. django.contrib.auth.views.logout), like this:

"post_new" method is mentioned but not available

Hi,
On following page, tutorial says we should change post_new and post_edit method in views.py. I have completed every step in tutorial. We didn't add any class to views.py, put aside any method... It is confusing...

https://djangogirls.gitbooks.io/django-girls-tutorial-extensions/homework/

Save new posts as drafts

Currently when we're creating new posts using our New post form the post is published directly. To instead save the post as a draft, remove this line in blog/views.py in the post_new and post_edit methods:

post.published_date = timezone.now()

Also

Delete post

Let's open blog/templates/blog/post_detail.html once again and add this line:


just under a line with the edit button.

We have never added edit button to post_detail page...

Problems with Deploy your website on Heroku

I'm working through the exercise and is running into issues with database migration. I followed the instructions to change to PostgreSQL installation. I run $ heroku run python manage.py migrate and I get all the stats staying ok. But yet when I run $ heroku run python manage.py createsuperuser I get errors saying database doesn't exist. I tried googling for answers but can't find a solution. Are these instructions outdated compared to Heroku?

(myvenv) Yenlys-MacBook-Pro:django_girls yenlyma$ heroku run python manage.py migrate
Running python manage.py migrate on β¬’ ydgblog... up, run.6320 (Free)
Operations to perform:
  Apply all migrations: admin, auth, blog, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying blog.0001_initial... OK
  Applying blog.0002_comment... OK
  Applying sessions.0001_initial... OK
(myvenv) Yenlys-MacBook-Pro:django_girls yenlyma$ heroku run python manage.py createsuperuser
Running python manage.py createsuperuser on β¬’ ydgblog... up, run.4890 (Free)

You have 15 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, blog, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.

Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py", line 337, in execute
    return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: auth_user

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 63, in execute
    return super(Command, self).execute(*args, **options)
  File "/app/.heroku/python/lib/python3.5/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 96, in handle

Support for string view arguments to url() is deprecated

Hello,
Looking at this page : https://djangogirls.gitbooks.io/django-girls-tutorial-extensions/content/authentication_authorization/index.html#login-users

I got a warning such as :

RemovedInDjango110Warning: Support for string view arguments to url() is deprecated and will be removed in Django 1.10 (got django.contrib.auth.views.login). Pass the callable instead.
url(r'^accounts/login/$', 'django.contrib.auth.views.login'),

Maybe you could change urls.py such as the following or any other more usual way :

from django.conf.urls import patterns, include, url
import django.contrib.auth.views as auth_views

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^accounts/login/$', auth_views.login, name="auth_views.login"),
    url(r'', include('blog.urls')),
)

Kinds

A error occurs in blog/urls.py

@h5jam commented on Sun Sep 08 2019

Issue description

When I add this code in my blog/urls.py, a error occurs.
I want to add the necessary module to the tutorial to make sure novices don't panic.
Β 

url(r'^drafts/$', views.post_draft_list, name='post_draft_list'),

Thank you.

https://tutorial-extensions.djangogirls.org/ko/homework/#%EA%B2%8C%EC%8B%9C%EB%90%98%EC%A7%80-%EC%95%8A%EC%9D%80-%EB%B8%94%EB%A1%9C%EA%B7%B8-%EA%B8%80-%EB%AA%A9%EB%A1%9D-%ED%8E%98%EC%9D%B4%EC%A7%80-%EB%A7%8C%EB%93%A4%EA%B8%B0

Language

KO

Operating system

Mac

Postgres extension problems on Linux

There are some problems with the postgres tutorial extension when run on Linux:

  1. There are a few packages that are required for the psycopg2 install to work:
  • postgresql-server-dev-X.Y (version may vary - on Ubuntu 16.04 it is 9.5)
  • gcc
  • libpython3.5-dev
  1. The default auth setup doesn't work. (Ref #59) - first of all, the default user can't open psql and create a database, that needs to be done by postgres user (so they must sudo). I don't know if this is something that just works on Mac or Windows?

  2. Authenticating a named (non-unix) user over the tcp socket requires a password, however the settings in the tutorial extension don't use a password (and the user is never given one). This was discussed in #59 - there are various options for this:

  • Get them to use their unix username, but that may require separate settings across different machines.
  • Get them to create the db user with a password, and include the password in settings. Probably the least complex and applicable to all platforms but would require careful pointing out of it being probably OK to include the password in this case, but making sure they're aware of it not generally being a good idea :)
  • Editing postgres config to trust local connections. It's a small edit but involves acting as root, changing a config file (probably making sure it gets backed up just in case) and restarting the postgres server.

Again, I don't know whether all this "just works" on windows and mac.

Interested in other opinions about what is the best way to deal with this!

Can't access postgres shell

Hi if I write:

$ psql

As recommended into your postgres tutorial. This will yield:

psql: FATAL: database "username" does not exist

While username is the linux ubuntu username. Can you write how to get around this?

Section1: Incorrect HTML for Draft button

In the first Homework. The single/double quote nesting is incorrect. The HTML to insert is given as:

<a href="{% url "post_draft_list" %}" class="top-menu"><span class="glyphicon glyphicon-edit"></span></a>

It should be:

<a href="{% url 'post_draft_list' %}" class="top-menu"><span class="glyphicon glyphicon-edit"></span></a>

Also it should follow the link for the post_new, rather than be just above the <h1><a href="/">Django Girls Blog</a></h1> line, so that it will only display for an authorized user.

Proposal: add a tutorial extension based on Wagtail

Hi πŸ‘‹

I've been thinking about writing a beginner-level tutorial for Wagtail, a popular CMS based on Django. Would this be interesting as a new extension? I'm willing to make that happen but I would like to check first whether others think it makes sense.

It is very common for people to initially start a project with Django, then bring on Wagtail later on to manage their site's content – it comes with its own admin interface which is generally more user-friendly than Django's (I help build it so I'm biased), as well as features specific to content management. Here are my ideas for what could go in the extension:

  • Explaining what Wagtail is, what a CMS is, how this fits with Django.
  • Installing Wagtail in the existing project.
  • Creating a page model, reflecting on how this compares with Django.
  • Creating a contact form on the site (very easy).
  • Creating a basic image gallery? (Wagtail does lots around this so that's not much code).

I think those things would be a good mix of being interesting to do and also simple enough for the extension to not be too long, but I'll check with other Wagtail people if they have more ideas.

How does that sound?

can't import name 'CommentForm'

ImportError at /post/5/comment/
cannot import name 'CommentForm'
Request Method: GET
Request URL:    http://localhost:8000/post/5/comment/
Django Version: 1.8
Exception Type: ImportError
Exception Value:    
cannot import name 'CommentForm'
Exception Location: E:\pywork\djangogirls\blog\views.py in <module>, line 6
Python Executable:  E:\Python35\python.exe
Python Version: 3.5.0
Python Path:    
['E:\\pywork\\djangogirls',
 'E:\\Python35\\lib\\site-packages\\django_debug_toolbar-1.4-py3.5.egg',
 'E:\\Python35\\lib\\site-packages\\sqlparse-0.1.19-py3.5.egg',
 'E:\\Python35\\python35.zip',
 'E:\\Python35\\DLLs',
 'E:\\Python35\\lib',
 'E:\\Python35',
 'E:\\Python35\\lib\\site-packages']
Server time:    Thu, 16 Jun 2016 17:02:11 +0800

when I study this course
https://github.com/DjangoGirls/tutorial-extensions/blob/master/homework_create_more_models/README.md .
run this url

http://localhost:8000/post/5/comment/

I get this error.

can u help me to fix this?Thank u.

broken links at https://djangogirls.gitbooks.io/django-girls-tutorial-extensions/content/en/

Add publish button

I'm following the instructions and I get an error when I click on publish button

`Request Method: GET
http://127.0.0.1:8000/post/6/publish/
1.10.7
AttributeError
'Post' object has no attribute 'publish'
/Users/nahusznaj/djangogirls/blog/views.py in post_publish, line 47
/Users/nahusznaj/djangogirls/myvenv/bin/python
3.5.1
['/Users/nahusznaj/djangogirls', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python35.zip', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin', '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib-dynload', '/Users/nahusznaj/djangogirls/myvenv/lib/python3.5/site-packages']
Mon, 7 Aug 2017 10:23:35 +0100
`

This is my line 47 in views.py

def post_publish(request, pk): post = get_object_or_404(Post, pk=pk) post.publish() return redirect('post_detail', pk=pk)

what's wrong?

Authorization/authentications issues, spanish version: url statements, link to old documentation

Hi! I noticed a few issues in the secure your website section, in the Spanish version. They are:

  • Urls patterns not updated (using url statement instead of path)
  • Login and logout urls use views.login instead of views.LoginView.as_view()
  • There's a link to the documentation of Django's 1.10 version
  • A sentence in the Log in users section, when asking to add a setting to mysite/settings.py is not very clear.

If it's okay, I'd like to volunteer to fix them.

Deploy to Heroku: whitenoise instructions are outdated and local_settings aren't currently applied locally

1. Whitenoise instructions

Currently the tutorial has following guidance to install whitenoise (from https://tutorial-extensions.djangogirls.org/en/heroku/#mysitewsgipy):

from whitenoise.django import DjangoWhiteNoise
application = DjangoWhiteNoise(application)

For whitenoise v4.* onwards (released Aug 2018), changelog states:

The WSGI integration option for Django (which involved editing wsgi.py) has been removed. > Instead, you should add WhiteNoise to your middleware list in settings.py and remove any reference to WhiteNoise from wsgi.py. See the documentation for more details.
(The pure WSGI integration is still available for non-Django apps.)

Here's new guidelines (from http://whitenoise.evans.io/en/stable/django.html):

Edit your settings.py file and add WhiteNoise to the MIDDLEWARE list. The WhiteNoise middleware should be placed directly after the Django SecurityMiddleware (if you are using it) and before all other middleware:

MIDDLEWARE = [
  'django.middleware.security.SecurityMiddleware',
  'whitenoise.middleware.WhiteNoiseMiddleware',
  # ...
]

That’s it – WhiteNoise will now serve your static files. However, to get the best performance you should proceed to step 3 below and enable compression and caching.

To add automatic compression with the caching behaviour provided by Django’s ManifestStaticFilesStorage backend, add this also to settings.py

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

2. local_settings.py

Whilst better options are available for handling environmental settings configuration, I understand that using local_settings.py is easy to understand and does the job well enough. However, it's not being applied locally in these instructions: https://tutorial-extensions.djangogirls.org/en/heroku/#mysitelocalsettingspy

To apply these locally, we just need to add following to the bottom of settings.py:

# Override with local_settings if it exists
try:
    from .local_settings import *
except ImportError:
    pass

settings.py error in "Deploy your website on Heroku" section

mysite/settings.py

import dj_database_url
DATABASES['default'] = dj_database_url.config()

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

ALLOWED_HOSTS = ['*']

DEBUG = False

try:
    from .local_settings import *
except ImportError:
    pass

I tried to deploy on heroku with above code, I got this error.

$ heroku logs
(omitted)
2017-07-21T18:55:02.766691+00:00 app[web.1]:   File "/app/register/settings.py", line 92, in <module>
2017-07-21T18:55:02.766691+00:00 app[web.1]:     DATABASES['default'] = dj_database_url.config()
2017-07-21T18:55:02.766694+00:00 app[web.1]: NameError: name 'DATABASES' is not defined
(omitted)

So I rewrite to below:
mysite/settings.py

try:
    from .local_settings import *
except ImportError:
    pass
import dj_database_url
DATABASES['default'] = dj_database_url.config()

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

ALLOWED_HOSTS = ['*']

DEBUG = False

this code passed. No error occurred.
So I think you need to fix code "settings.py" in "Deploy your website on Heroku.
Do you any other opinion? Because I'm beginner.

approved_comment count

For some reason I cannot seem to get the approved_comments count to work. The regular comment count works.

I copied and pasted the snippet into the models.py and post_list.html to ensure I didn't have a typo.

My post_list.html Just shows "Comments:". Is this just me?

Japanese translation

Hello. I am Kazuki, a coach of Django Girls Tokyo.
I would like to propose a merge for this pull request #123 .
As we have requested the merge last March #123, it has not been merged yet. Is there any problems?

The women (and men) who have finished the Django Girls Tutorial are going to try this extensions next.
Many people also need a Japanese translation.

This pull request #123 has been reviewed by Japanese people and I think it deserves what many people want.
Do you have any problems or concerns about merging?
If there is, I am willing to cooperate.

I am looking forward to it being merged.

'Post' object has no attribute 'publish'

I get the following error when I click on the "Publish" button. I think the alignment in my post_detail.html file may be off and causing the problem. Is the source code listed somewhere?

AttributeError at /post/4/publish/
'Post' object has no attribute 'publish'
Request Method: GET
Request URL: http://127.0.0.1:8000/post/4/publish/
Django Version: 1.9.4
Exception Type: AttributeError
Exception Value:
'Post' object has no attribute 'publish'
Exception Location: /home/kevin/djangogirls/blog/views.py in post_publish, line 56
Python Executable: /usr/bin/python
Python Version: 2.7.11
Python Path:
['/home/kevin/djangogirls',
'/usr/local/lib/python2.7/dist-packages/setuptools-20.2.2-py2.7.egg',
'/usr/lib/python2.7/dist-packages',
'/usr/local/lib/python2.7/dist-packages/lgogd_uri-0.1.0.1-py2.7.egg',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/home/kevin/.local/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PILcompat',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/python2.7/dist-packages/wx-3.0-gtk2']

Secure your website - superfluous homework and typos

I. Section Improving the layout - homework:

Edit the template blog/templates/blog/post_detail.html to only show the edit buttons for authenticated users

is superfluous, as it was already done in the basic DjangoGirls tutorial (http://tutorial.djangogirls.org/en/django_forms/#security last code snippet)

II. A typo in Login users second passage
is:

In your mysite/urls.py add a url url(r'^accounts/login/$', django.contrib.auth.views.login).

should be:

In your mysite/urls.py add a url url(r'^accounts/login/$', django.contrib.auth.views.login, name='login').

III. A typo in the second code snippet for More on authenticated users

is: include django.contrib.auth.views

should be: import django.contrib.auth.views

Check links in README.md

The first page of the book as well as the README.md 404s on the Contribute link.

Also in the book, the links for the 4 sections link to the GitHub repo instead of GitBook page.

NameError in URL declaration of post_draft_list

Hey all!

While following the tutorial I encountered a NameError:

File "/home/patrik/dev/django-blog/blog/urls.py", line 9, in <module>
    url(r'^drafts/$', views.post_draft_list, name='post_draft_list'),
NameError: name 'url' is not defined

The naming convention in the beginner tutorial was path instead of url. Applying this solves the NameError.

Also the regular expression r'^drafts/$' is unconventional up to this point. I declared 'drafts/' instead to follow the scheme.

What's your opinion on the raised error?

After discussion I would volunteer to PR request a merge solving this issue.

issue on comment submit

Hi, after I created a comment I was trying to submit it but got the following error:

ValueError: Cannot assign "'user1'": "Post.author" must be a "User" instance. Shouldn't be user name detected from login somehow? Are you planning to extend the tutorial? Thank you!

@login_required is not defined

Hi, after I add @login_required to functions comment_approve and comment_remove in views.py, I'm getting nameError in the CMD saying "login_required" is not defined.

Two minor documentation bugs

  • In the 'Log in users' section, just before the first code snippet, "In your mysite/urls.py add a url url(r'^accounts/login/$', views.login). So the file should now look similar to this: " should be changed to "In your mysite/urls.py add a url url(r'^accounts/login/$', views.login, name='login'). So the file should now look similar to this:" ~ adding name='login' in the url statement

  • In the homework given in 'Improving the layout' section, it should be "delete and edit buttons" instead of "add and delete buttons", as we have already taken care of the add button in base.html as mentioned in the code snippet in the same section.

base.html in mysite

Reported by a student:
There seems to be some confusion around base.html.
The tutorial suggests operations (login.html extends base.html) on mysite/base.html which is not created until later on in the tutorial - 'Improving the layout' - where improvement is done on a file which does not exist.

This book doesn't build on Gitbook anymore

Maybe we need to upgrade book.json to 2.5.0? Needs testing locally.

Build error:

Downloading source
Extracting source
Installing GitBook 2.1.0
[email protected] ../tmp-40pX7E6h4npZcI/node_modules/gitbook
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected] ([email protected], [email protected])
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected])
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected])
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected] ([email protected], [email protected], [email protected], [email protected])
└── [email protected]
GitBook version is 2.1.0 
Tweaking book.json
Installing plugins
info: 2 plugins to install 
info: No version specified, resolve plugin comment 

Found no satisfactory version for plugin comment

unclosed small tag

in div class="page-header" the small tag does not have it's closing counterpart

"Patterns" and multiple discrepancies.

In the mysite/urls.py, the code is completely different than how the Django Girls tutorial ends:

It looks like:

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'', include('blog.urls')),
]

The "Homework: secure your website" shows:

from django.conf.urls import include, url
import django.contrib.auth.views

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^accounts/login/$', django.contrib.auth.views.login, name='login'),
url(r'^accounts/logout/$', django.contrib.auth.views.logout, name='logout', kwargs={'next_page': '/'}),
url(r'', include('blog.urls')),
)

When importing "patterns", Python throws an error that it is deprecated since v1.10.

include(admin.site.urls) is changed in Django 1.10

include function is not needed in Django 1.10 in url.py

https://djangogirls.gitbooks.io/django-girls-tutorial-extensions/authentication_authorization/

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),]

https://docs.djangoproject.com/en/1.10/ref/contrib/admin/

urls.py

from django.conf.urls import url
from django.contrib import admin

urlpatterns = [
url(r'^admin/', admin.site.urls),
]
Changed in Django 1.9:
In previous versions, you would pass admin.site.urls to include().

comments count

comments count on post_list page is not working. When changing it to show only count of approved comments on post_list page it shows "Comments: ".

Security chapter: url tag in link to post list

In the "secure your website" chapter, the h1 tag in the base template is shown as follows:

<h1><a href="{% url 'blog.views.post_list' %}">Django Girls</a></h1>

Which needs updating to use the url name rather than the view path.

But the markup from the tutorial just has <a href="/">

I guess using the url tag is better but it should be made consistent (and correct) one way or another

Typographic error

In views.py, I get an error in the redirect phrase for post_publish.

I think that "pk=pk" should read "pk=post.pk" .
Unless I am missing something.

def post_publish(request, pk):
post = get_object_or_404(Post, pk=pk)
post.publish()
return redirect('post_detail', pk=pk)

greetings,
Rose

Allauth-Tutorial

Hello. I'd like to see an allauth-tutorial. It's a rather big package with not very newbie friendly documentation.

Problems with urls.py in 'Homework: create comment model' chapter

The tutorial says to add this pattern:

url(r'^post/(?P<pk>\d+)/comment/$', views.add_comment_to_post, name='add_comment_to_post'),

(1) It is not mentioned that you need to add the following import statement: from blog import views
(2) this assumes that the student hasn't completed the previous chapter, where they import import django.contrib.auth.views. (I suggested that my student amend this to import django.contrib.auth.views as djangoviews to avoid the conflict.)

Issue at Improving the layout -

At the section of this tutorial it is mentioned that:
"So now we have made sure that only authorized users (ie. us) can add, edit or publish posts. But everyone still gets to view the buttons to add or edit posts. " However I believe that is not true, if you are not authorized you cannot see it because:

{% if user.is_authenticated %}


{% else %}

I tried and I do not see those buttons... can you please check that this is the intended behavior?

Best and congratulations this is the best tutorial I've seen on django!

Ana

"Your first PR" tutorial

It would be really cool to create a tutorial extension to help attendees fix typo in the tutorial. I'll start working on that ASAP.

Typo in Url in Section "Add publish button"

Hey, I think in the "Add publish button" section the url should read blog/templates/blog/post_detail.html, that is, with templateS in plural, instead of singular as it is now..

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.