python-mentorship icon indicating copy to clipboard operation
python-mentorship copied to clipboard

Submissions for Assignment2

Open KenanBek opened this issue 6 years ago • 15 comments
trafficstars

This assignment is based on DevHub. Please check repository before starting with this assignment.

As a task, you need to implement basic functionality for Django 2 project. Video describing all the details:

Video explaining Assignment2

Shortly,

  1. you need to fork this repository
  2. then in assignments/assignment2/solutions create a new folder associated with your username. Example: assignments/assignment2/solutions/kenanbek
  3. as a base version copy assignments/assignment2/devhub-0.1.0 to this directory
  4. start with the implementation of the following tasks

Tasks for Assignment2:

  1. Introduce Django backend and frontend (separate from React frontend)
  2. Introduce database model classes
  3. User register model (via Django frontend)
  4. User login model (via Django frontend)
  5. Setup Docker environment for Django project with Postgres database

In the example folder (assignments/assignment2/solutions/kenanbek) you can find a solution for the first task. Video explaining the solution:

Exact steps to start with the assignment:

cd assignments/assignment2
cp -R devhub-0.1.0 solutions/<YOUR-GITHUB-USERNAME>
cd solutions/<YOUR-GITHUB-USERNAME>
virtualenv venv -p python3
source ./venv/bin/activate
python src/manage.py makemigrations
python src/manage.py migrate
python src/manage.py runserver

These tutorials can be helpful:

  1. Django Web Framework: How to Setup Django 2.1 and Python 3 Example Project Structure with GitHub
  2. Introduction & Custom User Model
  3. Setup URLs, templates and HTML views for Account application

KenanBek avatar Apr 14 '19 17:04 KenanBek

Hi, am having the following error after cloning and running the DevHub app.

Unhandled exception in thread started by <function check_errors..wrapper at 0x7fae1798a620> Traceback (most recent call last): File "/home/nkeumo/Dev/Django/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "/home/nkeumo/Dev/Django/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run autoreload.raise_last_exception() File "/home/nkeumo/Dev/Django/lib/python3.6/site-packages/django/utils/autoreload.py", line 248, in raise_last_exception raise _exception[1] File "/home/nkeumo/Dev/Django/lib/python3.6/site-packages/django/core/management/init.py", line 337, in execute autoreload.check_errors(django.setup)() File "/home/nkeumo/Dev/Django/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper fn(*args, **kwargs) File "/home/nkeumo/Dev/Django/lib/python3.6/site-packages/django/init.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/home/nkeumo/Dev/Django/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate app_config = AppConfig.create(entry) File "/home/nkeumo/Dev/Django/lib/python3.6/site-packages/django/apps/config.py", line 116, in create mod = import_module(mod_path) File "/home/nkeumo/Dev/Django/lib/python3.6/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 953, in _find_and_load_unlocked ModuleNotFoundError: No module named 'account.app'

Nkarnaud avatar Apr 19 '19 09:04 Nkarnaud

@Nkarnaud could you please provide the actions you take to run the app? Do you set src as source root?

KenanBek avatar Apr 19 '19 09:04 KenanBek

Yes the src is my root directory and i run with this command python manage.py runserver

Nkarnaud avatar Apr 19 '19 09:04 Nkarnaud

To solve the issue i have to clone the project from

**CoderVlogger/devhub** and copy it in my project on python mentorship

Nkarnaud avatar Apr 19 '19 10:04 Nkarnaud

@Nkarnaud no, you can use the version which is in assignments/assignment2/devhub-0.1.0.

KenanBek avatar Apr 19 '19 12:04 KenanBek

Steps to start with the assignment:

cd assignments/assignment2
cp -R devhub-0.1.0 solutions/<YOUR-GITHUB-USERNAME>
cd solutions/<YOUR-GITHUB-USERNAME>
virtualenv venv -p python3
source ./venv/bin/activate
python src/manage.py runserver

KenanBek avatar Apr 19 '19 12:04 KenanBek

@KenanBek I use that but it is giving me the above error. i will check on that again

Nkarnaud avatar Apr 19 '19 12:04 Nkarnaud

@Nkarnaud I found error. In src/devhub/settings change this account.app.AccountConfig to this account.apps.AccountConfig.

KenanBek avatar Apr 19 '19 12:04 KenanBek

okay thanks for your feedback

Nkarnaud avatar Apr 19 '19 12:04 Nkarnaud

@Nkarnaud and also in src/account/models.py change this REQUIRED_FIELDS = ['username', 'email'] to REQUIRED_FIELDS = ['email'].

KenanBek avatar Apr 19 '19 12:04 KenanBek

i have already done that

Nkarnaud avatar Apr 19 '19 12:04 Nkarnaud

@Nkarnaud and before runserver run:

python manage.py makemigrations
python manage.py migrate

Let me know if you can run app now.

KenanBek avatar Apr 19 '19 12:04 KenanBek

the app is running now

Nkarnaud avatar Apr 19 '19 12:04 Nkarnaud

I have updated the source code with the fixes in assignments/assignment2/devhub-0.1.0.

KenanBek avatar Apr 19 '19 12:04 KenanBek

the app is running now

Nkarnaud avatar Apr 19 '19 18:04 Nkarnaud