-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assignment-2 #27
base: main
Are you sure you want to change the base?
Assignment-2 #27
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are there two apps django-auth and authentication ?
Apply template inheritance and update the PR.
Make the changes where commented.
class CreateUserForm(UserCreationForm): | ||
class Meta: | ||
model = User | ||
fields = ['email', 'password'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
email is not a defined field in UserCreationForm , you'll have to create it statically and then add it in fields.
Refer this for help:
https://stackoverflow.com/questions/48049498/django-usercreationform-custom-fields
from django.db import models | ||
|
||
# Create your models here. | ||
class User(models.Model): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not good, User is a pre-defined class, you should name this something else and not User.
Also you don't need to create a User model , it is predefined in django.
""" | ||
userData = User.objects.filter(email = request.POST["email"],password=request.POST["password"]) | ||
if userData.exists(): | ||
print("user successfully logged in ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick-Note: This print will show data on cmd only and not a webpage.
title = models.CharField(max_length=100) | ||
description = models.TextField() | ||
|
||
user_id = models.ForeignKey(User,on_delete=models.CASCADE,null=True,blank=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change user_id to created_by or author , that will look better.
<h5 class="card-title">{{blog.title}}</h5> | ||
|
||
<p class="card-text">{{blog.description}}.</p> | ||
<a href="update/{{blog.id}}" class="btn btn-primary" role="button"> update this blog</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not the right way for using href , use {% url 'update-blog' blog.id %}
for both update and delete
No description provided.