Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
azure web app deployment in django not working
when i deploy my django app in azure with sql database it is showing me The page cannot be displayed because an internal server error has occurred.but when i deploy it without sql database it works fine. what is the problem Thank you. -
Django custom authentication with email as username
So I am a bit stuck right now.I know about django user model and what means to extend it..kinda. The thing is that I don't know how to get started... I have a student model where name, surname and student ID are entered in by the admin. Fields of email, phone and photo, are readonly. I want that a student can make an account, where he can enter all those fields himself, but name, surname and student ID need to match with those from database, otherwise he cannot make account. What is a good approach ? class Student(models.Model): name = models.CharField(max_length=50) surname = models.CharField(max_length=50) student_ID = models.CharField(unique=True, max_length=14, validators=[RegexValidator(regex='^.{14}$', message='The ID needs to be 14 characters long.')]) photo = models.ImageField(upload_to='students_images') email = models.EmailField() phone = models.CharField(max_length=15, ) def __str__(self): return self.name + self.surname This is how I started. -
calling values from a different model - Django
A little stuck on this, i'm close to it, but sure i'm missing something I have 2 models. Equipment & Bookings I have a foreign key in Bookings to look up the equipment name works fine. Then in the booking form i want to show the hourly rate of the equipment selected (I will add some more functionally later to multiply by the days or hours selected, but just trying to get it to screen first) I trying to do it with some java script, my console log returns the ID of the equipment so i'm sure the problem is in the view, where i need to add some context for equipment, just no too sure how to do that. Here is the part of the java script i have: $('#id_equipment').on('change',function(){ var equid; equid = $('option:selected', this).attr('value'); console.log(equid); $.get("{% url 'equipment:add-equipmentbooking' %}", {content: equid, name: "equip_sum"}, function(data){ var result = $('<div />').append(data).find('#xhttp').html(); $('#xhttp').html(result); console.log(result) }); }); The logs return the ID of the item selected and the html, but not that data i'm after Here is the current view, only one model class EquipmentBookingCreateView(CreateView): model = EquipmentBooking template_name = 'equipment/equipmentbooking_form.html' form_class = EquipmentBookingForm success_url = '/equipment/list-equipmentbooking' def showval(request): equipment_list = … -
Django project applying user login and registration
hi i am very new in django and really need for your help. i am making a web sit in django which consist 4 small web app(gallery, news, live camera, realtime data).i want to only login user can upload pictures ,see the news ,can use live camera option. so my project struct like that WEBSITE gallery news Camera Realtime data now i want to introduce registration and login logout option.i want ,once user login from homepage ,can use any option(gallery,news etc) so where i write coding for login and registration. inside each webapp? if you can give me any link about this.. very helpful for me -
] ^ SyntaxError: invalid syntax
from django.contrib import admin from django.urls import path from webexample import views from django.conf.urls import url, includes urlpatterns = [ path('admin/', admin.site.urls), path('webexample/', include(webexample.views.index), ] ] ^ SyntaxError: invalid syntax File "C:\Users\admin\Desktop\ccc\mysite\mysite\urls.py", line 23 -
CSS file not loading in Django Progect
I have a CSS file in which i added a background initially to it. Then after some time i added some more background images to my media folder and tried to change the background. But this time, it didn't work. And moreover, the previous background image itself is loaded again. I tried to inspect the webpage. There, in sources, I opened the CSS file. It was not updated. It is still showing the previous background image url. How to rectify this issue? My CSS file(previously): body { background: white url("images/background.png"); } ul.errorlist { padding-left: 0; } ul.errorlist > li { list-style: none; } .navbar { border-radius: 0; } .navbar-brand { font-family: 'Satisfy', cursive; } Then I changed the background image url to: body { background: white url("images/ak.jpg"); } The new image is not loading. When I inspect the element, the previous CSS file is shown. -
Django serializer - unable to pass correct data in Many to Many relation with nested serializers
I am trying to solve this problem : A user can add skills to his profile and other user can upvote the skill on his profile . I have implemented adding skills in system . Now next I am trying build adding a skill (which is already added in system by admins ) to be added to the user profile . But in my POST API , i am always getting following error { "user": { "user": [ "This field is required." ] } } Body Input : { "user":{ "username": "USERN", "email": "diahu@gail.com", "first_name": "", "last_name": "" }, "new_user_skill": { "id": 1, "skill_name": "C" } } My View : elif request.method == 'POST': data = { 'user':request.data.get('user'),'skill_item':request.data.get('new_user_skill')} serializer = UserSkillSerializer(data=data) print("-------------------> serializer ") print(serializer) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) Model : class UserModelSerializer(serializers.ModelSerializer): class Meta: model = User fields = ('username', 'first_name', 'last_name', 'email') extra_kwargs = { 'username': { 'validators': [], } } class UserProfileSerializer(serializers.ModelSerializer): user=UserModelSerializer() class Meta: model = UserProfile fields = '__all__' def create(self, validated_data): user_serializer = UserModelSerializer.create(UserModelSerializer(),validated_data = validated_data) user,created=UserProfile.objects.update_or_create(user=user_serializer) return user class UserSkillSerializer(serializers.ModelSerializer): user = UserProfileSerializer(required=True) skill_item = SkillSerializer(required=True) class Meta: model = UserSkill fields= '__all__' def create (self,validated_data): user_data = … -
Django Query - Prefetch filter based on query data?
Im trying to filter a prefetch based on its parent query object, is this possible? hopefully the below example explains. live link type from SiteData and circuit type from Circuits use the same child model. so for example if the live link type is 'Fibre' I want to prefetch only the circuit that has the circuit_type of 'Fibre'. each site can have many circuits but I only want the live one at this moment This is the query: conn_stats = SiteData.objects.all() .exclude(site_type__site_type='Factory') \ .exclude(site_type__site_type='Data Centre') \ .Prefetch( 'circuits_set', queryset=Circuits.objects.filter(SiteData.objects.live_link_type.circuit_type) ) ) these are the models: class CircuitTypes(models.Model): circuit_type = models.CharField(max_length=50) monitor_priority = models.IntegerField(verbose_name="Monitoring Priority", blank=True, null=True) class Meta: verbose_name = "Circuit Types" verbose_name_plural = "Circuit Types" def __str__(self): return self.circuit_type class SiteData(models.Model): location = models.CharField(max_length=50) site_type = models.ForeignKey(SiteTypes, verbose_name="Site Type", \ on_delete=models.PROTECT) is_live = models.BooleanField(default=False, verbose_name="Is this a live site?") live_link_type = models.ForeignKey(CircuitTypes, verbose_name="Link Type", \ on_delete=models.PROTECT, default=1) live_link_preference = models.CharField(max_length=200, blank=True, null=True) live_link_query_timestamp = models.DateTimeField(auto_now_add=True, blank=True, null=True) class Circuits(models.Model): site_data = models.ForeignKey(SiteData, verbose_name="Site", on_delete=models.PROTECT) order_no = models.CharField(max_length=200, verbose_name="Order No") expected_install_date = models.DateField() install_date = models.DateField(blank=True, null=True) circuit_type = models.ForeignKey(CircuitTypes, verbose_name="Circuit Type", on_delete=models.PROTECT) ... -
SMTPAuthenticationError , username and password not accepted
So I am trying to make a registration form which requires confirmation sent by email before account is created. But I get error: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8 https://support.google.com/mail/?p=BadCredentials g60sm43019864wrd.92 - gsmtp') I already tried the solution for this issues. I allowed low secure apps and also allowed account access(DisplayUnlockCaptcha). I cant seem to find any more fixes for this. def activate(request, uidb64, token): try: uid = force_text(urlsafe_base64_decode(uidb64)) user = User.objects.get(pk=uid) except(TypeError, ValueError, OverflowError, User.DoesNotExist): user = None if user is not None and account_activation_token.check_token(user, token): user.is_active = True user.save() login(request, user) # return redirect('index') return HttpResponse('Thank you for your email confirmation. Now you can login your account.') else: return HttpResponse('Activation link is invalid!') message = render_to_string('acc_active_email.html', { 'user': user, 'domain': current_site.domain, 'uid': urlsafe_base64_encode(force_bytes(user.pk)).decode(), 'token': account_activation_token.make_token(user), }) EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = 'youremail@gmail.com' EMAIL_HOST_PASSWORD = 'yourpassword' EMAIL_PORT = 587 Traceback: http://dpaste.com/2S96YSK -
How to use a form showing selected and not selected in Django Admin
In django admin the Groups element of the Change User form gives you two lists with arrows to move from one list to the other. Something like the attached. I have a many to many field where I would like Django Admin to use this form but I cannot find out how to use it. Can anyone help? Thanks -
Using Django CreateView how can I access the request.session.user variable?
class ViewCreate(CreateView): model = view_C author_name = self.request.user.username #this is the error author = get_user_model().objects.get(username=author_name).pk publish_date = datetime.date.today() initial={ 'author':author, 'publish_date':publish_date, } author_name = self.request.user.username ... NameError: name 'self' is not defined How do I access the request.user variable from within a subclass of CreateView? I am trying to make use of a CreateView were the entries for author are automatically filled in using the session data and so don't have to be manaully entered. -
Return serializer data of a SET in Serializers.py in Django Rest Framework
I use Django Rest Framework for my project. I have a serializer function which return a SET but I dont know how to return it into data. Please help me! class BookSerializer(ModelSerializer): class Meta: model = Book fields = [ 'pk', 'book_name', ] class UserSerializer(ModelSerializer): booklist = SerializerMethodField() class Meta: model = User fields = [ 'username', 'booklist', ] def get_booklist(self, obj): ... booklist = set(result_user_obj).intersection(result_user_req) # Return data: [5, 2] ##### How to return it by BookSerializer????? ##### return booklist I want to print result: [{pk: 5, book_name: A}, {pk:2, book_name: B}] instead of [5, 2] -
Can't find model related descriptor field in django
I've checked a field class in the model and it is: django.db.models.fields.related_descriptors.RelatedManager I can't find in any file this field to be declared, where it may be stored or how to find it? -
Collect remarks for task in django-viewflow
Is there way to collect remarks for specific task when user submits his task form? Lets say i have below step to perform approval, where i'm exposing only ìs_approvedfield which will get stored in actual process model. Now along with ìs_approved, i also want to capture remarks for the same task. approve = ( flow.View( UpdateProcessView, fields=["is_approved"], task_title="Approve the document" ).Permission( lambda process: 'core.can_approve_{}'.format(process.process.type) ).Next(this.check_approve) ) -
What does a parameter without equal in a django models.Field means?
I was reviewing a django repo in git hub and find this way of fields declaration from django.utils.translation import ugettext_lazy as _ class Usuario(AbstractBaseUser, PermissionsMixin): usuario = models.CharField(_('Usuario'), max_length=60, unique=True) is_staff = models.BooleanField(_('staff status'), default=False) I don't understand for what is the _('Usuario') and _('staff status') parameters. Could someone explain me this? Thanks -
Unable to save django form after added queryset filter in __init__ method
I've filtered a field queryset from my django form and now suddenly in html page when i hit submit it doesn't save anymore but if i comment the method, I can save again. Any help is much appreciated below is my code model : class Model_A(models.Model): project_name = models.CharField(max_length=50, unique=True) project_manager = models.ForeignKey(Employee, on_delete=models.CASCADE, related_name='project_manager', null=True, blank=True) def __str__(self): return self.project_name form.py : class EditProjectForm(forms.ModelForm): prefix = 'edit_form' class Meta: model = Model_A fields = '__all__' #Save failed after adding this method def __init__(self, user, *args, **kwargs): super(EditProjectForm, self).__init__(*args, **kwargs) self.fields['project_manager'].queryset = Employee.objects.filter(department__in=[18, 19, 20]).exclude(employment_status=6) view.py : def project_setting(request, project_id): form = EditProjectForm(request.POST or None, request.FILES or None, instance=selected_project, prefix='settings') if form.is_valid(): inst = form.save(commit=False) inst.save() form.save_m2m() return HttpResponseRedirect('/projects/{}/setting'.format(project_id)) context = { 'form': form, } return render(request, '/projects/setting.html', context=context) -
only show the root nodes in django treebeard
I have a category in following form Home Bedroom Office Here Home and Office are only the root node. I wanted to show them in a grid but also the Bedroom is displayed. The code I tried is the following <div class="container"> <div class="row category-header"> {% category_tree depth=2 as tree_categories %} {% if tree_categories %} {% for tree_category, info in tree_categories %} <div class="col-sm-12 col-md-6"> {% if info.has_children %} <li class="dropdown-submenu"> <a tabindex="-1" href=""> <img src="media/{{ tree_category.image }}" class="img-responsive" alt={{ tree_category.name }}> {{ tree_category.name }} </a> <ul class="dropdown-menu"> {% else %} <li> <a tabindex="-1" href=""> <img src="media/{{ tree_category.image }}" class="img-responsive" alt={{ tree_category.name }}> {{ tree_category.name }} </a> </li> {% endif %} {% for close in info.num_to_close %} </ul> </li> {% endfor %} </div> {% endfor %} {% endif %} </div> </div> How do i show only the Home and Office in 2 column? The way i am trying is a hacky -
Return NoneType on queryset django REST framework
Problem : I am getting an error like this : Traceback: File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py" in inner 41. response = get_response(request) File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/csrf.py" in wrapped_view 58. return view_func(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/rest_framework/viewsets.py" in view 87. return self.dispatch(request, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/rest_framework/views.py" in dispatch 474. response = self.handle_exception(exc) File "/usr/local/lib/python2.7/dist-packages/rest_framework/views.py" in handle_exception 434. self.raise_uncaught_exception(exc) File "/usr/local/lib/python2.7/dist-packages/rest_framework/views.py" in dispatch 471. response = handler(request, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/rest_framework/mixins.py" in list 42. page = self.paginate_queryset(queryset) File "/usr/local/lib/python2.7/dist-packages/rest_framework/generics.py" in paginate_queryset 172. return self.paginator.paginate_queryset(queryset, self.request, view=self) File "/usr/local/lib/python2.7/dist-packages/rest_framework/pagination.py" in paginate_queryset 311. self.count = _get_count(queryset) File "/usr/local/lib/python2.7/dist-packages/rest_framework/pagination.py" in _get_count 54. return len(queryset) Exception Type: TypeError at /api/userprofiles/ Exception Value: object of type 'NoneType' has no len() What I am trying to do : I just want people to get their own profile, when they connect to the api, so instead of applying UserProfile.objects.all , I thought it would be better if I used UserProfile.objects.get(user=request.user). But as you can well see it isn't working, perhaps because pagination has some problem cause it is trying to get len() but the object it's getting is NoneType although I printed the queryset just after it's … -
Trying to query based on choice field django
I've been stuck on this all day. I've got a model, Load, within that model it has a choice field with different "statuses". I am trying to implement some tabbed views in my template. So basically each tab will be responsible for displaying a certain status. I believe that I should be using a queryset within my view get_context_data but I'm just not really understanding how to accomplish this. I've tried a ton of different ways in the view, so i'll just paste the latest attempt. These query's will be static once they are done so my best thought was to use a model managers for each query, but I couldn't get multiple model managers to work on one model. Here's an example of one. Any help would be appreciated. Thank you class BookedManager(models.Manager): def get_queryset(self): return super(BookedManager, self).get_queryset().filter(load_status='Booked') Models.py class Load(models.Model): load_number = models.IntegerField() agent = models.ForeignKey(User, limit_choices_to={'groups__name': 'Agent'},related_name='Agent', on_delete=models.CASCADE, null=True) customer = models.ForeignKey(User, limit_choices_to={'groups__name': 'Customer'},related_name='Customer', on_delete=models.CASCADE) carrier = models.ForeignKey(Carrier, on_delete=models.CASCADE, blank=True, null=True) pickup_date = models.DateField() delivery_date = models.DateField() shipper = models.ForeignKey(Location, related_name='shipper', on_delete=models.CASCADE, blank=True) consignee = models.ForeignKey(Location, related_name='consignee', on_delete=models.CASCADE, blank=True) po_number = models.CharField(max_length=255) pu_number = models.CharField(max_length=255) pieces = models.IntegerField() description = models.TextField() date_created = models.DateTimeField(auto_now_add=True) PREBOOK = 'Waiting … -
Having a django model that can only contain a specified number of rows
I want to create a Django Group model whose members are in a Django Person Model...The Person instance can only occur in a specific number of groups...and a group can only accommodate a specific number of person instances -
How to do Django Database routing for two database in same app?
I am new to django, facing challenge of using two different database in my same App I have done something like this. DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'projectDb', 'USER': 'piyush', 'PASSWORD': 'piyush@123', 'HOST': 'localhost', 'PORT': '5432', }, 'vendor': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'vendorDb', 'USER': 'piyush', 'PASSWORD': 'piyush@123', 'HOST': 'some_rds_end_point', 'PORT': '5432', } } For both the Database I need read and write access , I have refer DjangoDoc but still confused, how to write DATABASE_ROUTERS for this. Please help me. -
Exception in worker process while running heroku open
I am trying to deploy my django app on heroku, after running git push heroku master , when i do heroku open , it gives Application error. heroku logs command shows : [2018-01-21 05:25:17 +0000] [10] [ERROR] Exception in worker process 2018-01-21T05:25:17.928006+00:00 app[web.1]: Traceback (most recent call last): 2018-01-21T05:25:17.928007+00:00 app[web.1]: File "/app/.heroku/python /lib/python2.7/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker 2018-01-21T05:25:17.928009+00:00 app[web.1]: worker.init_process() 2018-01-21T05:25:17.928010+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process 2018-01-21T05:25:17.928011+00:00 app[web.1]: self.load_wsgi() 2018-01-21T05:25:17.928012+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi 2018-01-21T05:25:17.928013+00:00 app[web.1]: self.wsgi = self.app.wsgi() 2018-01-21T05:25:17.928014+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 2018-01-21T05:25:17.928015+00:00 app[web.1]: self.callable = self.load() 2018-01-21T05:25:17.928016+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load 2018-01-21T05:25:17.928016+00:00 app[web.1]: return self.load_wsgiapp() 2018-01-21T05:25:17.928018+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp 2018-01-21T05:25:17.928018+00:00 app[web.1]: return util.import_app(self.app_uri) 2018-01-21T05:25:17.928019+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 352, in import_app 2018-01-21T05:25:17.928020+00:00 app[web.1]: __import__(module) 2018-01-21T05:25:17.928021+00:00 app[web.1]: File "/app/mysite/wsgi.py", line 16, in <module> 2018-01-21T05:25:17.928023+00:00 app[web.1]: application = get_wsgi_application() 2018-01-21T05:25:17.928023+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application 2018-01-21T05:25:17.928024+00:00 app[web.1]: django.setup(set_prefix=False) 2018-01-21T05:25:17.928025+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/__init__.py", line 27, in setup 2018-01-21T05:25:17.928026+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS) 2018-01-21T05:25:17.928027+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate 2018-01-21T05:25:17.928028+00:00 app[web.1]: app_config = AppConfig.create(entry) 2018-01-21T05:25:17.928029+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/config.py", line 94, in create 2018-01-21T05:25:17.928030+00:00 app[web.1]: module = import_module(entry) 2018-01-21T05:25:17.928031+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in … -
supervisord prints logs only when stopped server
so this is what I print in python with flushing: import sys print "getting detailed" sys.stdout.flush() then i check the logs file and it is empty, so then I stop the server: supervisorctl stop my-project and the logs file is filled with messages from the print above, so the question is how to make it print to the log file without stopping the server? -
Django Formset Redirect with pk/id
I'm trying to pass in the parent id of a formset into a view, but it doesn't seem to work for me for some reason. I do this in other apps without issue but this particular one returns "None" as a pk. The only difference being my formset model doesn't usually contain a foreignkey relationship. If I render the parent by itself, I can pass the pk just fine. Please help :) Exception Value: Reverse for 'company-detail' with keyword arguments '{'pk': None}' not found. 1 pattern(s) tried: ['customers/(?P[0-9a-z-]+)/detail/$'] ''' forms.py ''' class CompanyCreateForm(forms.ModelForm): class Meta: model = CompanyModel fields = [ 'name', 'website', 'rate', ] widgets = { 'name': forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': ''}), 'website': forms.URLInput(attrs={ 'class': 'form-control', 'placeholder': ''}), 'rate': forms.NumberInput(attrs={ 'class': 'form-control', 'placeholder': ''}), } SitesFormSet = inlineformset_factory( CompanyModel, SiteModel, fields=('street1', 'street2', 'city', 'state', 'zipcode', 'country', 'phone', 'distance', ), widgets={ 'street1': forms.TextInput(attrs={ 'class': 'form-control' }), 'street2': forms.TextInput(attrs={ 'class': 'form-control' }), 'city': forms.TextInput(attrs={ 'class': 'form-control' }), 'state': forms.TextInput(attrs={ 'class': 'form-control' }), 'zipcode': forms.NumberInput(attrs={ 'class': 'form-control' }), 'country': forms.TextInput(attrs={ 'class': 'form-control' }), 'phone': forms.TextInput(attrs={ 'class': 'form-control' }), 'distance': forms.NumberInput(attrs={ 'class': 'form-control' }) }, extra=1 ) ''' views.py ''' def companycreateview(request): if request.method == 'POST': companyform = CompanyCreateForm(request.POST) if companyform.is_valid(): company … -
django core 'dict' object is not callable
Django 2.0.1 python 3.6.3 Hi I have an address form which is a kind of extended user model form. The form asks for name, birth-date, address and phone info. I do some form validation on the form fields, for example the birth-date entered must be at least 18 years ago. I also overwrite the form's clean method to verify the US address via the USPS address api. After the address info is verified the validated/normalized address values returned from the USPS are put into the cleaned_data dict and are returned. After the cleaned_data return, Django eventually calls _get_response() in django/core/handlers/base.py. There is a section ... if response is None: wrapped_callback = self.make_view_atomic(callback) try: response = wrapped_callback(request, *callback_args, **callback_kwargs) except Exception as e: response = self.process_exception_by_middleware(e, request) that throws the error: TypeError at / 'dict' object is not callable What does that mean in this context?