95 questions
1
vote
4
answers
575
views
request.user.is_authenticated is returning False even though `X-Session-Token` header is sent in django-allauth (headless) {app}
I'm using django-allauth (headless, {app}) as my authentication backend along with django-ninja. I've set-up django-allauth configurations properly. If I login using POST http://127.0.0.1:8000/...
1
vote
1
answer
162
views
How to pass self.request data in django form?
I want to pass self.request data in the form class. I can access it in View, but unable to access it in form class.
class AttendanceCreateView(LoginRequiredMixin, CreateView):
model = Attendance
...
0
votes
1
answer
187
views
How to get the session's data of date with `request.session.get()` in Django?
I could get the session's data of data with request.session['key']['key'] as shown below:
# "views.py"
from django.http import HttpResponse
def my_view(request):
request.session['...
0
votes
0
answers
123
views
I tried to run my django project and it shows the following error
(venv) PS C:\Users\User\OneDrive\Desktop\student-management-using-django-main> python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
Exception in thread ...
0
votes
3
answers
370
views
Get email of the current logged in user in Django and filter with it to get specific statistics
When a doctor is logged in with his email and password, his dashboard shows him some statistics:
the number of his patients, the number of his appointments (including past and future appointments)
I ...
0
votes
1
answer
75
views
Unable to use the value in a dictionary in one Django view in another Django view (AttributeError: module 'urllib.request' has no attribute 'session')
I am new to using Django. I have a function in views.py that computes the profit and prints it to a webpage in Django. I store the profit in a dictionary by the name of context and then store it in a ...
0
votes
1
answer
82
views
Flexible Django Filter (django-filter package)
I'm currently implementing some filters and I'm facing multiple problems. First of all my checkbox works when clicking on the brand title, not the actual:
this is my .html code:
<form method="...
-1
votes
1
answer
122
views
Someone help me in this error TypeError at /contact 'method' object is not subscriptable [closed]
Views.py
# Create your views here.
def home(request):
return render(request, 'home.html')
def about(request):
return render(request, 'about.html')
def project(request):
return render(...
1
vote
1
answer
32
views
List of arrivals, per year
I have these three models (I've summarize them):
class Tourist(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
class Etablissement(...
1
vote
1
answer
797
views
Django Error: __init__() takes 1 positional argument but 2 were given
I am new to Django and I'm trying to create my first project following a tutorial from Udemy, but I encounter this error.
My project has the following folder structure:
-demo
__ init__.py
admin.py
...
1
vote
1
answer
1k
views
How do I get the JWT tokens from user in Django RestFramework
I have a DRF project using Simple-JWT for authentication. When a user logs in, they get a response containing the access and refresh tokens in the serializer.data. However:
When testing on the Apis I ...
1
vote
0
answers
121
views
How to enrich the Django request object with extended functions?
In my Django project, I have a situation where different views communicate via a request session data as follows:
def view_one(request):
...
request.session['my_session_key'] = data
...
...
3
votes
2
answers
2k
views
How to get the path name of an URL in view?
I have urls paths with name in my urls.py file.
urls.py
urlpatterns = [
path('home/', views.home, name="home_view"),
]
my views.py
def home(request):
path_name = get_path_name(...
1
vote
2
answers
48
views
Failed to pass html input to django
I'm trying to pass date input to django python script in order to retrieve the data based on it.
Here is my code.
view
def daily_usage_report(request):
if request.method == 'POST':
...
0
votes
0
answers
360
views
Displaying messages through django signals
I'm looking to make a django app that uses signals. (using django signals) There I would like to run some functions, and based on which output they give, send a message within the webpage. so for ...