Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Inner join in Django 1.9
I have these two models: class ModelInteractions(models.Model): id1 = models.IntegerField(primary_key=True) id2 = models.IntegerField() comm = models.TextField(blank=True, null=True) class Meta: managed = False unique_together = (('id1', 'id2'),) class Models(models.Model): id = models.IntegerField(primary_key=True) name = models.TextField() class Meta: managed = False and I want to select also comm. In my view, I use the following code to get data from Models: condition = Q(name__icontains=names[0]) for name in names[1:]: condition &= Q(name__icontains=name) # ↓↓↓ this line is for what I need but it doesn't work condition &= Q(ModelInteractions__id2=id) models = Models.objects.filter(condition) id is received on request (def details(request, id):). I need to select comm from ModelInteractions where id2 = id (id received on request). Current code returns: Cannot resolve keyword 'ModelInteractions' into field. Choices are: id, name -
Django - Return full_name from Profile model which has relation with Django User model in other model
I created Book, Book_stat a Profile model which has relation with Django User Model, i am trying to display Book title and full_name from Profile as default str return string from Book_stat models.py from django.db import models from django.contrib.auth.models import User from decimal import Decimal # Create your models here. class Book(models.Model): title = models.CharField(max_length=200) def __str__(self): return self.title class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) full_name = models.CharField(max_length=150) def __str__(self): return self.full_name class Book_stat(models.Model): user = models.ForeignKey(User) book = models.ForeignKey(Book) rating = models.DecimalField(max_digits=5, decimal_places=2, default=Decimal('0.00')) like = models.BooleanField(default=False) def __str__(self): return self.book.title # here i would like to return book title + full_name from Profile Model admin.py from django.contrib import admin from .models import Book, Book_stat, Profile # Register your models here. admin.site.register(Book) admin.site.register(Book_stat) admin.site.register(Profile) When i click on Book_stat in my django admin page i would like to display Book title and Profile full_name as title's in my Book_stat list -
Django - is it more suitable to use abstract class or multiple table inheritance?
I'm creating a web app for a school, and one of the features is to provide a quiz for students that contains multiple questions. One of the tricky things is that a quiz can contain questions that have different formats (e.g. a word question, a picture question) in a one-to-many relationship. I'm thinking the cleanest solution is to have a base Question class, and then have different types of questions that inherits from it (e.g. WordQuestion, PictureQuestion). My problem is whether to make Question class abstract or not. Making it abstract seems to be cleaner from a database standpoint since I'm not creating multiple tables, but it creates two problems. Firstly, I don't think I can do foreign keys to an abstract class, so that means I need to have one-to-many relationships with WordQuestion, PictureQuestion, etc. Secondly, I lose the ability to filter by Question (e.g. I might want to compute the scores of all the questions answered correctly regardless of type). I'm just wondering whether my understanding of abstract classes is correct, and whether it makes more sense to just not make Question class abstract? -
I cant make Javascript to cpy my string as I want it
So i have this on a javascript that is running on a django app, I get a list from my views.py and after that i want to get the img url The first line of code gets it and if i print it with the console log i get exactly what i want pictures/logo.png The problem is that in the third line of code the variable img shows me this %22%2bimg%2b%22 Dont know what I'm missing, it might be some stupid thing but I haven't had luck or I'm doing somehting pretty bad :p img = data[i].fields.imagen.substring(13); console.log(img); html += "<div class='brick "+size+"' style='background-image: url(\"{% static '"+img+"' %}\")'><div class='cover'>"+nombre+"</div></div>" Thanks -
Create a form validation error instead of the yellow page error message DJANGO MultipleChoiceField
I have been trying to solve this forever now, tried 20+ stackoverflow solutions but nothing fits. Let's get started. I am trying to figure out how to set an initial value for MultipleChoiceField. and then disable it for the user. So that is shows form validation error in the HTML page {{forms.errors}} instead of the yellow page error message. for starters this is the model: class Review(models.Model): user = models.ForeignKey(User,validators=[check_unique]) entry = models.ForeignKey(Entry, on_delete=models.CASCADE) rating = models.IntegerField(validators=[MinValueValidator(1),MaxValueValidator(10)]) review = models.TextField(validators=[RegexValidator('^[A-Za-z0-9 ]+$', message='Only Alphanumeric Characters')]) slug = models.SlugField(null=False, blank=False, unique=True) date_created = models.DateTimeField(auto_now_add=True) date_updated = models.DateTimeField(auto_now=True) here's the unique key : class Meta: unique_together = ('user', 'entry') it has user and entry as foreign keys. What I want is when 1 user adds a review for an entry for the second time he should be shown an error message " you can add only 1 review to this entry ". I have tried this several ways. case 1 : tried to collect entry from url kwargs, send it to forms and set initial value views.py class ReviewCreateView(LoginRequiredMixin,CreateView): form_class = ReviewForm template_name = 'myapp/review_form.html' def get_form_kwargs(self): entry = self.kwargs.get('entry') kwargs = super(ReviewCreateView, self).get_form_kwargs() kwargs.update({'entry': entry}) return kwargs forms.py class ReviewForm(forms.ModelForm): class Meta: … -
How to use list serializer in django to serialize according to inherited serializer?
Lets assume there are three models Animal, Cat, Dog where Cat and Dog are inheriting from parent class Animal. class Animal: name class Cat: sleep_hours class Dog: breed Considering that sleep_hours and breed are mutually exclusive property of cat and dog respectively. Now we have serializers :- AnimalSerializer: name CatSerializer(AnimalSerializer): sleep_hours DogSerializer(AnimalSerializer): breed Now we want to develop an API where we return all the information about animal so it should return something like this [ {'tommy', 'pug'}, {'kitty', '10'}, ] So consider animal class is linked to user i.e. user.animals returns a list of animals (parent class) we want to use modelSerialiser on user. class UserAnimalSerializer(serializers.ModelSerializer): animals = AnimalSerializer(read_only=True) class Meta: model = User fields = ('animals') Now we want to use different serializer(child serializer) based on the instance type. Is there any good way to handle these type of scenarios. Please comment if there is some confusion about the question. -
Django receive post result from curl
I've created a function that's supposed to receive post data from a curl request and return a result. I've disabled csrf for the view so the error I'm getting is I can't parse the json. Here's my view @csrf_exempt def create_user(request): response = {'status': None} if request.method == 'POST': data = json.loads(request.body) ... I get this error on the terminal Internal Server Error: /api-user-create/ Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 149, in get_response response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 147, in get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/csrf.py", line 58, in wrapped_view return view_func(*args, **kwargs) File "/home/samuel/Documents/code/binabikers/delivery/views.py", line 14, in create_user data = json.loads(request.body) File "/usr/lib/python2.7/json/__init__.py", line 339, in loads return _default_decoder.decode(s) File "/usr/lib/python2.7/json/decoder.py", line 364, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode raise ValueError("No JSON object could be decoded") ValueError: No JSON object could be decoded [01/Aug/2017 03:58:24] "POST /api-user-create/ HTTP/1.1" 500 85347 which implies this is not the best way to read json from curl request like this curl -X POST -d "username=john&password=john2&email=john@email.com&first_name=john&last_name=smith" http://localhost:8000/api-user-create/ -
Django Orm Many-To-Many query
from itertools import chain class Filter(models.Model): name = models.CharField(max_length=128) groups = models.ManyToManyField(Group, related_name='filters') class Group(models.Model): name = models.CharField(max_length=128) class User(models.Model): name = models.CharField(max_length=128) groups = models.ManyToManyField(Group, related_name='users') filters = Filter.objects.all() gl_users = [] for filter in filters: users = User.objects.filter( groups__pk__in=filter.groups.all().distinct().values_list('pk', flat=True) ) gl_users = list(chain(gl_users, users)) how i can write without loops and get all users via Filter model? -
form.serialize() sends empty object - Django forms
My AJAX query sends an empty object Object { } on button click - it should be sending form data. I have a form with checkboxes. It renders and functions, and the HTML is like this: <form method="post" action="" data-id="filter-form"> //This is from Django's CSRF token <form method="post" > <input type='hidden' name='csrfmiddlewaretoken' value=.../> <div class="form-group"> <div id="div_id_vacant" class="checkbox"> <label for="id_vacant" class="">Is Vacant</label> <input type="checkbox" name="vacant" class="checkboxinput" id="id_vacant" /> </div></div> ...more of the same inputs... </form> </form> <hr/> <button id="search-btn" class="btn btn-info" data-filter-leads-url="/leads/ajax/filter">Search</button> <button id="download-btn" class="btn btn-default" data-filter-leads-url="/leads/csv">Download</button> I also have some JQuery stuff. It is supposed to read the form and send an AJAX request via post to a Django view. It looks like this: {Django CSRF code here} var searchBtn = $("#search-btn"); searchBtn.click(function () { var form = $("#filter-form"); $.ajax({ url: searchBtn.attr("data-filter-leads-url"), method: "POST", data: form.serialize(), dataType: 'json', success: function (data) { console.log(data) }, error: function (data) { console.log("There was an error."); console.log(data.error()) } }); }); I've also tried: var formData = new FormData(form[0]); It sends an empty object as well. Empty object confirmed through Django view printing request.POST and a console.log(form.serlialize()) command as well as a console.log(formData) command. Can anyone help me solve this? -
Search query for Django-Haystack app
I am trying to use Haystack to search from the Elasticsearch Database in my Django app. This is the model 'Recordings' in my models.py: class Recordings(models.Model): channel = models.ForeignKey(Channel, related_name="recordings") date = models.DateTimeField(auto_now_add=True) duration = models.DurationField(default=0) file_size = models.FloatField(default=0.0) file_location = models.CharField(max_length=255) proceed = models.BooleanField(default=False) class Meta: get_latest_by = 'date' ordering = ['-date'] index_together = ["date", "channel"] def __str__(self): return str(self.date) The html page that is responsible to take the search items is search.html <h2>Search</h2> <form method="get" action="."> <table> {{ form.as_p }} <tr> <td> <input type="submit" value="Search"> </td> </tr> </table> {% if query %} <h3>Results</h3> {% for result in page.object_list %} <p> <a href="{{ result.object.get_absolute_url }}">{{ result.object.title }}</a> </p> {% empty %} <p>No results found.</p> {% endfor %} {% if page.has_previous or page.has_next %} <div> {% if page.has_previous %}<a href="?q={{ query }}&amp;page={{ page.previous_page_number }}">{% endif %}&laquo; Previous{% if page.has_previous %}</a>{% endif %} | {% if page.has_next %}<a href="?q={{ query }}&amp;page={{ page.next_page_number }}">{% endif %}Next &raquo;{% if page.has_next %}</a>{% endif %} </div> {% endif %} {% else %} {# Show some example queries to run, maybe query syntax, something else? #} {% endif %} </form> And the query that searches the data from the database is in views.py: def search(uri, term): … -
Multi ManyToMany fields with m2m_changed signal
I have 2 m2m fields on a model: class InsuranceBroker(models.Model): AUTO = 1 HIGH_RISK = 2 HOME = 3 BOAT = 4 MOTORCYCLE = 5 TRAVEL = 6 BUSINESS = 7 LIFE = 8 INSURANCE_TYPES = ( (AUTO, 'Auto Insurance'), (HIGH_RISK, 'High Risk Auto Insurance'), (HOME, 'Home Insurance'), (BOAT, 'Boat Insurance'), (MOTORCYCLE, 'Motorcycle Insurance'), (TRAVEL, 'Travel Insurance'), (BUSINESS, 'Business Insurance'), (LIFE, 'Life Insurance'), ) first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) email = models.EmailField(max_length=50) insurance_type = models.IntegerField(choices=INSURANCE_TYPES, default=AUTO) user = models.ForeignKey(User, null=True) tags = models.ManyToManyField(Tag, blank=True) #m2m 1 documents = models.ManyToManyField(Document, blank=True) #m2m 2 def __unicode__(self): return ('%s %s') % (self.first_name, self.last_name) and I have a signal for the tags like so: @receiver(m2m_changed) def tag_changed(sender, **kwargs): instance = kwargs.pop('instance', None) pk_set = kwargs.pop('pk_set', None) action = kwargs.pop('action', None) models = ('InsuranceBroker_tags', 'AutoDealership_tags', 'MortgageBroker_tags', 'Realtor_tags') if sender.__name__ in models: model = _get_model(sender) if action == "pre_add": for pk in pk_set: try: tag = Tag.objects.get(pk=pk) except Tag.ObjectDoesNotExist: tag = None contact = sender.objects.get(pk=instance.pk) # no need to catch here # hit api with tags server = api.InsuranceAPI() if tag.tagId: add_tag = server.ContactService('addToGroup', int(contact.contact_id), int(tag.tagId)) The above code works fine for the tag but I introduced a m2m for documents. I am not getting … -
Save validation form
I have a little issue with the following method in the customers/forms.py file def clean(self): cleaned_data = super(CustomerBaseForm, self).clean() bank_account = cleaned_data.get("bank_account") ssn = self.cleaned_data.get('ssn') bank = self.cleaned_data.get('bank') bank_transit = self.cleaned_data.get('bank_transit') v = CustomerProfileFormCleaner(self) v.clean() # The concatenation of bank transit, the bank account and the bank # number must be unique. Hence, the following message would be # displayed if it is already in use. msg = _('The bank, the bank transit and the bank account are already in use') customer = CustomerProfile.objects.filter(ssn=ssn) qs = FinancialProfile.objects.filter( bank=bank, bank_transit=bank_transit, bank_account=bank_account) if customer.count() == 1: qs = qs.exclude(customer_id__in=[cust.id for cust in customer]) if qs.count() > 0: self.add_error('bank_account', msg) self.add_error('bank', '') self.add_error('bank_transit', '') I have an error form because of error_1_id_bank_transit which give me as information that prevent me to save that form. How could I save a validation form? -
Django DEBUG=False resulting in 400 error for all requests
I'm running my Django app in a Docker container with nginx as the webserver, and uWSGI as the app server. Everything is deployed on AWS Elastic Beanstalk. When I set DEBUG=False, all the requests result in Bad Request (400). I have tried both ALLOWED_HOSTS='*' and ALLOWED_HOSTS=['*']. I verified the request is coming to uWSGI by checking the logs. The uWSGI logs have this: [pid: 33|app: 0|req: 4/4] 172.17.0.1 () {46 vars in 855 bytes} [Tue Aug 1 02:54:17 2017] GET / => generated 26 bytes in 26 msecs (HTTP/1.1 400) 1 headers in 53 bytes (1 switches on core 0) I've tried a bunch of answers, but no luck. I've tried this answer, but I still get the same error. Is there anything else that could cause this? -
django model missing when accessing with psycopg2
I've been building a django app and the models.py includes a few models: Customer Error Record When I run python3 manage.py shell I have no errors with: From myapp.models import Customer, Error, Record records = Record.objects.all() print(len(records)) # the same works if I run the query for Customer, Error, etc. However, if I try to connect using psycopg2 I'm finding that some tables are not accessible. cur.execute("select relname from pg_class where relkind='r' and relname !~ '^(pg_|sql_)';") conn = psycopg2.connect(conn_string) cursor = conn.cursor() cursor.execute("select relname from pg_class where relkind='r' and relname !~ '^(pg_|sql_)';") print cursor.fetchall() [('django_migrations',), ('django_content_type',), ('django_admin_log',), ('auth_group_permissions',), ('auth_group',), ('auth_user_groups',), ('auth_permission',), ('auth_user_user_permissions',), ('django_session',), ('my_app_contactme',), ('my_app_employee',), ('auth_user',), ('Error',), ('my_app_blogpost_category',), ('Customer',), ('Record',)] cur.execute("SELECT * from Customer") --------------------------------------------------------------------------- ProgrammingError Traceback (most recent call last) <ipython-input-38-3532e0e20e34> in <module>() ----> 1 cur.execute("SELECT * from Customer") ProgrammingError: relation "customer" does not exist LINE 1: SELECT * from Customer I can't figure out why Customer, Error and Record are causing issues with accessing via psycopg2 -
Django NoReverseMatch pattern name
I'm having issues with NoReverseMatch. cart/views.py: checkout/checkout.py checkout/urls.py: So basically in cart.html (show_cart in cart.views.py), I have a form that looks like this: When I press the "Checkout" button, Django leads me to the error. -
Does Django or Bootstrp offer SelectOneListBox?
I used primefaces before, and it offers a component called SelectOneListBox. I am now using Django, and I was wondering if Django or Bootstrap offer anything similar. I know Django offers the drop down box, however, I am hoping to provide a a list box where the user can see all the options and just click to select the item he/she wants. -
Django: Save ContentFile (or some kind of virtual file) to database
In my django app I create string which I have to save to my database as a File. If I understand correctly, django is supposed to automatically upload the file when I save the entry: class Foo(models.Model): bar1=models.ForeignKey(Table1) bar2=models.ForeignKey(Table2) res=models.FileField(upload_to='MYPATH') The problem is that to create an instance of Foo, I have to first create a physical file on the server's disk which would mean two copie would be created (one by me in order to create a database entry, one by djngo when saving the entry). As far as I can see, I must create the file myself in 'MYPATH' and instead of using a FileField, I have to save a reference in the database (essentially what django is doing ????). However I have doubts that this is the best method as It doesn't strike me as Pythonesque. I won't have access to the same methods as when using a real FileField. For instance when calling it, I won't have a FieldFile but just a reference string. Basically, what I wanted to do was: String --> ContentFile (or some form of "virtual" file) --> Physical File handled by Django when saving entry in the database. entry = Foo(bar1=var1, bar2=var2, … -
Strange behaviour when using tuples in django objects.filter
Hi I'm trying to get object at certain index using filter for index, l in enumerate(pos_l): #get first value of each tuple currentIndex = l[0] #get second value of each tuple currentPos = l[1] pl = Produk_L.objects.filter(produk_t_id=currentIndex)[currentPos:(currentPos + 1)].get() pos_l is array of tuple [(1,8),(2,5),(3,10)] Those code returns matching query does not exist. But if i change currentIndex = l[1] to currentIndex = 3 or any integer, it doesnt return error. Any suggestion ? -
How to improve exception handling in GraphQL Query Resolver?
I've got the CRUD operations in my Graphene-Django enabled API working. However, I don't entirely like the way one of my tests is working: def test_delete_workflow(self): response = self.client.post('/graphql/?query=mutation%20%7B%0A%20%20%20%20deleteWorkflow(input%3A%20%7B%0A%20%20%20%20id%3A%203%0A%20%20%7D)%0A%20%20%7B%0A%20%20%20%20success%0A%20%20%20%20errors%0A%20%20%7D%0A%7D') self.assertNotEqual(response.content.find(b'\"data\":{\"deleteWorkflow\":{\"success\":true'), -1) content = self.get_workflow(3) self.assertNotEqual(content.find(b'{\"errors\":[{\"message\":\"Workflow matching query does not exist.\"'), -1) Deleting an existing "workflow" and then trying to retrieve it again correctly fails (as it should) but a bunch of code is being displayed in the test output because the error is not being properly handled. Here's a snippet of my pertinent GraphQL Query code: class Query(graphene.AbstractType): workflow = graphene.Field(WorkflowType, id=graphene.Int()) workflows = graphene.List(WorkflowType) def resolve_workflow(self, args, context, info): id = args.get('id') if id is not None: return WorkflowModel.objects.get(pk=id) #Failing here return None def resolve_workflows(self, args, context, info): return WorkflowModel.objects.all() The code is clearly failing on the line where I left the comment. The problem is, I don't know how, within the resolver, to trap the error in such a way that I can return the Exception. I did figure this out within Mutations but I don't understand the required syntax within Queries. Could anyone shed some light? Robert -
How to make dynamically parameters django models fields
This code is a abstract class for many Class Base (models.Model): Created_by = models.ForeignKey(User) Modified_by = models.ForeignKey(User, null=True) I want related_name like this related_name = self.default_related_name + '_name_field' As the following Class Base(models.Model): Created_by = models.ForeignKey(User, related_name = self.default_related_name + '_created_by') Modified_by = models.ForeignKey(User, null = True, related_name = self.default_related_name + '_modified_by') But i know that, I cant have access to instance in the attributes of the class. So what method do i can to overload to create a field with a method (or property)? (I tried to create the field in the init method, but it doesnt not work) -
How to export application level metrics using django-prometheus and prometheus-client?
I have a Django app exposed to the client as uwsgi server with multiple processes and thread set up in wsgi.ini. I read the django-prometheus docs and implemented the models metrics. I can view the models metrics exposed over /metrics endpoint on browser. However the docs say -- You can add application-level metrics in your code by using prometheus_client directly. The exporter is global and will pick up your metrics. However I cannot see the values of these metrics increasing. They remain 0.0. I have added lazy = true and enable-threads = true in my wsgi.ini file. Also as doc suggests I have added PROMETHEUS_METRICS_EXPORT_PORT_RANGE = xrange(8001, 8050) in my settings.py file to export over different ports for different workers. However still I am not seeing results. What extra needs to be done to finally view my application level metrics which I have added for different celery workers and apis? -
Django fontsize tinymce
I am trying to use django tinymce in my project but the font is too small. I have googled it and learned I am meant to use content_css but without proper step by step approaches as to how exactly this should be done. I am wondering if there was another way and if there isn't, could someone give me a simple step by step approach to solving it using the content_css. Thanks in advance -
problems with custom user form django
I am trying to create a website with Django, and am stuck on the user registration form. When I click the button to go to the registration form, it redirects me fine but for some reason the form isn't there. I'll include the html and views.py below views.py from django.shortcuts import render, redirect from django.contrib.auth import authenticate, login from django.views import generic from django.views.generic.edit import CreateView from django.views.generic import View from .forms import UserForm def index(request): return render(request, 'personal/home.html') class UserFormView(View): form_class = UserForm template_name = 'personal/registration_form.html' #display blank form def get(self, request): form = self.form_class(None) return render(request, self.template_name, {'form': form}) # process form data def post(self, request): form = self.form_class(request.POST) if form.is_valid(): user = form.save(commit=False) #cleaned (normalized) data username = form.cleaned_data['username'] password = form.cleaned_data['password'] user.set_password(password) user.save() #returns User objects if credentials are correct user = authenticate(username=username, password=password) if user is not None: if user.is_active: login(request, user) return redirect('personal:index') return render(request, self.template_name, {'form':form}) registration_form.html {% extends 'personal/header.html' %} {% block body %} <div class="container-fluid"> <div class="row"> <div class="col-sm-12 col-md-7"> <div class="panel panel-default"> <div class="panel-body"> <form class="form-horizontal" action="" method="post" enctype="multipart/form-data"> {% csrf_token %} {% include 'personal/form-template.html' %} <div class="form-group"></div> <div class="col-sm-offset-2 col-sm-10"> <button type="submit" class="btn btn-success">Submit</button> </div> </form> </div> </div> </div> … -
Posting device_id through request headers in django rest framework api
I am trying to post device_id through request headers below is my code but i am not getting able to post it. i am sending device_id through headers in postman. Plz Avoid the spacing views.py class DeviceID(APIView): def post(self, request): device_id = request.META.get('HTTP_X_DEVICE', '') serializer = DeviceSerializer(data=device_id) if serializer.is_valid(): serializer.save() else: return Response(serializer.errors) serializers.py class DeviceSerializer(serializers.ModelSerializer): DEVICE = serializers.IntegerField() class Meta: model = Device fields = 'DEVICE' def create(self, validated_data): return Device.objects.create(**validated_data) models.py class Device(models.Model): DEVICE = models.IntegerField() urls.py url(r'^device/', views.DeviceID.as_view()), -
Django request.COOKIES returning empty dictionary
I've set some cookies using javascript document.cookie = ... and then am trying to retrieve them in a Django (1.8) view using request.COOKIES. However, when I print the result to the console it is just an empty dictionary. I wrote this code a few weeks ago, and am pretty sure it was working then, but now I've come back to it broken. Cookies are visible in the Application window of the browser console and I can retrieve them using Javascript, just not Django. I've read the docs and experimented with changing my settings, but can't see anything that makes much of a difference. Any suggestions of where I should look next would be appreciated. I haven't provided any code because I have no idea where the problem is, and my app isn't tiny. Just looking for an avenue to explore as to why request.COOKIES isn't returning anything. Thanks