Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
I can`t see sitemap.xml in django sitemap framework
I am new in django and i want to create sitemap of my suit. I use sitemap framework from django, but when i go to 127.0.0.1:8000/sitemap.xml i have TemplateDoesNotExist error This is my sitemap.py from django.contrib.sitemaps import Sitemap from datetime import datetime from .models import * class CharacterSitemap(Sitemap): changefreq = "never" priority = 0.9 def items(self): return Character.objects.all() def lastmod(self, obj): return datetime.now() def location(self, obj): return '/' + obj.server.link + '/' + obj.link This is my urls.py from django.conf.urls import url, include from django.contrib.sitemaps.views import sitemap from .views import * from core import api_views from .models import * from .sitemap import CharacterSitemap sitemaps = { 'character': CharacterSitemap, } urlpatterns = [ **some urls**, url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'), ] Where i must see my sitemap.xml document and what i am do wrong? -
Django HttpResponse generating csv but not downloading it
I am taking queryset turning into csv file, I am even getting the response back. But the browser is not downloading the returned csv file. I am on chrome. class CSVMixin(object): csv_filename = 'csvfile.csv' def get_csv_filename(self): return self.csv_filename def render_to_csv(self, queryset): response = HttpResponse(content_type='text/csv') cd = 'attachment; filename="{0}"'.format(self.get_csv_filename()) response['Content-Disposition'] = cd headers = queryset[0].keys() dict_writer = csv.DictWriter(response, fieldnames=headers) dict_writer.writeheader() dict_writer.writerows(queryset) return response class EmailCampaignViewSet(CSVMixin, OrionAdminModelViewset): queryset = MyObject.objects.all() pagination_class = DefaultLimitOffsetPagination filter_class = EmailCampaignFilter @list_route() def report(self, request): query = self.request.query_params if data_format == 'csv': return self.render_to_csv(queryset) When I call the report route, I get the csv formatted text in my response. But it is not triggering the download. Here is my request from react: this.getReport = (format="json") => { this.setState({btnDisabled: true}); const requestObj = { method: 'GET', headers: { 'Authorization': 'Token ' + this.props.session_token, 'Content-Type': 'application/json', } }; const uri = new URI(`${API_ENDPOINT}/email-campaign/report`); const campaigns = this.state.campaignList.map((campaign)=>( campaign.value )); uri.setSearch({ campaigns: [campaigns], date_from: stringToDateISOString(this.state.dateFrom), date_to: stringToDateISOString(this.state.dateTo), data_format: format, }); return fetch(uri.toString(), requestObj).then(restJSONResponseToPromise).then(responseJSON => { if (responseJSON.results){ this.setState({report: responseJSON.results, btnDisabled: false}); } }, (response) => { clearSessionIfInvalidToken(this.props.clearSession); this.setState({btnDisabled: false}); }); } -
Ephemeral model instances for demo in Django 1.10
I need to dynamically create a series of models and relationships in a Postgres database for the purpose of demoing some features. The issue is these models can't interfere with or be returned by queries in the normal functioning of the Django app. However they must have the full behavior set of the model and the ability to be returned by queries during the demo. Using factories (we use Factory Boy primarily) is imperfect because the models can't be queried without being saved to the database at which point they interact with regular operation queries. A second database is imperfect as well because the demo occurs during normal app operation and thus the "valid" model instances still need to be available. Flagging the models as is_demo also won't work as there's a half dozen different types of models that need to be instantiated for the demo to work as intended. I could clear the specific models that are created with a cron job or similar but they'd effect the database between creation and the scheduled job. Running everything in a staging environment is acceptable, but the ideal answer allows me to run the demos on the production build. Is there … -
FileBrowser is not defined
I was tasked with upgrading a Django 1.3 application up to 1.8. I changed out the applications Filebrowser with a newer version from a Django 1.7 app we also have. Everything is working great, except in the admin, when I try to upload an image with Filebrowser I get the error ReferenceError: FileBrowser is not defined. It is being called in this Filebrowser template filebrowser/templates/filebrowser/custom_field.html /* Part that throws the error -> */ FileBrowser.show('id_image', '/admin/filebrowser/browse/?pop=1&dir=/customer_media'); {% load fb_versions %} <input id="{{ final_attrs.id }}" type="text" class="vFileBrowseField" name="{{ final_attrs.name }}" value="{{ value }}" /><a href="javascript:FileBrowser.show('{{ final_attrs.id }}', '{% url "fb_browse" %}?pop=1{% if final_attrs.directory %}&amp;dir={{ final_attrs.directory }}{% endif %}{% if final_attrs.format %}&amp;type={{ final_attrs.format }}{% endif %}');" class="fb_show"> <img src="{{ final_attrs.search_icon }}" alt="" /> </a> {% ifequal value.filetype "Image" %} <p class="help" id="help_{{ final_attrs.id }}"> <a href="{{ value.url_full }}" target="_blank" id="link_{{ final_attrs.id }}"> <img id="image_{{ final_attrs.id }}" src="{% version value.path final_attrs.ADMIN_THUMBNAIL %}" class="preview" /> </a> </p> {% else %} <p class="help" id="help_{{ final_attrs.id }}" style="display: none;"> <a href="javascript://" target="_self" id="link_{{ final_attrs.id }}"> <img id="image_{{ final_attrs.id }}" class="preview" src="" /> </a> </p> {% endifequal %} {% if final_attrs.DEBUG %} <p> <strong>Path</strong> {{ value.path }}<br /> <strong>FileType</strong> {{ value.filetype }}<br /><br /> <strong>Directory</strong> {{ final_attrs.directory }}<br … -
Remove form from DOM using javacript
I have three radio buttons.. each radio buttons on click have an independent form that appears. I need to remove form from DOM when i click on a radio button. and there are a third one not ready yet. When i click on the first radio button only its form appears, the other two are removed from DOM. Same for other. I don't have a good idea about javascript. Html: <div class="page-header"> <h1>Backtesting{% if form.instance.pk %}: {{form.instance.title}} {% endif %}</h1> </div> <div class="row"> <div class='col-md-9'> <form action="{% url "backtest" %}" method='POST' role='form' id='form'> {% csrf_token %} <div id="tabs"> <input type="radio" name="tabs" value="first" id="toggle-tab1" checked="checked" /> <label for="toggle-tab1">Long</label> <input type="radio" name="tabs" value="second" id="toggle-tab2" /> <label for="toggle-tab2">Short</label> <input type="radio" name="tabs" value="third" id="toggle-tab3" /> <label for="toggle-tab3">Long and Short</label> <div id="tab1" class="tab" > {% include 'tags/parameters_form.html' %} <br /> {% if user.is_authenticated %} <input type='submit' id='run' value='Run' class='btn btn-default'> {% if user.profile.is_active %} Name: {{ form.title }} <input type='submit' name='save' value='Save' class='btn btn-default'> {% else %} <p> Expired account! you need to reactivate in order to save parameters. </p> {% endif %} {% else %} Please <a href="{% url 'auth_login' %}">login</a> in order to Run backtesting! </br> Our system needs your email in order … -
How to access csv file data in django?
I want a webpage in django that accepts csv file from the user and need to process that data.could you please help me -
Return from CreateView's form_valid() without saving an instance
While handling a form submission, I have to perform custom logic (contact web service etc). In case of failure I want to prevent the creation of a new instance of model Car. Let's demonstrate through a simple snippet: from django.views import generic from django.http import HttpResponseRedirect class CarCreateView(generic.edit.CreateView): model = Car form_class = CarForm def form_valid(self, form): # some logic that may succeed or fail if success: messages.success(self.request, 'bla bla') return super().form_valid(form) else: messages.error(self.request, 'blabla') # How to return to form index without saving??? return HttpResponseRedirect(self.get_success_url()) Not calling super().form_valid(form) is not enough. A new Car is still being saved. Any ideas? -
Changes in index.html cause server 500 error on heroku
When I edit my index.html file in Django templates, and deploy my app using git, heroku shows server 500 error. By editing, I mean the minor changes like deleting the comments. How should I avoid this error? -
Documenting body parameters in Django rest framework
I have a simple APIView to get log files from certain subsystems: class LogParser(APIView): def get(self, request, subsystem): """ Get logs :param subsystem: subsystem name :param since: start date :param until: end date [...] """ since = request.data.get('since') until = request.data.get('since') [...] It gets subsystem parameter as query_param, but takes much more additional data to from JSON to perform additional filtering. This view doesn't have a representation in models, it does some filesystem operation and returns file so I have no serializer to base on. I want to document this method similary as in above snippet and make Django Rest Framework with Swagger to understand it and let me to execute queries via swagger with additional parameters. With get parameters it is working fine, but how to add those request.data params to work? -
Taking input from user and backend processing in Django
I am a Biological Sciences student and my Bioinformatics Professor has asked me to make this page which is becoming really hard for me. The task seems simple but somehow I cannot understand it mainly because I have basic Python knowledge. He has asked me to create a webpage using Django which has two input fields and a "Submit" button. When the user clicks the "submit" button, the data from fields should be processed (backend) and generate another webpage to create the output. An example would be that two input fields take a string of letters and numbers, and clicking submit generates another webpage which displays the count of letters and digits individually. -
Slicing a Django queryset without retrieving everything from the database
Lets say, I want the first 12 elements from a Django queryset. Now I could easily do this as follows: queryset = Content.objects.all()[:12] This works, but I am retrieving every single Content from my database. Is there a better way to do this? I am thinking something that only retrieves the first 12 items from the queryset from the database. Thanks. -
Make a multipart export / import with loaddata and dumpdata in django
So i made a dumpdata with django but my file is really big. Does anyone have any tip on how to make a multi part export and import with dumpdata and loaddata in django ? I have mainly an app that take the most size so i can separate by app. Thanks and Regards -
How to display things such as username when youve extended the Django User Model in admin.py
so I expanded on the Django User Model and this is what I currently have: class StudentProfile(models.Model): user = models.OneToOneField(User, null = True, related_name = 'StudentProfile', on_delete = models.CASCADE) teacher = models.BooleanField(default = False) school = models.CharField(max_length = 50) #replies = models.ManyToManyField() class TeacherProfile(models.Model): user = models.OneToOneField(User, null = True, related_name = 'TeacherProfile', on_delete = models.CASCADE) teacher = models.BooleanField(default = True) school = models.CharField(max_length = 100) subject = models.CharField(max_length = 100) head_of_subject = models.BooleanField(default = False) headmaster = models.BooleanField(default = False) #reviews = models.ManyToManyField() class SchoolProfile(models.Model): school_name = models.CharField(max_length = 100, default = '') identification_code = models.CharField(max_length = 10, unique = True) teachers = models.ManyToManyField(TeacherProfile, blank = True) I am now setting up the admin.py and I was wondering how i could display things such as the users first, last, and username? This is what I have tried, however it has not worked. class StudentProfileAdmin(admin.ModelAdmin): list_display = ["user.username", "school"] class Meta: model = StudentProfile class TeacherProfileAdmin(admin.ModelAdmin): list_display = ["user.username", "school"] class Meta: model = TeacherProfile class SchoolProfileAdmin(admin.ModelAdmin): list_display = ["school_name", "identification_code"] class Meta: model = SchoolProfile admin.site.register(StudentProfile, StudentProfileAdmin) admin.site.register(TeacherProfile, TeacherProfileAdmin) admin.site.register(SchoolProfile, SchoolProfileAdmin) Thanks for any help! -
Is it ever OK to catch Django ORM errors inside atomic blocks?
Example code: with transaction.atomic(): # Create and save some models here try: SomeModel.objects.get(id=NON_EXISTENT_ID) except SomeModel.DoesNotExist: raise SomeCustomError() Two questions: 1) Will this work as intended and roll back any previously saved models, given that nothing is done in the exception handler except for re-raising a custom error? 2) From a code style perspective, does it make sense to not use a nested transaction inside the try block in cases like this? (That is, only one line of code within the try block, no intention of persisting anything else within the transaction, no writes to the database inside the exception handler, etc.) -
Multiple user type sign up with django-allauth
TL;DR How could I implement sign up for private and company users using django-allauth? The approach I'm following (is it correct?) I have the following models: class PrivateUser(models.Model): """Models a private user account""" user = models.OneToOneField(User, on_delete=models.CASCADE) class CompanyUser(models.Model): """Models the company's contact person user account""" user = models.OneToOneField(User, on_delete=models.CASCADE) class Company(models.Model): """Models the company attributes""" contact_person = models.OneToOneField(User, related_name='company') name = models.CharField(max_length=50, null=False, blank=False) vat_no = models.CharField( # some config and validators ) # ... other non-relevant fields Now, I have to distinguish between the two users PrivateUser and CompanyUser during the sign up process with django-allauth having just one sign up form as specified in the official django-allauth documentation: ACCOUNT_SIGNUP_FORM_CLASS (=None) A string pointing to a custom form class (e.g. myapp.forms.SignupForm) that is used during signup to ask the user for additional input (e.g. newsletter signup, birth date). This class should implement a def signup(self, request, user) method, where user represents the newly signed up user. So, to create a unique form I created an abstract model class with all the fields from the PrivateUser and the CompanyUser plus one (note the user_type field): class AbstractComprehensiveUser(models.Model): """ Little hackish model class needed to handle one single sign up … -
testing send_email is not working
I don't get why when I run the test it's always failed with AssertionError: 0 != 1 even though the result of r is 1. class UserProfileTaskTest(TestCase): def test_send_email(self): subject = 'subject' body = 'body' from_email = 'from_email@test.com' recipient_list = ['recipient@test.com'] r = send_mail( subject=subject, message=body, from_email=from_email, recipient_list=recipient_list ) print(r) self.assertEqual(len(outbox), 1) -
Get foreign key, and corresponding field values into model
I have a model which I am using a foreign key from another model. I need to also set another column to a corresponding field of that foreign key but am unsure how to do so correctly. Class ModelA(models.Model): ModelB = models.ForeignKey(ModelB, on_delete=models.PROTECT) ValueFromB = models.CharField(max_length=100) Class ModelB(models.Model): Value = models.CharField(max_length=100) How can I get the db structure to be something similiar to: id ModelB_id ValueFromB _______________________________ Currently I am trying def _get_valuefromB(self): return self.ModelB.Value value = property(_get_valuefromB -
Clashing between two postgres database though having two different docker-compose yaml files for django projects
I am running two different django projects in my machine. My machine is running on os -ubuntu 16.04. I am very new to docker. As far as I know, the only way to differentiate between two projects setup is defining different containers. To have different containers, I have given different container_name in my docker-compose.yml file. So, basically, I do have different containers name for two different project and I have used different postgres database name in settings.py file for the each project as well. Following are two different docker-compose.yml file configurations PROJECT - 1 version: '3' services: nginx: restart: always image: nginx:latest container_name: NGINX_P1 ports: - "8000:8000" volumes: - ./src:/src - ./config/nginx:/etc/nginx/conf.d - /static:/static depends_on: - web web: restart: always build: . container_name: DJANGO_P1 command: bash -c "python manage.py makemigrations && python manage.py migrate && gunicorn safersit.wsgi -b 0.0.0.0:8000 --reload" depends_on: - db volumes: - ./src:/src - /static:/static expose: - "8000" db: restart: always image: postgres:latest container_name: PSQL_P1 And, the settings.py file for project-1 is : DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'postgres_test', <--- different name for postgres 'USER': 'postgres', 'HOST': 'db', 'PORT': 5432, } } For PROJECT - 2 version: '3' services: nginx: restart: always image: nginx:latest … -
Failed to load resource: the server responded with a status of 500 (INTERNAL SERVER ERROR) Django
I'm running Html file from S3 bucket in that HTML file there is AJAX call when I run/open the HTML file I am getting below error. Failed to load resource: the server responded with a status of 500 (INTERNAL SERVER ERROR) My code from s3 bucket JS file <script type="text/javascript"> $(document).ready(function () { $.get("https://52.221.186.121/email_view/6/", function (data) { console.log(JSON.stringify(data)); email_otp = JSON.stringify(data); $("#btnSubmit").click(function () { var input_value = $('#entered_otp').val(); alert(input_value); alert(email_otp); if (email_otp == input_value) { alert('matches'); $('.modal').removeClass('show'); } else { alert('not matching'); window.location = "https://awslocation.com/mobile/index.html"; } }); }); }); Corresponding views.py code def email_view(request, id): course = get_object_or_404(CourseWare, pk=id) user = UserProfile.objects.get(user__id=request.user.id) myorder = MyOrder.objects.get_or_create(buyer=user, course=course) if myorder: sms_otp = randint(10000, 100000) user = UserProfile.objects.get(user__id=request.user.id) email = user.user.email body = '''Dear User, \n Please Enter the OTP to view the Course. \n \n OTP : %s \n \n Thanks,''' % ( sms_otp) email = EmailMessage('Course Ware OTP', body, to=[email]) email.send() if request.is_ajax(): return HttpResponse(json.dumps(sms_otp), content_type="application/json") -
Not Generating Multiple Dropdowns by Django
I am trying to add multiple dropdown filed for a model but Django is not generating multiple dropdowns.. Here is model.py file. Dropdown is shown for 'qualification' field but 'department' is not shown in form.. Here is template file. <table style="width:100%"> {% for field in form %} <tr> <td>{{ field.label_tag }}</td> <td>{{ field }}</td> </tr> {% endfor %} </table> here is forms.py class EmployeeForm(forms.ModelForm): class Meta: model = Employee fields = ['regno','fname','lname','ffname','flname','qualification', 'num', 'email','city','contact','alternatecontact','fathercontact','joiningdate','qualification', 'department', 'experience','lastemployer','picture','isteaching','dob','status','address'] model.py class StaffEducation(models.Model): id = models.AutoField(db_column='id', primary_key=True) title = models.CharField(db_column='title', max_length=100) def __str__(self): return self.title class Department(models.Model): id = models.AutoField(db_column='id', primary_key=True) title = models.CharField(db_column='title', max_length=100) def __str__(self): return self.title class Employee(models.Model): id = models.AutoField(db_column='id', primary_key=True) regno = models.CharField(db_column='regno', max_length=100) fname = models.CharField(db_column='fname', max_length=100, blank=False, null=False) lname = models.CharField(db_column='lname', max_length=100, blank=False, null=False) ffname = models.CharField(db_column='ffname', max_length=100, blank=False, null=False) flname = models.CharField(db_column='flname', max_length=100, blank=False, null=False) qualification = models.ForeignKey(StaffEducation) num = models.DecimalField(db_column='num', default='0', decimal_places=2, max_digits=11) email = models.EmailField(db_column='email', max_length=100) address = models.TextField(db_column='address') city = models.CharField(db_column='city', max_length=100) contact = models.CharField(db_column='contact', max_length=100) alternatecontact = models.CharField(db_column='alternatecontact', max_length=100) fathercontact = models.CharField(db_column='fathercontact', max_length=100) joiningdate = models.DateField(db_column='joiningdate') department = models.ForeignKey(Department) #qualification = models.CharField(db_column='qualification', max_length=100) experience = models.CharField(db_column='experience', max_length=100) lastemployer = models.CharField(db_column='lastemployer', max_length=100) picture = models.ImageField(db_column='picture') isteaching = models.BooleanField() dob = models.DateField(db_column='dob') status = … -
syntax error while importing csv file for winerama project
I am trying to build up a wine recommendation tutorial. I am trying import data from csv using pandas and I get this error. Please help! c:\Users\Adhista Chapagain\Desktop\winerama> python load_users.py data/users.csv File "load_users.py", line 22 print "Reading from file " + str(sys.argv[1]) ^ SyntaxError: invalid syntax here is the code for load_users.py > import sys, os import pandas as pd os.environ.setdefault("DJANGO_SETTINGS_MODULE", "winerama.settings") import django django.setup() from django.contrib.auth.models import User def save_user_from_row(user_row): user = User() user.id = user_row[0] user.username = user_row[1] user.save() if __name__ == "__main__": if len(sys.argv) == 2: print "Reading from file " + str(sys.argv[1]) users_df = pd.read_csv(sys.argv[1]) print users_df users_df.apply( save_user_from_row, axis=1 ) print "There are {} users".format(User.objects.count()) else: print "Please, provide User file path" -
how to optimize posts, comments and likes using django rest framework and postgresql
Assuming we have to list of posts(paginated) with each post having some likes and also some comments. What is the better way to optimize them ? Note that I am not using mongodb and want answer in postgresql. My thoughts: one way: Slow way: Fetch likes and comments along with the post. So in single api call, you will get list of paginated posts with each post containing likes and comments data. Another way: Fetch list of posts without likes and comments. Cache them. Make another call to fetch likes of the posts with the ids loaded. Same for comments. -
Displaying image in 500 status page (Django)
I have a Django app with nginx as a reverse proxy web server. I want to serve an image in my 500 error page. How do I do that within a Django project? I tried the advice here. I.e. my virtual host file for nginx contains: error_page 500 502 503 504 /500.html; location = /500.html { root /home/myuser/myproject/myapp/templates/; } location = /500.png { root /home/myuser/myproject/myapp/static/img/; } Note that 500.png is indeed placed at /home/myuser/myproject/myapp/static/img/500.png.The HTML template refers to the 500 error image like so: <img src="500.png" alt="."> But, although the 500 error page loads correctly, the image itself never loads, falling back to alt in the img tag. What could I be doing wrong? Please ask for more information in case you need it. -
Django query with annotate & aggregate - how to include empty/0 rows?
I have the following query which sums transaction amounts and counts total transactions: results = transactions.extra({"dimension": "date_trunc('year', timestamp)"}).values('dimension', 'currency_code').order_by('dimension').annotate(volume=Coalesce(Count("id"), 0), total=Coalesce(Sum('amount'), 0)) Which returns: 2012-01-01 00:00:00 USD 12109 234123.63 2013-01-01 00:00:00 USD 12277 285216.54 2014-01-01 00:00:00 USD 9927 244956.04 2014-01-01 00:00:00 EUR 616 12449.04 2014-01-01 00:00:00 GBP 629 13863.25 2015-01-01 00:00:00 USD 6942 213611.19 2015-01-01 00:00:00 EUR 594 18581.88 2015-01-01 00:00:00 GBP 690 24975.23 2016-01-01 00:00:00 GBP 564 20911.87 2016-01-01 00:00:00 USD 5372 169850.73 2016-01-01 00:00:00 EUR 456 16214.96 2017-01-01 00:00:00 EUR 142 5286.74 2017-01-01 00:00:00 USD 1683 54829.33 2017-01-01 00:00:00 GBP 157 6257.85 I'd like it to return the following: 2012-01-01 00:00:00 USD 12109 234123.63 2012-01-01 00:00:00 EUR 0 0 2012-01-01 00:00:00 GBP 0 0 2013-01-01 00:00:00 USD 12277 285216.54 2013-01-01 00:00:00 EUR 0 0 2013-01-01 00:00:00 GBP 0 0 2014-01-01 00:00:00 USD 9927 244956.04 2014-01-01 00:00:00 EUR 616 12449.04 2014-01-01 00:00:00 GBP 629 13863.25 2015-01-01 00:00:00 USD 6942 213611.19 2015-01-01 00:00:00 EUR 594 18581.88 2015-01-01 00:00:00 GBP 690 24975.23 2016-01-01 00:00:00 USD 5372 169850.73 2016-01-01 00:00:00 EUR 456 16214.96 2016-01-01 00:00:00 GBP 564 20911.87 2017-01-01 00:00:00 USD 1683 54829.33 2017-01-01 00:00:00 EUR 142 5286.74 2017-01-01 00:00:00 GBP 157 6257.85 Or alternatively if it's easier: 2012-01-01 00:00:00 USD_c 12109 … -
Django Python shell indentation error
when i paste the below code in my python shell. I get an Indentation error. ... print "this is an ideal answer for both" File "", line 2 print "this is an ideal answer for both" ^ IndentationError: expected an indented block def get_match(user_a, user_b): user_a_answers = UserAnswer.objects.filter(user=user_a)[0] user_b_answers = UserAnswer.objects.filter(user=user_b)[0] if user_a_answers.question.id == user_b_answers.question.id: user_a_answer = user_a_answers.my_answer user_a_pref = user_a_answers.their_answer user_b_answer = user_b_answers.my_answer user_b_pref = user_b_answers.their_answer if user_a_answer == user_b_pref: print "%s fits with %s's preference" %(user_a_answers.user.username, user_b_answers.user.username) if user_a_pref == user_b_answer: print "%s fits with %s's preference" %(user_a_answers.user.username, user_b_answers.user.username) if user_a_answer == user_b_pref and user_a_pref == user_b_answer: print "this is an ideal answer for both" get_match(mohit, saraswati) get_match(saraswati, userc) get_match(mohit, userc) i get an indentation error , when i run this from the shell , why?`