Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django 1.8 test issue: ProgrammingError: relation "auth_user" does not exist
I recently upgraded Django to 1.8 and set up a new development database for a fresh start. Migrations and dependencies went well, safe the usual errors you get and you end up solving. The app is working locally now just fine. However, I am getting an error when trying to run tests: python manage.py test This is the error I am getting: django.db.utils.ProgrammingError: relation "auth_user" does not exist Needless to say, Django's auth module is indeed installed and migrated in the app, so I am not sure what is going on. Here is the full stacktrace in case you need to peek at it, but it does't say anything even remotely helpful to me to figure out the cause of this error: Traceback (most recent call last): File "C:/Users/dabadaba/PycharmProjects/dogpatchsports_com/mysite/manage_sched_dev.py", line 10, in <module> execute_from_command_line(sys.argv) File "C:\Users\dabadaba\Envs\django18\lib\site-packages\django\core\management\__init__.py", line 354, in execute_from_command_line utility.execute() File "C:\Users\dabadaba\Envs\django18\lib\site-packages\django\core\management\__init__.py", line 346, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\dabadaba\Envs\django18\lib\site-packages\django\core\management\commands\test.py", line 30, in run_from_argv super(Command, self).run_from_argv(argv) File "C:\Users\dabadaba\Envs\django18\lib\site-packages\django\core\management\base.py", line 394, in run_from_argv self.execute(*args, **cmd_options) File "C:\Users\dabadaba\Envs\django18\lib\site-packages\django\core\management\commands\test.py", line 74, in execute super(Command, self).execute(*args, **options) File "C:\Users\dabadaba\Envs\django18\lib\site-packages\django\core\management\base.py", line 445, in execute output = self.handle(*args, **options) File "C:\Users\dabadaba\Envs\django18\lib\site-packages\django\core\management\commands\test.py", line 90, in handle failures = test_runner.run_tests(test_labels) File "C:\Users\dabadaba\Envs\django18\lib\site-packages\django\test\runner.py", line 210, in run_tests old_config = … -
Not transferring project to server when git push
I have a django project under development on my windows computer (dev-machine). I am using pyCharm for development. I have set up a server (server-machine) running ubuntu. And now want to push my project to the server. So in my project folder on the dev-machine I have done the git init: $ git init $ git add . $ git commit -m"Init of Git" And on the server-machine I have made a project folder: /home/username/projects In this folder I init git as well $ git init --bare Back on my dev-machine, I set the connection to the server-machine by doing this $ git remote add origin username@11.22.33.44:/home/username/projects And finally pushing my project to server-machine by typing this command on my dev-machine $ git push origin master It starts to do ome transfer. And here's the problem. On the server-machine when I check what's been transferred, it's only stuff like this ~/projects$ ls branches config description HEAD hooks info objects refs Not a single file from the project is transferred. This looks much like what the .git folder contains on the dev-machine. What am I doing wrong? -
How to make token based api with tastypie
I need to implement using api such behavior: App opening without registration If it's new user, then send signup request, and get new session If there is a session, then check it. So I think I need /signup method which creates session and returns a session token. And /check method which gets a token and returns check result. So, how to make token based api with django and tastypie? -
Change to django's urls.py not reflected online
I haven't touched my Django application in quite some time. Long enough to have forgotten these simple things. I'm running my Django application using nginx and uwsgi. I made some changes in my urls.py, adding one new line: url(r'^collections/',views.collections), When I navigate to the correct URL, it shows me the Django 404 page with attempted URL patterns, which doesn't show the newly added line. Previous related questions told me to restart NGINX and UWSGI,which I've done. The problem continues however. -
Why I m unable to create project in Django in Ubuntu 17.04
Why Django is not working I installed python 3 ,pip and virtualenr successfully but still I m unable to run Django app.what should I do. Where is the problem plz help. -
Organizing safety of uploaded files
Django==1.11.6 models.py class ItemFile(models.Model): file = models.FileField(blank=False, max_length=255, upload_to=get_item_path, verbose_name=_("file")) In my project files is the most valuable information. Files will be uploaded only through Django admin. But files are provided by different people. Therefore filenames may really be unpredictable. What I'd like to do: Rename the file just to be on the safe side. Save original file name in the database. Calculate hash of the file with md5. Reason: files may be damaged in course of time (reasons may be various). Before backing up the database, I'll run a script to check the files. It is early detection of problems with files. If at point 1 a new filename will be the same hexdigest as in point 3, that would be great. Could you help me understand whether this idea with checksums of file is Ok or garbage. If it is, I'm planning to organize this all in the handler of post_save signal. Anything else seems impossible before the file is really saved. -
Continuous updating image - django
What I am looking to achieve is to have a page hosted by django. One part of this page will be an svg image which I retrieve as a parameter from within one of my programs objects. Basically what I want is to be able to update the svg image without having to refresh the page. Im also going to have a second html element that I want to update in a similar method. -
Django: Widget that queries database based on current text in text field?
I'm creating a workout calendar where users, among other things, can add workouts to their own calendar. To let users add a workout, I want to create an addworkout view that contains a form. Of course, an important part of a workout is the lifts it entails, such as benchpress, deadlift, etc. The names of the lifts will be entered in a text field. Now, since the users will often be typing in names of lifts that are well known, I intend to keep a bunch of lists stored in a model: from mongoengine import * class Lift(EmbeddedDocument): lift_id = IntField(unique=True) name = StringField(max_length=200) #e.g. bench press, etc sets = ListField(IntField()) # No of reps in each set def __str__(self): return self.name Then, when a user enters some text in a text field, I want the browser to query the database based on the text in the text field, and display all the matching lifts in a rolldown as suggestions. For example, if a user types "Dumbbell" into the text field, I want him/her to see a rolldown bar (is that what it's called?) with the suggestions "Dumbbell press", "Dumbbell row", etc. It's similar in functionality to how Google suggests … -
@transaction.atomic not working on signals.py
This is my signals.py file @transaction.atomic def post_save_transaction(sender, instance, created, **kwargs): """ adjusts the patient or organization account balance on transaction """ if created: instance.paid_by.balance -= instance.amount instance.accounts.balance += instance.amount instance.accounts.save(update_fields=['balance']) instance.paid_by.save(update_fields=['balance']) for multiple objects creation at a time this transaction work but use the previous balance again. -
Download intraday historical data of all Dow Jones stocks and put in a dataframe with one timestamp and index
I want to download all DJI stocks intraday historical data and assign one timestamp and index for all with stock ticker used as the name of each column. Here is my code but it not working. I know a little tweak would make it work. def High_Frequency_data(symbol, period, window): x = pd.DataFrame(parsed_data) for i in symbol: url_root = 'http://www.google.com/finance/getprices?i=' url_root += str(period) + '&p=' + str(window) url_root += 'd&f=d,o,h,l,c,v&df=cpct&q=' + symbol response = urllib2.urlopen(url_root) data = response.read().split('\n') #actual data starts at index = 7 #first line contains full timestamp, #every other line is offset of period from timestamp parsed_data = [] anchor_stamp = '' end = len(data) for i in range(7, end): cdata = data[i].split(',') if 'a' in cdata[0]: #first one record anchor timestamp anchor_stamp = cdata[0].replace('a', '') cts = int(anchor_stamp) else: try: coffset = int(cdata[0]) cts = int(anchor_stamp) + (coffset * period) parsed_data.append((dt.datetime.fromtimestamp(float(cts)), float(cdata[1]), float(cdata[2]), float(cdata[3]), float(cdata[4]), float(cdata[5]))) except: pass # for time zone offsets thrown into data x = x.append(parsed_data) x = pd.DataFrame(parsed_data) x.columns = ['ts', 'Open', 'High', 'Low', 'Close', 'Volume'] x.index = x.ts del x['ts'] return x print x symbol = ['AAPL','AXP','BA','CAT','CSCO','CVX','KO','DD','XOM','GE', 'GS','HD','IBM','INTC','JNJ','JPM','MCD','MMM','MRK','MSFT', 'NKE','PFE','PG','TRV','UNH','UTX','VZ','WMT','DIS'] High_Frequency_data(symbol,7200,252) -
My template do not shows the context_processors's data
In the blog/context_processors.py, I have a custom function: def custom_proc(request): user = {'name': 'allen', 'sex': 'man'} return user And I also add to the context processors in settings.py: TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.i18n", "testMulToM.context_processors.custom_proc", # add there ) But when I run my server, and request the url to template, it do not fill the data to template: my app04/index.html template: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> User: {{ name }} : {{ sex }} </body> </html> My app04/views.py: def index(request): return render(request, 'app04/index.html') -
Custom JSON Structure in Django for Highcharts
I am currently using Django 1.11 and Highcharts to accomplish a project of mine. I am finding utility quite useful and it's easy integration is especially cool! I am stuck with a problem : I need to show column chart with DrillDown : [e.g : https://www.highcharts.com/demo/column-drilldown ] And I need the "data" part from my Django Model for both Drilldown and Accumulated data shown in the data section at the top. : // Chart data : data: [{ name: 'Microsoft Internet Explorer', y: 56.33, drilldown: 'Microsoft Internet Explorer' }, { name: 'Chrome', y: 24.03, drilldown: 'Chrome' }, { name: 'Firefox', y: 10.38, drilldown: 'Firefox' }, { name: 'Safari', y: 4.77, drilldown: 'Safari' }, { name: 'Opera', y: 0.91, drilldown: 'Opera' }, { name: 'Proprietary or Undetectable', y: 0.2, drilldown: null }] drilldown: { series: [{ name: 'Microsoft Internet Explorer', id: 'Microsoft Internet Explorer', data: [ [ 'v11.0', 24.13 ], [ 'v8.0', 17.2 ], [ 'v9.0', 8.11 ], [ 'v10.0', 5.33 ], [ 'v6.0', 1.06 ], [ 'v7.0', 0.5 ] ] }, { name: 'Chrome', id: 'Chrome', data: [ [ 'v40.0', 5 ], [ 'v41.0', 4.32 ], [ 'v42.0', 3.68 ], [ 'v39.0', 2.96 ], [ 'v36.0', 2.53 ], [ 'v43.0', … -
Dynamically split a dictionary into multiple dictionaries in python3.6 depending on input provided
I am using Python 3.6 with Django Framework. I am getting input from the user & that input comes in the form of dictionary in my views.py. Lets say, the user enter 3 values than my dictionary will hold value like my_dict = {'name1': abc, 'job1': xyz, 'pos1':tak, 'phone1': 12345, 'name2': pqr, 'job2': ftr, 'pos2': lkj, 'phone2': 27654, 'name3': swq, 'job3': nme, 'pos3': mnb, 'phone3': 98421} I am looking to create sub dictionaries depending on the user input, in above case 3. Expected output is dict1 = {'name1': abc, 'job1': xyz, 'pos1': tak, 'phone1': 12345} dict2 = {'name2': pqr, 'job2': ftr, 'pos2': lkj, 'phone2': 27654} dict3 = {'name3': swq, 'job3': nme, 'pos3': mnb, 'phone3': 98421} Now, the catch here is we don't know what number of records we get from user, so sub dictionaries also need to be created dynamically. "dict1" to "dictn" where "n" is number given by user. Please suggest! -
show distance of restaurant from user
show distance of restaurant from user location I have implemented the feature of showing nearby restaurant from the given coordinates using postgis and geodjango. I am showing the list of restaurant so I could not show something like '5km' away. Here is what I have done to show the list of restaurant nearby url(r'^nearby_restaurant/(?P<current_lat>-?\d*.\d*)/(?P<current_long>-?\d*.\d*)/$', views.nearby_restaurant_finder, name="nearby-restaurant"), class Restaurant(models.Model): user = models.OneToOneField( User, on_delete=models.CASCADE, related_name='restaurant' ) name = models.CharField(max_length=500) restaurant_slug = models.SlugField(max_length=250, unique=True) location = gis_models.PointField(blank=True, null=True, geography=True) gis = gis_models.GeoManager() objects = models.Manager() def nearby_restaurant_finder(request, current_lat, current_long): from django.contrib.gis.geos import Point from django.contrib.gis.measure import D user_location = Point(float(current_long), float(current_lat)) distance_from_point = {'km': 50} restaurants = Restaurant.gis.filter( location__distance_lte=(user_location, D(**distance_from_point))) restaurants = restaurants.distance(user_location).order_by('distance') context = { 'restaurants': restaurants } return render(request, 'restaurant/nearby_restaurant.html', context) What else should I consider for showing the distance of that restaurant from user? -
I wanna set minlength&maxlength in template of input tag
I wrote in index.html <div class="heading col-lg-6 col-md-12"> <h2>New account registration</h2> <form class="form-horizontal" action="regist_save/" method="POST"> <div class="form-group-lg"> <label for="id_username">username</label> {{ regist_form.username }} </div> <div class="form-group-lg"> <label for="id_email">email</label> {{ regist_form.email }} </div> <div class="form-group-lg"> <label for="id_password">password</label> {{ regist_form.password1 }} </div> <div class="form-group-lg"> <label for="id_password">password(conformation)</label> {{ regist_form.password2 }} <p class="help-block">{{ regist_form.password2.help_text }}</p> </div> <div class="form-group-lg"> <div class="col-xs-offset-2"> <button type="submit" class="btn btn-primary btn-lg">SUBMIT</button> <input name="next" type="hidden"/> </div> </div> {% csrf_token %} </form> </div> I wanna set minlength&maxlength in template of username&password input tag.If i wrote in html stye,it is <form class="form-horizontal" action="regist_save/" method="POST"> <div class="form-group-lg"> <label for="id_username">username</label> <input id="id_username" name="username" type="text" value="" minlength="5" maxlength="12" placeholder="username" class="form-control"> </div> <div class="form-group-lg"> <label for="id_email">email</label> {{ regist_form.email }} </div> <div class="form-group-lg"> <label for="id_password">password</label> <input id="id_password1" name="password1" type="password1" value="" minlength="8" maxlength="12" placeholder="password1" class="form-control"> </div> <div class="form-group-lg"> <label for="id_password">password(conformation)</label> <input id="id_password2" name="password2" type="password2" value="" minlength="8" maxlength="12" placeholder="password2" class="form-control"> <p class="help-block">{{ regist_form.password2.help_text }}</p> </div> <div class="form-group-lg"> <div class="col-xs-offset-2"> <button type="submit" class="btn btn-primary btn-lg">SUBMIT</button> <input name="next" type="hidden"/> </div> </div> {% csrf_token %} </form> in forms.py class RegisterForm(UserCreationForm): class Meta: model = User fields = ('username', 'email','password1','password1',) def __init__(self, *args, **kwargs): super(RegisterForm, self).__init__(*args, **kwargs) self.fields['username'].widget.attrs['class'] = 'form-control' self.fields['email'].widget.attrs['class'] = 'form-control' self.fields['password1'].widget.attrs['class'] = 'form-control' self.fields['password2'].widget.attrs['class'] = 'form-control' in views.py @require_POST def regist_save(request): regist_form … -
How to install django spirit ? I am getting the error command not found: spirit
I tried install django spirit using mkvirtualenv env -p /usr/bin/python3 pip install django-spirit spirit startproject mysite - it says spirit command not found Any solutions ? -
How to set up ALLOWED_HOSTS in digital ocean
I successfully hosted my Django code in digital ocean with DNS.After hosted I'm getting weird output in my browser. when I enter example.com.i'm getting the login page after logged in I'm reached my home page.all works fine.But when I enter www.example.com I'm redirected to my login page.then again I test example.com it shows homepage, not the login page. I don't know what I'm doing wrong here. my ALLOWED_HOSTS look like this initially ALLOWED_HOSTS = ['www.example.com','example.com'] Then I changed it to: ALLOWED_HOSTS = ['.example.com'] last try ALLOWED_HOSTS = [*] I changed multiple things but the result is same.Any help really appreciate :) -
Issue in migrating database from pyhton-mysql in OSX
I am running this command to migrate my database. I am unable to do so. Whenver I run this command I am getting error: bin/django migrate Error: raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/rm/Documents/GitHub/project/lib/python2.7/site-packages/_mysql.so, 2): Symbol not found: _mysql_affected_rows Referenced from: /Users/rm/Documents/GitHub/project/lib/python2.7/site-packages/_mysql.so Expected in: flat namespace in /Users/rm/Documents/GitHub/project/lib/python2.7/site-packages/_mysql.so MySql Version: mysql Ver 14.14 Distrib 5.7.19, for osx10.12 (x86_64) using EditLine wrapper Python Version: Python 2.7.14 -
How to convert the UTC time to Shanghai +8 timezone time in template?
From the database, I query out the created_date and put in the template: You see, it is UTC time, how can I in the template shows the +8 timezone time? I tried use the custom template-filter to change, but failed: from django import template from django.template.defaultfilters import stringfilter import datetime, time register = template.Library() ### function def utc2local(utc_st): """UTC时间转本地时间(+8:00)""" now_stamp = time.time() local_time = datetime.datetime.fromtimestamp(now_stamp) utc_time = datetime.datetime.utcfromtimestamp(now_stamp) offset = local_time - utc_time local_st = utc_st + offset return local_st @register.filter def convert_utc_to_shanghai(value): """ UTC->Shanghai :param value: :return: """ local_time = utc2local(value) print local_time.strftime("% Y - % m - % d % H: % M: % S") return local_time.strftime -
Django Querying database based on the user input.
I just started learning python/django and I'm working on a small project. I have models and an html form build. How can I query my database and filter all the names of the drivers that matches the destination city the user entered. My models class Drivers(models.Model): first_name = models.CharField(max_length=30, null=True, blank=False) last_name = models.CharField(max_length=30, null=True, blank=False) destination_one = models.CharField(max_length=50, null=True, blank=False) My HTML form <form id="searchform" method="get" action="" accept-charset="utf-8"> Search destination: <input id="searchbox" name="search_res" type="text" placeholder="Search"> <input type="submit" value="OK"> </form> {% for dr in results %} {{dr.first_name}} {{dr.last_name}} {{dr.destination_one}} <br> {% endfor %} <br> My View def newpage(request): querry = request.GET.get('search_res') if request.method == 'GET': results = Drivers.objects.filter(destination_one=querry) context = RequestContext(request) return render_to_response(request,'busapp/newpage.html',{'results': results}) Models and HTML are fine. I'm having trouble building a simple def in views.py. -
How can i Access the JWT_AUTH variables in my models for creating JWT token
in my settings.py JWT_AUTH = { 'JWT_ENCODE_HANDLER': 'rest_framework_jwt.utils.jwt_encode_handler', 'JWT_DECODE_HANDLER': 'rest_framework_jwt.utils.jwt_decode_handler', 'JWT_PAYLOAD_HANDLER': 'rest_framework_jwt.utils.jwt_payload_handler', 'JWT_PAYLOAD_GET_USER_ID_HANDLER': 'rest_framework_jwt.utils.jwt_get_user_id_from_payload_handler', 'JWT_RESPONSE_PAYLOAD_HANDLER': 'rest_framework_jwt.utils.jwt_response_payload_handler', 'JWT_SECRET_KEY': settings.SECRET_KEY, 'JWT_GET_USER_SECRET_KEY': None, 'JWT_PUBLIC_KEY': None, 'JWT_PRIVATE_KEY': None, 'JWT_ALGORITHM': 'HS256', 'JWT_VERIFY': True, 'JWT_VERIFY_EXPIRATION': True, 'JWT_LEEWAY': 0, 'JWT_EXPIRATION_DELTA': datetime.timedelta(hours=1), 'JWT_AUDIENCE': None, 'JWT_ISSUER': None, 'JWT_ALLOW_REFRESH': True, 'JWT_REFRESH_EXPIRATION_DELTA': datetime.timedelta(days=7), 'JWT_AUTH_HEADER_PREFIX': 'JWT', 'JWT_AUTH_COOKIE': None, } api_settings = APISettings(JWT_AUTH) And this code block is in my Models.py def _generate_jwt_token(self): dt = datetime.now() + timedelta(days=60) token = jwt.encode({ 'id': self.pk, 'exp': int(dt.strftime('%s')) }, settings.SECRET_KEY, algorithm='HS256') return token.decode('utf-8') All i want to replace settings.SECRET_KEY, algorithm='HS256' from the JWT_AUTH (settings.py) I have tried these following from rest_framework.settings import api_settings api_settings.JWT_AUTH['JWT_SECRET_KEY'] and from django.conf import settings settings.JWT_AUTH['JWT_SECRET_KEY'] -> This works but no idea this is the proper way. -
'invalid_grant: Invalid JWT: Google Translation Api
when I am trying to run this on my server I am getting following error but is working on my local machine. RefreshError: ('invalid_grant: Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values and use a clock with skew to account for clock differences between systems.' -
Password is not saved
Password is not saved in new user registration.I wrote in views.py def regist(request): regist_form = RegisterForm(request.POST or None) context = { 'regist_form': regist_form, } return render(request, 'registration/regist.html', context) @require_POST def regist_save(request): regist_form = RegisterForm(request.POST) if regist_form.is_valid(): user = regist_form.save(commit=False) password = regist_form.cleaned_data.get('password') user.set_password(password) user.save() login(request, user) context = { 'user': request.user, } return redirect('detail') context = { 'regist_form': regist_form, } return render(request, 'registration/regist.html', context) in regist.html <div class="heading col-lg-6 col-md-12"> <h2>New account registration</h2> <form class="form-horizontal" action="regist_save/" method="POST"> <div class="form-group-lg"> <label for="id_username">username</label> {{ regist_form.username }} </div> <div class="form-group-lg"> <label for="id_email">email</label> {{ regist_form.email }} </div> <div class="form-group-lg"> <label for="id_password">password</label> {{ regist_form.password1 }} </div> <div class="form-group-lg"> <label for="id_password">password(conformation)</label> {{ regist_form.password2 }} <p class="help-block">{{ regist_form.password2.help_text }}</p> </div> <div class="form-group-lg"> <div class="col-xs-offset-2"> <button type="submit" class="btn btn-primary btn-lg">SUBMIT</button> <input name="next" type="hidden"/> </div> </div> {% csrf_token %} </form> </div> in forms.py class RegisterForm(UserCreationForm): class Meta: model = User fields = ('username', 'email','password1','password1',) def __init__(self, *args, **kwargs): super(RegisterForm, self).__init__(*args, **kwargs) self.fields['username'].widget.attrs['class'] = 'form-control' self.fields['email'].widget.attrs['class'] = 'form-control' self.fields['password1'].widget.attrs['class'] = 'form-control' self.fields['password2'].widget.attrs['class'] = 'form-control' Username&email is registered normally.So I really cannot understand why password is not registered.I read Django tutorial and I think my code is ok.How should I fix this?What should I write it? -
Django: How to write Mixin for queryset for logged in User's data
I am using Generic Class based views for my Project like: ListView (Queryset returning all the objects) DetailView (Queryset for single object) CreateView (Foreignkey data in select boxes) UpdateView (Foreignkey data in select boxes) How to write a generic Mixin for CBV so that the queryset returns only the data owned by the logged in user. -
Invalid geometry value with PostGis
I am using PointField of gis for storing the latitude and longitude in the location field. I dont want to show that field in the ui because I am using google autocomplete places where when user selects the address, i get the lat and lng which I want to fetch it and save to the location field. However I could not do that but I tried to change the field type to TextInput but that did not work as well. How can I do it so? Here is what I have tried class Restaurant(models.Model): user = models.OneToOneField( User, on_delete=models.CASCADE, related_name='restaurant' ) name = models.CharField(max_length=500) phone = models.CharField(max_length=500) location = gis_models.PointField(blank=True, null=True, geography=True) gis = gis_models.GeoManager() objects = models.Manager() class RestaurantForm(forms.ModelForm): class Meta: model = Restaurant widgets = {'country': forms.HiddenInput(attrs={'id': 'country'}), 'location': forms.HiddenInput(attrs={'id': 'location'}), 'city': forms.HiddenInput(attrs={'id': 'locality'}), 'state': forms.HiddenInput(attrs={'id': 'administrative_area_level_1'}), 'postal_code': forms.HiddenInput(attrs={'id': 'postal_code'}), } fields = ( "logo", "name", "cuisine", "phone", "location", "country", "city", "state", "postal_code", ) def clean_location(self): print('self', self.cleaned_data) coordinates = self.cleaned_data['location'] lat, lng = coordinates.split(', ', 1) return GEOSGeometry('POINT(' + longitude + ' ' + latitude + ')') if request.method == "POST": restaurant_form = RestaurantForm(request.POST, request.FILES) if restaurant_form.is_valid(): print(request.POST.get('location')) new_restaurant = restaurant_form.save(commit=False) new_restaurant.user = request.user new_restaurant.save() return redirect(restaurant_order) …