Guest User

Untitled

a guest
Jul 27th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. IN forms.py
  2.  
  3. __________________________
  4. class LoginForm(forms.ModelForm):
  5.  
  6.  
  7. password= forms.CharField(widget=forms.PasswordInput(
  8. attrs={
  9. 'class': 'form-control',
  10. 'placeholder' : 'password',
  11. }
  12. ))
  13. username = forms.CharField(widget=forms.TextInput(
  14. attrs={
  15. 'class': 'form-control',
  16. 'placeholder': 'User Name',
  17. }
  18. ))
  19.  
  20. class Meta:
  21. model = User
  22. fields = [ 'username' , 'password']
  23.  
  24.  
  25.  
  26. ____________________________________________________________________________
  27. ____________________________________________________________________________
  28.  
  29.  
  30. in urls.py
  31.  
  32. ______________________________
  33.  
  34. from django.urls import path
  35. from . import views
  36. from django.contrib.auth import views as auth_views
  37. from .forms import LoginForm
  38.  
  39.  
  40. app_name = 'music'
  41.  
  42. urlpatterns = [
  43.  
  44.  
  45. #Register
  46. path('register', views.UserFormsView.as_view(), name ='register'),
  47. # /music
  48. path('', views.IndexView.as_view(), name ='index'),
  49. # /music/123
  50. path('<int:pk>/', views.DetailView.as_view(), name = 'detail'),
  51.  
  52. #/music/add/$
  53.  
  54. path('album/add/' , views.AlbumCreate.as_view(), name = 'album-add'),
  55.  
  56. #/music/2/$
  57.  
  58. path('album/<int:pk>/' , views.AlbumUpdate.as_view(), name = 'album_update'),
  59.  
  60. #/music/2/delete$
  61.  
  62. path('album/<int:pk>/delete' , views.AlbumDelete.as_view(), name = 'album_delete'),
  63.  
  64. #logout
  65. path('logout/', views.logout_view , name = 'logout'),
  66.  
  67. #LoginForm
  68. path('login/', auth_views.login, {'template_name': 'music/login.html' , 'authentication_form' : 'LoginForm'} , name = 'login'),
  69. ]
Add Comment
Please, Sign In to add comment