Skip to content

Commit

Permalink
Added quick fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniDiazTech committed Jun 2, 2021
1 parent 1372763 commit 0a82ca2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
3 changes: 2 additions & 1 deletion config/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
},
]


# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/

Expand All @@ -133,6 +132,8 @@
LOGIN_URL = 'user:login'
LOGIN_REDIRECT_URL = 'photo:list'

LOGOUT_REDIRECT_URL = 'photo:list'

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/

Expand Down
2 changes: 1 addition & 1 deletion config/photoapp/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ class UpdatePhotoForm(forms.ModelForm):
class Meta:
model = Photo

fields = ('title', 'description')
fields = ('title', 'description', 'tags')

4 changes: 3 additions & 1 deletion config/photoapp/templates/photoapp/delete.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{% extends 'base.html' %} {% block body %}
{% extends 'base.html' %}

{% block body %}
<div class="form-group mx-auto">
<h2 class="text-center">
You are going to <span class="text-danger">delete</span>: "<i
Expand Down
9 changes: 2 additions & 7 deletions config/photoapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,16 @@ class PhotoListView(ListView):
context_object_name = 'photos'


class PhotoTagListView(ListView):

model = Photo
class PhotoTagListView(PhotoListView):

template_name = 'photoapp/taglist.html'

context_object_name = 'photos'


# Custom function
def get_tag(self):
return self.kwargs.get('tag')

def get_queryset(self):
return Photo.objects.filter(tags__slug=self.get_tag())
return self.model.objects.filter(tags__slug=self.get_tag())

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
Expand Down
8 changes: 5 additions & 3 deletions config/users/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from django.contrib import auth
from django.views.generic import CreateView

from django.contrib.auth import views, authenticate, login
from django.contrib.auth import authenticate, login

from django.contrib.auth.views import LoginView

from django.contrib.auth.forms import UserCreationForm

Expand All @@ -14,6 +15,7 @@ class SignUpView(CreateView):
form_class = UserCreationForm

success_url = reverse_lazy('photo:list')

def form_valid(self, form):
to_return = super().form_valid(form)

Expand All @@ -26,6 +28,6 @@ def form_valid(self, form):

return to_return

class CustomLoginView(views.LoginView):
class CustomLoginView(LoginView):

template_name = 'users/login.html'

0 comments on commit 0a82ca2

Please sign in to comment.