Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django template syntax error
When i run my django server it shows error but i can't find it.it shows template syntax error Unclosed tag on line 2: 'if'. Looking for one of: elif, else, endif. Request Method: GET Request URL: http://127.0.0.1:8000/tag/django/ Django Version: 2.0.5 Exception Type: TemplateSyntaxError Exception Value: Unclosed tag on line 2: 'if'. Looking for one of: elif, else, endif. Exception Location: C:\Users\user\Anaconda3\envs\amirdjango\lib\site-packages\django\template\base.py in unclosed_block_tag, line 549 Python Executable: C:\Users\user\Anaconda3\envs\amirdjango\python.exe Python Version: 3.6.5 Python Path: ['H:\\Amir\\Django\\myDjangostuff\\suorganizer', 'C:\\Users\\user\\Anaconda3\\envs\\amirdjango\\python36.zip', 'C:\\Users\\user\\Anaconda3\\envs\\amirdjango\\DLLs', 'C:\\Users\\user\\Anaconda3\\envs\\amirdjango\\lib', 'C:\\Users\\user\\Anaconda3\\envs\\amirdjango', 'C:\\Users\\user\\Anaconda3\\envs\\amirdjango\\lib\\site-packages'] Server time: Tue, 28 Aug 2018 15:59:01 +0000 -Error: Unclosed tag on line 2: 'if'. Looking for one of: elif, else, endif. The django template is here:- <h2> {{ tag.name|title }} </h2> {% if tag.startup_set.all %} <section> <h3>Startup {{ tag.startup_set.count|pluralize }}</h3> <p> Tag is associated with {{ tag.startup_set.count }} startup {{ tag.startup_set.count|pluralize }} </p> <ul> { % for startup in tag.startup_set.all % } <li><a href=""> { { startup.name } } </a></li> { % endfor % } </ul> </section> { % endif % } { % if tag.blog_posts.all % } <section> <h3>Blog Post { { tag.blog_posts.count|pluralize } } </h3> <ul> { % for post in tag.blog_posts.all % } <li><a href=""> { { post.title|title } } </a></li> { % endfor % } </ul> … -
Display number of records in a Model in Django Admin
As shown above, how could I show the number records (10 questions, 7 answers, and 5 rewards) next to the Model name on the Django Admin page? -
How do I put a link in bootstrap_alert?
How do I put a link in bootstrap_alert? msg=mark_safe('Please visit our forum site <a href="talk.edgle.com" class="alert-link">Edgle Talk</a> as well!') render_alert(msg) '<div class="alert alert-info alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>Please visit our forum site &lt;a href=&quot;talk.edgle.com&quot; class=&quot;alert-link&quot;&gt;Edgle Talk&lt;/a&gt; as well!</div>' As seen, html elements are escaped due to the following chain of function calls: bootstrap_alert -> render_alert -> render_tag ->format_html -> conditional_escape -
Wagatail 2.1 (Django) Custom settings access from Snippet
So i have some settings that i need to be configured from the interface. @register_setting class TierPricingSettings(BaseSetting): Monday = models.CharField(max_length=255) Tuesday = models.CharField(max_length=255) Wednesday = models.CharField(max_length=255) Thursday = models.CharField(max_length=255) Friday = models.CharField(max_length=255) Saturday = models.CharField(max_length=255) Sunday = models.CharField(max_length=255) content_panels_english = [ FieldPanel('Monday'), FieldPanel('Tuesday'), FieldPanel('Wednesday'), FieldPanel('Thursday'), FieldPanel('Friday'), FieldPanel('Saturday'), FieldPanel('Sunday'), ] However i cannot seem to access these values from a snippet ? This is because the documentation states you can only access it through using python my_settings = TierPricingSettings.for_site(request.site) However snippets do not have access to the request object. How can i achieve having settings configurable from the admin panel and have those values accessible in snippets. -
Django AUTH_LDAP_MIRROR_GROUPS Not working
I'm having some trouble trying to instruct Django only to synchronize some groups using LDAP integration. The documentation itself tells me that: AUTH_LDAP_MIRROR_GROUPS ... This can also be a list or other collection of group names, in which case we’ll only mirror those groups and leave the rest alone. My ldap_config.py is set as follows: import ldap ... AUTH_LDAP_MIRROR_GROUPS = { "NETBOX-ADM":"CN=USR-NETBOX-ADM,OU=SUPRESSED,OU=SUPRESSED,OU=SUPRESSED,OU=SUPRESSED,DC=SUPRESSED,DC=SUPRESSED,DC=SUPRESSED" } AUTH_LDAP_ALWAYS_UPDATE_USER = True AUTH_LDAP_CACHE_GROUPS = False My problem is that those group USR-NETBOX-ADM isn't synchronized to Django. If I only set AUTH_LDAP_MIRROR_GROUPS = True many groups are synchronized and I want to avoid garbage. -
Django Context Processors not being called
I've got a context processor which is supposed to inject a list of offices into the template to be displayed in the global footer. The context processor isn't even being called. Django version is 2.1. (.env) ~/staging/ $ cat core/settings.py ... TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'contact.context_processors.offices', ], }, }, ] ... (.env) ~/staging/ $ cat contact/context_processors.py from . import models def offices(request): raise Exception('Testing: This got called') offices = models.Office.objects.order_by('order') return { 'offices': offices, } There's no exceptions being thrown and no warnings or error messages in the console. -
Changing the virtualenv for the terminal in pycharm
I was postponing this question since i am not sure this is the right place to ask it. But i don't find a clear answer either. I am running pycharm 2018.1.4, on windows and it seems that i can't change the virtual env that running in the terminal in pycharm. When i check the python version in the terminal i get version 2.7.3, for the project interpreter i have python 3.6 and for my run configurations i have the same 3.6 interpreter. There are no problems running the development server or anything like that, just in the terminal i can't run the manage.py script without getting following. ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment? I understand the error, i just dont get why it is using that virtuals env instead of the one configured as project interpreter. Anyone else stumbled upon this problem? -
django-tenant-schemas example not working properly
I am using django-tenant-schemas and downloaded the GitHub sample project, but when I generate random users, they are only saved in the public schema. I created subdomains as the example tutorial says (tenant2.trendy-sass, tenant2.trendy-sass) and I added them to the hosts file. I am working with Django 2.0 and PostgresSql 10. Schemas are created correctly. In the first release, I'm looking at the index_tent.html, not the index_puclic.html. I am only viewing the next warning from psycopg2: /Users/Fernando/miniconda3/envs/cookiecutter/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>. i am so confused, it's supposed to work. -
Sending the correct credential using Facebook Grap Api and Webhooks to received subscribed messages from messenger through django
I'm having trouble wrapping my head around how exactly to use the Facebook Graph Api and Webhooks. I'm trying to send and read messages from a group chat that I'm a part of on Facebook. I followed the steps to create an app on Developers.Facebook.com and passed the app review for pages_messages. I generated a Page_access_token and subscribed my app to my fb page. I imagine I need to give Facebook the actual page_access_token and app_secret somewhere in my code, but the tutorial I followed says nothing about it. I'm using django, and the following code to receive the webhook from Facebook using a tutorial I found online: class botView(generic.View): def get(self, request, *args, **kwargs): if self.request.GET['hub.verify_token'] == VERIFY_TOKEN: print(self.request.GET['hub.challenge']) return HttpResponse(self.request.GET['hub.challenge'], 200) else: return HttpResponse('Error, invalid token') @method_decorator(csrf_exempt) def dispatch(self, request, *args, **kwargs): return generic.View.dispatch(self, request, *args, **kwargs) # Post function to handle Facebook messages def post(self, request, *args, **kwargs): # Converts the text payload into a python dictionary incoming_message = json.loads(self.request.body.decode('utf-8')) print(incoming_message) # Facebook recommends going through every entry since they might send # multiple messages in a single call during high load for entry in incoming_message['entry']: for message in entry: pass # Check to make sure the … -
Django mail sending adress
My contact mails are being sent to the console, but i want to change the location so they will go to an email adress like a gmail one. EMAIL_BACKEND ='django.core.mail.backends.console.EmailBackend' <br> DEFAULT_FROM_EMAIL = 'testing@example.com' <br> EMAIL_HOST_USER = ' ' <br> EMAIL_HOST_PASSWORD = ' ' <br> EMAIL_USE_TLS = False <br> EMAIL_PORT = 1025 -
Django, get object with spaces instead of %20 [duplicate]
This question already has an answer here: Decode escaped characters in URL 5 answers In urls.py url(r'^player/(?P<player_name>[\w|\W]+)/$', views.player_details, name="player_details") my views.py def player_details(request, player_name): player = Player.objects.get(name=player_name) deaths = Deaths.objects.filter(killed=player) return render(request, 'player.html', {'player': player, 'deaths': deaths }) And it works fine for when player_name is simple, without spaces - like "Abc". But if player_name is "Abc Defg", it makes it "Abc%20Defg" instead, so I get this error DoesNotExist at /player/Abc%20Defg/ Player matching query does not exist. I tried to unquote it with urllib or to replace %20 with space in objects.get method, but does not work for me. -
Django - How do I add a placeholder on a modelform that's the current field of the model?
I want to be able to vary the placeholder like so: <input placeholder=" {{ input.placeholder }}"> Where input is a model with the "placeholder" field. The placeholder field will vary since I'll be using a formset, and each placeholder will vary. Here's my modelForm class Value(forms.ModelForm): class Meta: model = ValueModel fields = ['value_text'] widgets = { 'value_text': forms.TextInput(attrs={'class': 'form-control'}) and my modelformset values_formset = modelformset_factory(model=ValueModel, extra=0, form=Value) I've tried def __init__(self, *args, **kwargs): super(ActualValues, self).__init__(*args, **kwargs) self.fields['actual_value_text'].widget.attrs['placeholder'] = self.fields['placeholder'] And other attempts at trying to modify the self.fields with no success. -
Django: Assign default value using model method (using self)
I'm looking to assign a default value using a method inside model: class Discussion(models.Model): # attributes ... def __str__(self): return str(self.id) + ". " + self.title def class_name(self): return self.__class__.__name__ discussion_type = models.CharField(max_length = 50, default = self.class_name()) class TechDiscussion(Discussion): # ... class ScienceDiscussion(Discussion): # ... In my Django app, users can only create science or tech discussions. Thus discussion_type should be either "TechDiscussion" or "ScienceDiscussion". Server returns error NameError: name 'self' is not defined, referring to the default value assigned to discussion_type. -
How to serialize queryset in get method in Django Rest Framework?
I am trying to implement calculation logic in APIView class following this page. However, I got below error because I tried to serialize queryset, not dictionary as demonstrated in the page. Does anyone know how I can pass queryset to serializer as argument? If not, are there any way to convert into format which can be serialized by serializer? { "non_field_errors": [ "Invalid data. Expected a dictionary, but got QuerySet." ] } views.py class envelopeData(APIView): def get(self,request,pk): #pk=self.kwargs['pk'] #print (pk) glass_json=self.get_serialized(pk,"glass") print (glass_json) def get_serialized(self,pk,keyword): queryset = summary.objects.filter(html__pk=pk).filter(keyword=keyword) serializer = summarySerializer(data=queryset) <=get error here serializer.is_valid(raise_exception=True) data=serializer.validated_data return data["json"] serializer.py class strToJson(serializers.CharField): def to_representation(self,value): x=JSON.loads(value) return x class summarySerializer(serializers.ModelSerializer): project=serializers.CharField(read_only=True,source="html.project") version = serializers.CharField(read_only=True, source="html.version") pk = serializers.IntegerField(read_only=True, source="html.pk") json = strToJson() #json=serializers.JSONField(binary=True) class Meta: model=summary fields=('pk','project','version','json') -
Error while setting up Apache Solr backend in Django oscar
I am trying to set up the Apache Solr backend for searching products in Django Oscar.So I have followed the documentation provided here:https://django-oscar.readthedocs.io/en/latest/howto/how_to_setup_solr.html. However after extracting the tar file and putting the required code in the settings.py file.I ran the command ./manage.py build_solr_schema > solr-4.7.2/example/solr/collection1/conf/schema.xml On the console I got this output: Save the following output to 'schema.xml' and place it in your Solr configuration directory. -------------------------------------------------------------------------------------------- So I copied it on top of the existing code in schema.xml.Then ran java -jar start.jar and I got this error org.xml.sax.SAXParseException: Content is not allowed in prolog, so I googled it up and found an answer here ,it seems that there was an extra space inserted after I copied the output from the console to this file, so I just removed it. Now I ran the same command java -jar start.jar and I got another error. 3552 [coreLoadExecutor-4-thread-1] ERROR org.apache.solr.core.CoreContainer – Unable to create core: collection1 org.apache.solr.common.SolrException: Schema Parsing Failed: unknown field 'id'. Schema file is /home/netzary/SamuelProjects/cecilia_new2/cecilia/solr-4.7.2/example/solr/collection1/schema.xml at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:618) at org.apache.solr.schema.IndexSchema.<init>(IndexSchema.java:166) at org.apache.solr.schema.IndexSchemaFactory.create(IndexSchemaFactory.java:55) at org.apache.solr.schema.IndexSchemaFactory.buildIndexSchema(IndexSchemaFactory.java:69) at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:559) at org.apache.solr.core.CoreContainer.create(CoreContainer.java:597) at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:258) at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:250) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.RuntimeException: unknown field 'id' at … -
Django - How to make the topics, that you create public? Learning Log Project
The Problem I'm trying to make a project, where you can make topics, that can be private or public to unauthenticated users. In every topic, you can then make several entries, applying to that topic. Now I'm trying to make a checkbox in my new_topic.html, that if you check it, it evaluates to True, if not, to False. But I'm having trouble with, making the checkbox evaluate to True, when I check it. And for some reason, there is two checkbuttons in the page that applies to new_topic.html; one with a label, and one with just a box. What I've tried I've tried recreating the db.sqlite3 database. But that didn't work. I've tried using request.POST.get('public', False) in my new_topic() function, when saving the new_topic variable.¨ The Code My learning_logs/models.py looks like this: from django.db import models from django.contrib.auth.models import User class Topic(models.Model): """A topic the user is learning about.""" text = models.CharField(max_length=200) date_added = models.DateTimeField(auto_now_add=True) owner = models.ForeignKey(User, on_delete=models.CASCADE) def __str__(self): """Return a string representation of the model.""" return self.text class Entry(models.Model): """Something specific learned about a topic.""" topic = models.ForeignKey(Topic, on_delete=models.CASCADE) text = models.TextField() date_added = models.DateTimeField(auto_now_add=True) class Meta: verbose_name_plural = 'entries' def __str__(self): """Return a string representation of … -
Django - make sorl thumbnail show black bars
I am using sorl-thumbnail on my Django site. At the moment, I am showing a grid of 400px x 400px thumbnails, using the following code: {% thumbnail item.image "400x400" crop="center" as im %} <img src="{{ im.url }}" alt="..."/> {% endthumbnail %} This causes all the images to be squared (400x400). I'd still like them to show as 400x400 images, but showing black bars horizontally (top & bottom) if the image was landscape, and black bars vertically (left & right) if the image was portrait, so the actual aspect ratio of the image is not changed. Any ideas on how could I achieve that? -
`default_plugins` in django cms are ignored
According to django-cms docs in CMS_PLACEHOLDER_CONF one can define: default_plugins You can specify the list of default plugins which will be automatically added when the placeholder will be created (or rendered). http://docs.django-cms.org/en/latest/reference/configuration.html I am using: django-cms==3.4.0 Django==1.8.7 and I got none default plugins in placeholder. I followed example from docs: 'content_2': { 'name' : 'Content2', 'plugins': ['TextPlugin', 'LinkPlugin'], 'default_plugins':[ { 'plugin_type':'TextPlugin', 'values':{ 'body':'<p>Great websites : %(_tag_child_1)s and %(_tag_child_2)s</p>' }, 'children':[ { 'plugin_type':'LinkPlugin', 'values':{ 'name':'django', 'url':'https://www.djangoproject.com/' }, }, { 'plugin_type':'LinkPlugin', 'values':{ 'name':'django-cms', 'url':'https://www.django-cms.org' }, # If using LinkPlugin from djangocms-link which # accepts children, you could add some grandchildren : # 'children' : [ # ... # ] }, ] }, ] }, and in template: {% block content_2 %} {% placeholder "content_2" %} {% endblock content_2 %} -
Django EmailMessage with Text/Plain Attachment Sends Garbled File
I've been trying to send an email with an attachment by Django. The steps are as below: msg = EmailMessage( "Test", "This is testing.", to=["foo@bar.com"], attachments=[ ("test.txt", b"This is a text.", "text/plain") ] ) msg.send() However, the attachment that I'm getting is a garbled text: N®{ The below is what I got with hexdump from the attachment file in case it might be helpful: 0000000 184e 8aac adc6 1b7b 0000008 I've also tried the methods below (explicitly defining mimetype): attach method on EmailMessage instance with either string and binary attach_file method on EmailMessage instance with either string and binary However, with these methods, I've got (i) either a garbled result or (ii) an oddly empty attachment. So, is there something I don't know about attaching a simple string to the email? Environment Testing on Manjaro (if the test machine affects my results, maybe?) Python 3.5.6 Django 2.0.4 -
Find variable "a" in a variable "b" that contains a list - Django Template
Is there a way to find variable "A" in a variable "B" containing a list (in the Django template)? At the moment im trying to acomplish this within a for loop. Unfortunately that does not work. The variables carries the correct content, ive just checked it. However the for loop never gives back "true" - although variable A is definitely in the list of variable B username.0 = Variable A that contains an integer like: 1 or 7 or 16 user = Variable B that contains the list in this form: [1,5,6] {% for id, name, user in allowed_user %} <tr> <td class="align-middle"><strong>{{ name }}</strong></td> <td class="align-middle" align="center"> <div class="form-group"> <select multiple class="form-control" id="user_rights"> {% for username in alle_user %} {% if username.0 in user %} {{ username.0 }} {{ user }} <option selected="selected">if {{ username.1 }}</option> {% else %} {{ username.0 }} {{ user }} <option>else {{ username.1 }}</option> {% endif %} {% endfor %} </select> </div> </td> </tr> {% endfor %} -
Mixer: attribute error when creating a instance
For TDD i use: pytest==3.7.2 pytest-django==3.4.1 mixer==6.0.1 But problem is i can't create any instance by mixer. They shown a Attribute error: 'Options' object has no attribute 'private_fields' My test_models.py and models.py code: #test_models.py import pytest from mixer.backend.django import mixer from birdie.models import Post @pytest.mark.django_db class TestPost: def test_model(self): obj = mixer.blend(User) assert obj.pk == 1, 'Should create a post instance' # models.py class Post(models.Model): body = models.TextField() Full traceback error: https://paste.ubuntu.com/p/vXR5bqy7x8/ -
Django2: After form submission is there a better way to 'wipe' the POST to stop re-submission
I have a django application and on one page I have several forms for different models. I would like a 'success' message, which is easy to do by just adding to the context after form submission/validation. However, this leaves the possibility of re-submission of the form, which would just produce an error back to the page, but it still annoys me. urls: url_patterns = [ re_path(r'^manager/$', Manager.as_view(), name='manager'), .......more..... ] views.py: class Manager(LoginRequiredMixin, View): template_name = 'results/manager_templates/manager.html' form1 = Form1 form2 = Form2 login_url = '/' redirect_field_name = 'redirect_to' def get(self, request, *args, **kwargs): form1 = self.form1() form2 = self.form2() context = { 'form1': form1, 'form2': form,} return render(request, self.template_name, context) def post(self, request, *args, **kwargs): submit_clicked = request.POST.get('submit') form1 = self.form1() form2 = self.form2() context = {} if submit_clicked == 'Form 1': form1 = self.form1(request.POST) if form1.is_valid(): form1.save() context['message'] = 'Form 1 successful' # reset the form form1 = self.form1() # return HttpResponseRedirect( # reverse('results:manager', # )) else: print('NOT VALID') elif submit_clicked == 'Form 2': ... do same stuff as above ... context['form1'] = form1 context['form2'] = form2 return render(request, self.template_name, context) If I were to uncomment out the HttpResponseRedirect out, after the form was validated and added like … -
DRF APIClient login raises UnicodeDecodeError
def test_non_educator_user_visit_endpoint(self): self.assertTrue(self.client.login(username=self.educator.email, password=self.password)) # passes self.client.login(username=self.educator.email, password=self.password) # works fine response = self.client.get(self.assignment_url) # raises UnicodeDecodeError self.assertEqual(response.data, { 'detail': 'You do not have permission to perform this action.' }) Traceback (most recent call last): File "/src/app/educator/tests/test_educator_class_assignment_endpoints.py", line 75, in test_non_educator_user_visit_endpoint response = self.client.get(self.assignment_url) File "/usr/local/lib/python2.7/site-packages/rest_framework/test.py", line 291, in get response = super(APIClient, self).get(path, data=data, **extra) File "/usr/local/lib/python2.7/site-packages/rest_framework/test.py", line 208, in get return self.generic('GET', path, **r) File "/usr/local/lib/python2.7/site-packages/rest_framework/test.py", line 237, in generic method, path, data, content_type, secure, **extra) File "/usr/local/lib/python2.7/site-packages/django/test/client.py", line 416, in generic return self.request(**r) File "/usr/local/lib/python2.7/site-packages/rest_framework/test.py", line 288, in request return super(APIClient, self).request(**kwargs) File "/usr/local/lib/python2.7/site-packages/rest_framework/test.py", line 240, in request request = super(APIRequestFactory, self).request(**kwargs) File "/usr/local/lib/python2.7/site-packages/django/test/client.py", line 501, in request six.reraise(*exc_info) File "/usr/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 244, in _legacy_get_response response = middleware_method(request) File "/src/app/forum/middleware/inject_redux_store.py", line 9, in process_request serialized_user = UserSerializer(user, context={'request': request}).data File "/usr/local/lib/python2.7/site-packages/rest_framework/serializers.py", line 533, in data ret = super(Serializer, self).data File "/usr/local/lib/python2.7/site-packages/rest_framework/serializers.py", line 262, in data self._data = self.to_representation(self.instance) File "/usr/local/lib/python2.7/site-packages/rest_framework/serializers.py", line 500, in to_representation ret[field.field_name] = field.to_representation(attribute) File "/usr/local/lib/python2.7/site-packages/rest_framework/fields.py", UnicodeDecodeError: 'ascii' codec can't decode byte 0x89 in position 616: ordinal not in range(128) -
JQuery Autocomplete Won't Render Results
Trying to get a drop down! Model: class Student(models.Model): name = models.CharField(max_length=100) student_id = models.IntegerField() grade = models.IntegerField() View: def student_autocomplete(request): query = request.GET.get('term') if query: data = (Student.objects.filter(name__startswith = query).values('name', 'student_id', 'grade')) return JsonResponse(list(data), safe=False) else: data='blank' return JsonResponse(data) JQuery: $(document).ready(function() { console.log('ready!'); }); $("#student_auto").autocomplete({ source: "{% url 'student-autocomplete' %}", minLength: 2, autoFocus: true, select: function (event, ui) { $('#student_auto').val( ui.item.name ); console.log(ui, event); } }); $("#student_auto").removeAttr("autocomplete").attr("autocomplete", "on"); I can see the data when I manually call the autocomplete url and it looks nice, but the results appear only as empty boxes. -
pass a list as a parameter to django tag
I have a custom inclusion tag in Django, and I need to pass there a list as a parameter. Something along these lines: {% my_tag paramA='asdf' paramB='fdsa' listparams=['X', 'Y'] %} This of course does not work because Django does not know how to deal with lists passed that way. I can also capture something general like list_ and then combine them into a list on a server side: {% my_tag paramA='asdf' paramB='fdsa' list_1='X' list_2='Y' list_3='Z' %} But I wonder if there is a nicer way of dealing with this.