django app to change is_active to false for an existing record when i click a button. I…
- User
django app to change is_active to false for an existing record when i click a button. I need models.py, urls.py, views.py and templates
- Assistant
.py files to implement this functionality.
models.py:
codefrom django.db import models class User(models.Model): name = models.CharField(max_length=100) is_active = models.BooleanField(default=True) date_created = models.DateTimeField(auto_now_add=True) def __str__(self): return self.nameurls.py:
codefrom django.urls import path from . import views urlpatterns = [ path('user/<int:pk>/', views.deactivate_user, name='deactivate_user'), ]views.py:
- User
add another button far detail using the same views.py
- Assistant
Sure, here's an updated
urls.pyandviews.pywhich includes a new view for showing user details and a new URL pattern for accessing it:urls.py:
code