- Search the developers, projects, skills using keywords
- Get detailed information about developer
- Get detailed information about each project
- After user is logged in, user is redirected to Edit profile section, where user can add information such as profile picture, bio, skills
- For logged in users the My Account section is available, user can perform CRUD operations to
add new projects and skills, delete those, as well as update
- Logged in users can leave comments and vote for the projects, this way project's rating is calculated
- Pagination implemented
- Login/Logout/Register
- In Progress: Translation to a different language
- The first thing to do is to clone the repository:
$ git clone https://github.com/AnastasiaLunina/django-wecode.git
$ cd django-wecode
- Create a virtual environment to install dependencies in and activate it:
$ python3 -m venv ./env
# Mac/Linux
$ source env/bin/activate
# Windows
venv\Scripts\activate.bat
# Exit venv
deactivate
- Then install the dependencies:
(env)$ pip install -r requirements.txt
- Once
pip
has finished downloading the dependencies:
(env)$ cd project
(env)$ python manage.py runserver
- And navigate to http://127.0.0.1:8000/
Search implemented by quering the value of search_query
attribute from a template
Pagination implemented using Paginator
class built in in Django
landing.search.pagination.mp4
Used User
class from built in Django authentication system, I got user data from the request.POST
and then query it with objects.get
method from User
class instance passing username
as an argument. Then using authenticate
method check if the given credentials are valid, return a User
object. Then redirect user to the same page user was before log in by adding ?next={{request.path}}
to URL
login.mp4
register user with user_register
method in a view and accessing the data from CustomUserCreationForm
which inherits from built in UserCreationForm
class in django.contrib.auth.forms
. After user is regerested and logged in, user redirected to edit profile section.
Used built in decorator @login_required(login_url='login')
to run the method only if user is logged in.
Pass request
as an argument into the edit_profile
method. Django uses request and response objects to pass state through the system.
When a page is requested, Django creates an HttpRequest object that contains metadata about the request. Then Django loads the appropriate view, passing the request as the first argument to the view function.
Then getting particular user with request.user.profile
and adding instance=profile
as an argument to ProfileForm
pre-render user's information in form
register.and.edit.profile.mp4
Used built in decorator @login_required(login_url='login')
to run the function only if user is logged in.
Then getting particular user with request.user.profile
and adding instance=profile
as an argument to ProfileForm
pre-render user's information in form
getting particular user
profile = request.user.profile
accessing the data from model
creating an instance of SkillForm
class
form = SkillForm(request.POST)
checking if the form is valid with built in method form.is_valid()
Then using form.save()
method to create the skill.
getting particular user
profile = request.user.profile
accessing the data from model
form = SkillForm(request.POST, instance=skill)
creating an instance of SkillForm
class
checking if the form is valid with built in form.is_valid()
Then using form.save()
method to update the skill.
This method creates and saves a database object from the data bound to the form.
A subclass of ModelForm can accept an existing model instance as the keyword argument instance; if this is supplied, save() will update that instance. If it’s not supplied, save() will create instead of update a new instance of the specified model:
Getting a particular user
profile = request.user.profile
Quering needed skill from all skills
skill = profile.skill_set.get(id=pk)
Then delete it useng skill.delete()
method
skills.CRUD.mp4
getting current recipient
recipient = Profile.objects.get(id=pk)`
creating an instance of MessageForm
class
form = MessageForm()
To send messages following settings configurations needed
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_USE_TLS = True EMAIL_HOST_USER = 'email.email@gmail.com' EMAIL_HOST_PASSWORD = 'password'
in signals.py
sending.messages.mp4
inbox.mp4
Used django.contrib.messages.api
to send the notifications throughout the app.