Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to run the django web server even after closing the shell on Amazon Linux
I'm running a Django application on my Amazon Linux instance using the below command: python manage.py runserver ec2-instance-ip.us-east-2.compute.amazonaws.com:8000 I want the application to be running even after I quit the shell. How do I run this web server even after quitting the shell on Amazon Linux? I tried using the & as shown below, but it didn't work. python manage.py runserver ec2-instance-ip.us-east-2.compute.amazonaws.com:8000 & -
Show Hide conditional statement for select
I'm trying to figure out how to implement a simple show/hide conditional statement on a select HTML tag. If I have a select tag like the following: <select class="form-control" id="accesslevel_id"> <option> Facility </option> <option> Division </option> </select></div> In the example of a user selecting facility or division with the view defined as: facilitycfo = QvDatareducecfo.objects.filter(dr_code__exact = coid, active = 1, cfo_type = 1).values_list('cfo_ntname', flat = True) divisioncfo = QvDatareducecfo.objects.filter(dr_code__exact = coid, active = 1, cfo_type = 2).values_list('cfo_ntname', flat = True) args = {'facilitycfo': facilitycfo,'divisioncfo': divisioncfo} return render(request,'accounts/requestaccess.html', args) How would I display either facilitycfo or divisioncfo queryset depending on the select. I'm not using a form.py file for this example only the template with the view inside a form tag. You'd this something like this would be very trivial without having to use Jquery. I'm in the process of learning so if my logic is incorrect please help clarify. -
Django: cannot login via API
So I have two web-sites: A (the main service) and B (an internal tool). My goal is to auto-login to B via A. So in A I have an endpoint for authorization in B, which simply renders the basic A's login template. If a user successfully logins, then a hidden request is sent to a special B's endpoint (more details on this later), and finally the user gets redirected back to B. At this step I assume, that the user should have already been authenticated in B, but actually it's not the case :( The hidden request to B after authenticating in A simply uses the provided credentials to create/update the corresponding user in B, and also includes the following code snippet: user = auth.authenticate(...) auth.login(request, user) As I said before, this code doesn't work, i.e. after redirecting to B I still have to manually login. The interesting part here is that each time I repeat the workflow mentioned above, a new Session object is created in B, but I guess the session_key of that object is never used. I tried to set the sessionid cookie in the redirect response, but again without success. -
Django FieldError on poly__within
I cannot further find the cause why Django presents an error at the line where I call poly__within to query GeoDjango in PostGIS. My model doesn't have a poly yet the error below says its a FieldError. I do not know where or why its looking for a field for poly Traceback (most recent call last): File "/home/gridlockdev/Desktop/heroku/grace/env/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/home/gridlockdev/Desktop/heroku/grace/env/lib/python3.5/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/gridlockdev/Desktop/heroku/grace/env/lib/python3.5/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/gridlockdev/Desktop/heroku/grace/network/views.py", line 71, in view_routes routes = Route.objects.filter(poly__within= geom[0]) File "/home/gridlockdev/Desktop/heroku/grace/env/lib/python3.5/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/home/gridlockdev/Desktop/heroku/grace/env/lib/python3.5/site-packages/django/db/models/query.py", line 784, in filter return self._filter_or_exclude(False, *args, **kwargs) File "/home/gridlockdev/Desktop/heroku/grace/env/lib/python3.5/site-packages/django/db/models/query.py", line 802, in _filter_or_exclude clone.query.add_q(Q(*args, **kwargs)) File "/home/gridlockdev/Desktop/heroku/grace/env/lib/python3.5/site-packages/django/db/models/sql/query.py", line 1250, in add_q clause, _ = self._add_q(q_object, self.used_aliases) File "/home/gridlockdev/Desktop/heroku/grace/env/lib/python3.5/site-packages/django/db/models/sql/query.py", line 1276, in _add_q allow_joins=allow_joins, split_subq=split_subq, File "/home/gridlockdev/Desktop/heroku/grace/env/lib/python3.5/site-packages/django/db/models/sql/query.py", line 1154, in build_filter lookups, parts, reffed_expression = self.solve_lookup_type(arg) File "/home/gridlockdev/Desktop/heroku/grace/env/lib/python3.5/site-packages/django/db/models/sql/query.py", line 1034, in solve_lookup_type _, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta()) File "/home/gridlockdev/Desktop/heroku/grace/env/lib/python3.5/site-packages/django/db/models/sql/query.py", line 1352, in names_to_path "Choices are: %s" % (name, ", ".join(available))) django.core.exceptions.FieldError: Cannot resolve keyword 'poly' into field. Choices are: agency, agency_id, created_at, distance, duration, ogc_fid, route_color, route_desc, route_id, route_long, route_name, … -
ValueError: invalid literal for int() with base 10: '' I got this error when empty value was sent
I got ValueError: invalid literal for int() with base 10: '' error. I wrote def convert_json(request): json_body = json.loads(request.body) return json_body.get('ans', 0) When I send json like { "ans": "" } the error happens.I really cannot understand why this error happens because I think 0 is returned.In this json,"" means None , so 0 should be returned,I think.But my code did not work wells how should i fix this?What should I write it to make ideal system? -
Looping in django template creating earror in table data
I am using a table in django template. I passed two arrays of objects in context to the template. When i am looping through the two arrays of objects, it is creating problem when the if condition is failing. When if condition is not fulfilled it places the value of later td in the previous ones. Then i tried to apply an else to provide blank td if the condition is not fulfilled. But because of else condition it creates skips the first four blocks in all conditions. I just want to give blank spaces in first for td(table data) if the if condition is not statisfied. <table id="searchFilterNewAdmin" class="table table-striped table-bordered table-hover" > <thead> <tr role="row"> <th class="sorting_asc" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending">Admin Name</th> <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending">Tablet No</th> <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending">Region</th> <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending">Car Make</th> <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending">Total Time(s)</th> <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending">Last Opened</th> <th … -
Django queryset filter model where related objects have ALL a field value
I have two models: class Photo(models.Model): # fields class PhotoTags(models.Model): photo = models.ForeignKey(Photo, related_name="tags") tag_name = models.Charfield() is_disabled = models.BooleanField(default=False) What I'm trying to achieve is to get photos where tags are all with is_disabled = True. EDIT I tried with Photos.objects.filter(tags__is_disabled=True) but it returns photos with at least one tag that is disabled Thank you -
Save items and display the saved items dynamically in Django with Postgresql database
I am new to Django. I am trying to input person names in a HTML page, save it to the Postgresql and show the saved names in the HTML. I need help to create the model.py This is my index.html :- <!DOCTYPE html> <html> <body> <form> First name:<br> <input type="text" name="firstname"> <br> Last name:<br> <input type="text" name="lastname"> <br><br> <input type="submit" value="Submit"> </form> <div class="saved_names"> <!-- Here I am want to display the saved names dynamically --> <li>Micky Mouse</li> <li>Name 2 </li> <li>Name 3 </li> ..... </body> </html> This is view.py :- # homeapp/views.py from django.shortcuts import render from django.views.generic import TemplateView # Create your views here. class HomePageView(TemplateView): def get(self, request, **kwargs): return render(request, 'index.html', context=None) I have successfully connected the Postgres, this is settings.py :- DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'testdb', # DB Name 'USER': 'testuser', # User 'PASSWORD': 'mypass', # Password 'HOST': 'localhost', 'PORT': '5432', } } testdb is my Postgresql database. It has a table called user. user table has three columns id, First_Name, Last_Name . I can create the database, table, columns and also insert the data in the Postgresql columns CREATE DATABASE testdb; CREATE TABLE user ( id serial PRIMARY KEY, First_Name … -
Django Website - TemplateDoesNotExist at /edit/117/
I'm using UpdateView to edit data using forms. After cliking the Edit button a modal is being popped up with a few forms that can be edited and then after I edit and click confirm I get an error: TemplateDoesNotExist at /edit/117/ (or other pk...) DevOpsWeb/serverlist_form.html Request Method: POST Request URL: http://devopsweb:8000/edit/117/ Django Version: 1.11.6 Exception Type: TemplateDoesNotExist Exception Value: DevOpsWeb/serverlist_form.html Why do I get this error? Why when I get the modal the information of the PK is blank...? Does anyone know any of these questions? I'm really stuck :( Thank you! view.py- from django.shortcuts import render_to_response from django.shortcuts import get_object_or_404 from django.shortcuts import render, redirect from django.template import RequestContext from django.views.generic import TemplateView, UpdateView, DeleteView, CreateView from DevOpsWeb.forms import HomeForm from DevOpsWeb.models import serverlist from django.core.urlresolvers import reverse_lazy from simple_search import search_filter from django.db.models import Q class HomeView(TemplateView): template_name = 'serverlist.html' def get(self, request): form = HomeForm() query = request.GET.get("q") posts = serverlist.objects.all() if query: posts = serverlist.objects.filter(Q(ServerName__icontains=query) | Q(Owner__icontains=query) | Q(Project__icontains=query) | Q(Description__icontains=query) | Q(IP__icontains=query) | Q(ILO__icontains=query) | Q(Rack__icontains=query)) else: posts = serverlist.objects.all() args = {'form' : form, 'posts' : posts} return render(request, self.template_name, args) def post(self,request): form = HomeForm(request.POST) posts = serverlist.objects.all() if form.is_valid(): # Checks … -
Celery beat shedule task in runtime doesn't execute with crontab options
I try to schedule task dynamically during the runtime but it doesnt work. task_name = 'my_task_{}'.format(timezone.now()) now = timezone.localtime() + relativedelta(minutes=1) crontab_shedule, _ = CrontabSchedule.objects.get_or_create( minute = str(now.minute) ) PeriodicTask(name=task_name, task=my_p_func, crontab=crontab_shedule).save() This code will save expected records to the database including new timestamp into periodic_tasks last_update column. Running beat worker recognize this changes and correctly rewrite scheduled tasks (new one is including). But nothing more happens. When I schedule task via interval, it works fine. I think the problem is with timezone or something similar. But it seems ok. django_celery_beat.utils.now() This returns correct time for my timezone and crontab record into database is ok too. Using CELERYBEAT_SCHEDULE variable in settings file with crontab works fine too. Interval scheduling in runtime works fine. Starting celery beat celery -A my_project beat -l debug --scheduler django_celery_beat.schedulers:DatabaseScheduler Using django-celery-beat==1.1.0, celery==4.1.0 and broker is redis. I forgot for something? Thank you for your advice. -
Django Imagefield and Legacy Database
I'm working with a legacy database that has images stored in a table. I want to use these images in <img> tags. Do I need to write a script to read all the rows in the table, create a corresponding Django model, then save the model so that the image file is saved to the file system? Or is there a way to do this without iterating through all the old data? Thanks! -
Django Image Not found using template tags
I'm in trouble for many days now and all solutions given didn't helped me yet. The image profile I want to show doesn't appear if I use the template variable {{ userprofile.photo.url}} (the result is the Alt text) but it does work when I put the path to the image like this : /dashboard/media/photo/profils/user.png. I've tried to debug, it seems the url is good but the result given is this : **[27/Nov/2017 13:55:07] "GET /dashboard/ HTTP/1.1" 200 44757 Not Found: /media/photos/profils/user.png [27/Nov/2017 13:55:07] "GET /media/photos/profils/user.png HTTP/1.1" 404 2295** Here the files of the project : Structure of the project : project_dir/ dash-app/ __init__.py settings.py urls.py wsgi.py dashboard/ __init__.py admin.py app.py forms.py models.py urls.py views.py ... templates/ dashboard/ index.html ... static/ dashboard/ images/ logo9.png ... media/ dashboard/ photos/ profils/ user.png ... On the urls.py : from django.conf.urls import url from dashboard import models from dashboard import views from django.conf.urls.static import static from django.conf import settings urlpatterns = [ url(r'^$', views.index, name='index'), ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) On the settings.py : STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static"), ] STATIC_ROOT = os.path.join(BASE_DIR, "dashboard", "static") #dashboard/media/ MEDIA_URL = "/media/" MEDIA_ROOT = os.path.join(BASE_DIR, "dashboard", "media") On the … -
Tastypie - How to only authorize update a model through foreign keys?
A have a Location model that is foreign key in many models. don't want users to be able to create, edit or delete a Location directly (using the /api/v1/location/ endpoint), but i want them to be able to do is while creating an object that has Location as its foreign key. e.g.: /api/v1/event/ { "name": "xxx", "location": { <new location> } } Is it possible? -
How to write tests for django form views?
Django v1.10 FormView code: class PasswordResetConfirmView(FormView): template_name = "dashboard/account/reset_password_form.html" success_url = '/dashboard/' form_class = SetPasswordForm def authenticate_password_token(self, request, uidb64=None, token=None, encodedtimestring=None): try: uid = force_text(urlsafe_base64_decode(uidb64)) user = User.objects.get(pk=uid) timestring = force_text(urlsafe_base64_decode(encodedtimestring)) timestamp = timeparse(timestring) timediff = timezone.now() - timestamp except (TypeError, ValueError, OverflowError, User.DoesNotExist): user = None timediff = None if timediff is None or timediff.days < 0 or timediff.days > PASSWORD_RESET_TIMEOUT_DAYS: messages.error(request, _( 'The reset password link is no longer valid.')) return None if user is None or not default_token_generator.check_token(user, token): messages.error(request, _('The reset password link is not valid.')) return None return user def get(self, request, uidb64=None, token=None, encodedtimestring=None, *arg, **kwargs): form = self.form_class() assert uidb64 is not None and token is not None and encodedtimestring is not None user = self.authenticate_password_token( request, uidb64, token, encodedtimestring) if user is None: return redirect(reverse('dashboard-login')) return self.render_to_response(self.get_context_data(form=form)) def post(self, request, uidb64=None, token=None, encodedtimestring=None, *arg, **kwargs): form = self.form_class(request.POST) assert uidb64 is not None and token is not None and encodedtimestring is not None user = self.authenticate_password_token( request, uidb64, token, encodedtimestring) if user is None: return redirect(reverse('dashboard-login')) if not form.is_valid(): return self.form_invalid(form) new_password = form.cleaned_data['new_password2'] try: with transaction.atomic(): user.auth_token.delete() Token.objects.create(user=user) user.set_password(new_password) user.save() except: messages.error(request, _('Password reset was unsuccessful.')) return redirect(reverse('dashboard-login')) messages.success(request, _('Password has … -
I can not add a slug url to my django app
I am trying to use slug url like /post/5post-title or /post/post-title. I am currently using plain URLs in the form of /post/123 , I tried a lot of methods, and all failed.. Now I am trying "Migrating from primary-key based lookups" from https://keyerror.com/blog/slug-fields-an-alternative-approach and I got a broswer error 'Too many redirections'... How to solve this problem? Or do you have a better method to change the plain url to slug url? My models: class Post(models.Model): title,article and someFields....... def __str__(self): return self.title def get_absolute_url(self): return reverse('blog:detail',kwargs={'pk':self.pk}) def slug(self): return slugify(self.title) and my urls: urlpatterns=[ url(r'^$',views.IndexView.as_view(),name='index'), url(r'^post/(?P<pk>[0-9]+)(?:/(?P<slug>[\w-]+))?$',views.detail,name='detail'),] my views: def detail(request,pk,slug=None): post=get_object_or_404(Post,pk=pk) if slug!=post.slug(): return redirect(post, permanent=True) return render(request,'blog/detail.html',context=context) -
Developing an Informative page for a product
I need to create a web page for an android app which will be published in the app store. I want to know which will be the best approach to create it, because it's just an informative website (contains tutorials, videos, related info), but I need multi language support (several languages will be available) I tried to do a the multi language page by creating several pages with the same content but different strings (localised strings). For example, index.html index_es.html, etc, but this will not scale well if I have several languages. I used to develop with python django, but I don't know if a framework will be too much complexity for this simple website, in this case the internationalisation will be solved. Any ideas? or different approaches ? thanks! -
How to call multiple embedded mongo document objects in a single django view using mongoengine
I have created the django views and models using mongoengine. Below are the code snippets. I am unable to send the posts_1 object to the HTML. Can you please guide me analysing the error. Model.py class C_name(EmbeddedDocument): x_fname = StringField(max_length=200,required=True) x_lname = StringField(max_length=200,required=True) class dummy(Document): x_id = IntField(max_value=5,required=True) x_name= MapField(EmbeddedDocumentField(C_name)) Views.py from django.shortcuts import render_to_response from django.template import RequestContext from sms.models import dummy from django.shortcuts import render def post_index(request): if request.method == 'POST': # save new post x_id = request.POST['x_id'] x_fname = request.POST['x_fname'] x_lname = request.POST['x_lname'] post = dummy(x_id=x_id) post_1 = C_name(x_fname=x_fname,x_lname=x_lname) post.save() posts = dummy.objects posts_1 = c_name.objects context = { 'Sms': posts, 'dd': posts_1 } return render(request,'index.html',context) I am getting the error, c_name does not have the type Objects. Can any one please help me in how to pass embedded mongodb documents in django views Thanks -
How to build and deploy my django app on EC2 instance through Jenkins server?
I am running my application on EC2 instance with nginx+gunicorn setup. I cloned the application manually and did the setup. It is working fine. But, how do I make continuous Integeration& deployment with Jenkins. I couldn't find any EC2 plugins in Jenkins manage. Can anyone tell me what is the Jenkins plugin used to deploy django app on EC2? -
How to avoid getting user private data (user's email) on server (Django Social Auth)
In my Django application I am using Python Social Auth to use Google OAuth for my site's login. As a part of login mechanism the authentication middleware appends User object to reach request. Because of this I can easily access user emails through request.user.email on my server (which I don't want because of my site's privacy policy). So is there a way to use third party authentications systems without getting user emails on my server side. I am fine with writing a code that assigns username/alias for the first time user, which shall be used in future references. -
How to convert datetime that takes the tzinfo to json serializable data?
I get the bellow error: TypeError at /api/pro/list/ datetime.datetime(2017, 12, 24, 11, 12, 13, 932155, tzinfo=<UTC>) is not JSON serializable Through stackoverflow I get the famous error. But all the answer is for: datetime.datetime(2017, 12, 24, 11, 12, 13, 932155) this format, but mine there is timezone info there: tzinfo=<UTC>. How to convert this type datetime to json serializable data? -
django-requestlogging 1.0.1
I am trying to implement a logging in my Django Project (django 1.11, Py 3.6). I'm using default django logger. To get the username in log, I have used django-requestlogging 1.0.1. As of now, I don't have any user other than superuser admin. When I'm trying 'get' request on front-end side, error occurs like 'LogSetupMiddleware' is not callable. I) What is the reason for LogSetupMiddleware not callable? how to make it work? II) How to get 'anonymous' user in log? `Django settings.py` snippet INSTALLED_APPS= [..., 'django_requestlogging', ] MIDDLEWARE = [ .., 'django_requestlogging.middleware.LogSetupMiddleware', .. ] LOGGING = { 'version': 1, 'formatters': {'standard' : { 'format': '%(asctime)s %(username)s %(request_method)s' } } -
CORES django-react application
Getting issue on api call No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8080' is therefore not allowed access. My react app is running at 'http://127.0.0.1:8080' and django api app at 'http://127.0.0.1:8000' -
Can't logging into django admin panel
In production, after entering username and password in order to access django admin panel, the website arrises following error 'OperationalError at /admin/login/ unable to open database file' Here's my settings of db.sqlite3 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # BASE_DIR => /var/www/name_of_website/src where db.sqlite3 stored So far, I have changed the read/write mode of db.sqlite3 to -rw-rw-rw- And it is my apache log file /var/log/apache/error.log [Mon Nov 27 12:16:26.737719 2017] [wsgi:error] [pid 13974] Traceback (most recent call last): [Mon Nov 27 12:16:26.737724 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/db/backends/utils.py", line 65, in execute [Mon Nov 27 12:16:26.737728 2017] [wsgi:error] [pid 13974] return self.cursor.execute(sql, params) [Mon Nov 27 12:16:26.737733 2017] [wsgi:error] [pid 13974] File "/usr/local/lib/python3.5/dist-packages/django/db/backends/sqlite3/base.py", line 328, in execute [Mon Nov 27 12:16:26.737737 2017] [wsgi:error] [pid 13974] return Database.Cursor.execute(self, query, params) [Mon Nov 27 12:16:26.737740 2017] [wsgi:error] [pid 13974] sqlite3.OperationalError: unable to open database file [Mon Nov 27 12:16:26.737744 2017] [wsgi:error] [pid 13974] [Mon Nov 27 12:16:26.737747 2017] [wsgi:error] [pid 13974] The above exception was the direct cause of the following exception: [Mon Nov 27 12:16:26.737751 2017] [wsgi:error] [pid 13974] [Mon Nov 27 12:16:26.737754 2017] [wsgi:error] [pid 13974] Traceback (most recent call last): [Mon Nov 27 … -
How to Sort dictionary in python
i already tried some snippet [{"number": "1"},{"number": "10"},{"number": "101"},{"number": "2"},{"number": "20"}] expected answer should be [{"number": "1"},{"number": "2"},{"number": "10"},{"number": "20"},{"number": "101"}] -
Django: Model clean method called before form clean
I don't understand, why is my model clean method called before full form validation. I have required fields in my form. If I don't fill them, I don't get form errors, instead of, the model clean method is called (so I suppose it's because save is called). It crashes in models clean() method: if self.date_from > self.date_to can't compare datetime.date to NoneType Because I didn't filled date_to field. I think that form should have handle it and raise ValidationError and models save() shouldn't be even called. Create view should inherit form_invalid method. class TripCreationForm(forms.ModelForm): date_from = forms.DateField(required=True) date_to = forms.DateField(required=True) place_id = forms.CharField(widget=forms.HiddenInput(),required=True) class Meta: model = Trip fields = ['date_from','date_to','detail','participants','place_id'] def __init__(self, *args,**kwargs): user = kwargs.pop('user') super(TripCreationForm, self).__init__(*args,**kwargs) fs_helpers.add_widget_attribute('class','datepicker',self.fields['date_from']) fs_helpers.add_widget_attribute('class','datepicker',self.fields['date_to']) self.instance.user = user def clean(self): cleaned_data = super(TripCreationForm,self).clean() city, created = City.objects.get_or_create(place_id=self.cleaned_data['place_id']) self.instance.city = city date_from = self.cleaned_data.get('date_from') date_to = self.cleaned_data.get('date_to') if date_from and date_to and date_from>=date_to: raise ValidationError(_('Date from can\'t be higher that date to')) return cleaned_data This is my view: class TripCreationView(SuccessMessageMixin,CreateView): form_class = TripCreationForm template_name = 'trips/add_new_trip.html' success_message = _('Congratulations! You\'ve added a new trip!') context_object_name = 'trip_creation_form' def post(self, request, *args, **kwargs): # TODO Switch to get_success_url return super(TripCreationView, self).post(self, request, *args, **kwargs) def get_form_kwargs(self): …