w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
autocomplete ='off' is not working when the input type is password and make the input field above it to enable autocomplete
Browser's normally have two related yet different features regarding forms: Form auto-complete, where items of <input type="text"> type (and similar) collect typed values and offer them back in the form of a drop-down list.(It's a simple feature that works pretty well.) Password manager, where browser prompts to remember username/password combinations when it detects you've submitted a login form. When returning to the site, most browsers display available usernames in a drop-down box (Firefox, Chrome, Internet Explorer...) but some have a toolbar button (Opera). Also, Chrome highlights the fields in hard-coded yellow. (This depends on heuristics and might fail on certain pages.) There's an edge case with forms tagged as autocomplete="off". What happens if it's a login form and t

Categories : HTML

How do I re-initiate AutoComplete on a WinForm Text Box, after a successful initial AutoComplete?
Set Auto complete mode to suggest append so that it will suggest one or more suggested completion strings it has. TextBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend

Categories : C#

jQuery autocomplete remote data using getJson with autocomplete.filter
You should only use the "filter" if your data is locally stored. If it is remote, you should filter it on the server side first before sending it over. From the jQuery UI documentation: The Autocomplete plugin does not filter the results, instead a query string is added with a term field, which the server-side script should use for filtering the results. For example, if the source option is set to "http:// example.com" and the user types foo, a GET request would be made to http:// example.com?term=foo. The data itself can be in the same format as the local data described above. http://api.jqueryui.com/autocomplete/ Your first example works well for this scenario.

Categories : Jquery

How can I have the equivalent of django's admin inlines in a modelform?
You can use inline formsets. From the documentation: Suppose you have these two models: from django.db import models class Author(models.Model): name = models.CharField(max_length=100) class Book(models.Model): author = models.ForeignKey(Author) title = models.CharField(max_length=100) If you want to create a formset that allows you to edit books belonging to a particular author, you could do this: >>> from django.forms.models import inlineformset_factory >>> BookFormSet = inlineformset_factory(Author, Book) >>> author = Author.objects.get(name=u'Mike Royko') >>> formset = BookFormSet(instance=author) The inlineformset_factory takes care of things behind the scenes, but for the front-end part you may find the django-dynamic-formset j

Categories : Python

How do I run autocomplete directly from the server instead of the default JQuery UI autocomplete?
Jquery auto-completer gives you the option to load the data from server. Checkout this link http://jqueryui.com/autocomplete/#remote

Categories : Jquery

Enable autocomplete user dictionary for all files in Emacs
You may look at this 1. As I read the description I thought that is what you need just look at the example: I cant post so here the link: http://www.emacswiki.org/emacs/PredictiveMode#toc5

Categories : Emacs

Django admin: Allow ForeignKey to base class to refer to its subclasses
Either one should work. This is how you would do it with an abstract base class: class Excerpt(models.Model): excerpt = models.TextField() source = models.ForeignKey(Source) class Meta: abstract = True class Book(Excerpt): pass class Magazine(Excerpt): pass Now you can do: book = Book.objects.all() magazine = Magazine.objects.filter(source=1)

Categories : Python

ForeignKey to Django-MPTT tree generating storm of SQL requests in admin inline
So.. I found a solution, which is inspired from Caching queryset choices for ModelChoiceField or ModelMultipleChoiceField in a Django form and which I describe in that post. Django admin has a strange overhead of 1 query due to the inline factory mechanism (I haven't gone in depth into this). This explains why in the normal case you have 2*k + 1 queries (k=number of items in the inline formset). issue solved hopefully. LAI

Categories : Django

How to fill in an autocomplete inputbox using Selenium? (Why an automated input does not load autocomplete options BUT a manual input does?)
I tried your code, it does exactly what the manual walkthough does. "Associated Press, The" returns only a "No Match, please try sources". In your code you then try to click on the next form list item, not the results popup. The autosuggest popup is dynamically populated at the top of your html page positioned under the input form. The following code does select the first option on your drop down. @Test public void test() throws InterruptedException { WebDriver driver = new ChromeDriver(); driver.get("http://www.lexisnexis.com/hottopics/lnacademic/?verb=sf&sfi=AC00NBGenSrch"); driver.switchTo().frame("mainFrame"); WebDriverWait waitst = new WebDriverWait(driver, 0); waitst.until(ExpectedConditions.visibilityOfElementLocated(By.name("sourceTitl

Categories : Java

typeahead autocomplete for Django
I have used Bootstrap's typeahead before and what I did was create a method to get the dictionary via Ajax like this: <script type="text/javascript"> var typeahead_data = []; function get_client_names() { $.ajax({ url: "/lookup", success: function (data) { $.each(data, function (key, value) { typeahead_data.push(value.toString()); }); // assign the array to my typeahead tag $('.typeahead').typeahead({ source: typeahead_data, }); } }); } $(function () { get_client_names(); }); </script> The tag element is like this: <inp

Categories : Django

django-autocomplete key error
You should almost never import views into forms. Forms are used in views, not vice versa. I'd move autocomplete = AutocompleteView('Gestion') into some separate module (for example, gestion.autocomplete) and imported from there. P.S. Also please note that modules in Python are named in lowercase, so it should be gestion, not Gestion

Categories : Python

Django form with autocomplete functionality
This is going to be something in the JQuery/AJAX side of things, not Django. I would read up on the autocomplete functions of JQuery and use AJAX to call your DJango code and receive a populated list, which then displays to the user. JQuery Autocomplete - Custom Data

Categories : Django

Case insensitive autocomplete with Django
To get just the unique tag text matches, I think this should work: tag_text = BGTag._model_class.objects.filter(tag__istartswith=term, author_token=self.my_token).extra(select={'lc_tag': 'LOWER(tag)'}).values_list('lc_tag', flat=True).distinct()

Categories : Django

Jquery UI Autocomplete: Custom Data
I did something similar, but my .data() looks like this: $("input#books").autocomplete({ minLength : 3, source : someArray }).data( "ui-autocomplete" )._renderItem = function(ul, item){ //code to do cool stuff };

Categories : Jquery

How to set initial value from a model's custom field in a ModelForm in Django
Your URL has a parameter: (?P<country>[w-]+) that it is trying to pass to your view, but your view isn't accepting that parameter. def pest_report_create(request): should be def pest_report_create(request, country): You'll then want to pass the country across in the initial data for the form: form = PestReportForm(inital={'country': country} I'd also recommend not defining your forms in the models module

Categories : Python

How to overide django modelform to achieve custom behaviour
Its tough to make ModelForm's defined on the fly because they are intimately tied to the structure in your model. Nevertheless you could use some clever template control flow and view rendering to get your desired effect. This is untested so you millage with this might vary. <form method="post" action=""> {{ formset.management_form }} {% for form in formset %} {{ form.id }} <ul> {% if user_option.category %} <li>{{ form.caregory }}</li> {% endif %} {% if user_option.name %} <li>{{ form.name }}</li> {% endif %} {% if user_option.p_opt %} <li>{{ form.price }}</li> <li>{{ form.options }}</li> {% endif %} </ul> {%

Categories : Django

jquery autocomplete display custom result
here the working script: .data( 'ui-autocomplete' )._renderItem = function( ul, item ) { return $( "<li></li>" ) .data( "item.autocomplete", item ) .append(item.value) .appendTo( ul ); };

Categories : Jquery

JQuery Autocomplete Custom Lookup Function
It surely is. You specify source to be a function which will answer a list of strings or alternatively {label, value} objects. $('#myInput').autocomplete({ source: function (request, response) { var term = request.term; var data = handleAutocomplete( term); /* get answers from somewhere.. */ response( data); } }); function handleAutocomplete (term) { var options = ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]; // use 'term' for custom filtering etc. return options; } See: http://api.jqueryui.com/autocomplete/#option-source

Categories : Javascript

jquery autocomplete custom menu item
First you can override source method to return a custom set of responses. In this case, Create Entity is always appended to the list returned. Then handle the select event to prompt for the entity. var availableTags = ['car', 'duck', 'house']; $('#elementID').autocomplete({ source: function( request, response ) { var responses = $.ui.autocomplete.filter(availableTags, request.term); responses.push('Create Entity'); response( responses ); }, select: function( event, ui ) { var choice = ui.item.value; if (choice == 'Create Entity') { var selection = prompt('New Entity', 'default value'); availableTags.push(selection); console.log(selection); this.value = selectio

Categories : Jquery

Autocomplete with categories, item custom style
I solved it by myself. This is the solution: http://jsfiddle.net/3qgN3/2/ I THINK it was because the functions was inside a document ready function. $(document).ready(function () { //Functions in OP was moved outside });

Categories : Jquery

jquery autocomplete from custom source + angular.js
needed to replace name with value in the array of objects and in _renderItem the function params were supposed to be ul,item and not ui,item.... <body ng-controller='FriendController'> <form ng-submit="addFriend()"> <input type="email" auto-complete ui-items="fbFriends" ng-model="friend" autofocus /> </form> <ul ng-repeat="friend in friends"> <li> {{friend.text}} </li> </ul> <script> var addFriendAppModule = angular.module('addFriendApp', []); addFriendAppModule.controller('FriendController', function($scope) { var friendArr = []; $scope.fbFriends = [ { value: "manu", email: "sept@gmail.com" }, { value: "manu123"

Categories : Javascript

JQueryUI autocomplete - custom rendering; focus not working
Ok, finally found the problem. It is necessary to add a 'ui-menu-item' class on the element, otherwise JQuery cannot properly select and hand over the item to the handler functions. Overriding renderItem instead of renderItemData also seems the right way to do it. It should look something like: $(#"...").autocomplete(...) .data( "ui-autocomplete")._renderItemData = function( ul, item : Users.BriefUserDescriptor) { ul.data('ui-autocomplete-item', item); return $( "<li>" ) .data('ui-autocomplete-item', item ) .append( "<p>" + item.fullName + "<br>" + item.emailAddress+ "</p>" ) .addClass('ui-menu-item') .appendTo( ul ); };

Categories : Jquery

PHPStorm autocomplete for CakePHP custom helpers in view files
Have you tried looking at this article: http://blog.hwarf.com/2011/08/configure-phpstorm-to-auto-complete.html Look at the section "Setting Up Helper Auto-completion in Views". Hopefully this helps.

Categories : Cakephp

How can I do Autocomplete in Typescript ? Have jquery.d.ts & jquery.autocomplete.d.ts files
You need to add a reference to the autocomplete.d.ts file e.g.: /// <reference path="path/to/your/jquery.autocomplete.d.ts" /> Although I suspect that you are using the wrong definition file and should be using this one: https://github.com/borisyankov/DefinitelyTyped/blob/master/jqueryui/jqueryui.d.ts It contains your required definition: interface JQuery { // ... autocomplete(): JQuery; autocomplete(methodName: string): JQuery; autocomplete(methodName: 'close'): void; autocomplete(methodName: 'destroy'): void; autocomplete(methodName: 'disable'): void; autocomplete(methodName: 'enable'): void; autocomplete(methodName: 'search', value?: string): void; autocomplete(methodName: 'widget'): JQuery; autocomplete(options: JQueryUI.AutocompleteOptions): JQuery;

Categories : Javascript

Django Inline Admin : Error : has no ForeignKey to
syncdb does not detect changes (read the section Syncdb will not alter existing tables) . You either need to - Drop the database and recreate (not very recommended) or - Install a 3rd party app called django-south to modify the database colums and manage the migrations

Categories : Python

django autocomplete_light default widget instead of autocomplete widget
I think i found the answer :) I always got the following message when using registered autocomplete names: KeyError at /search/ 'CityAutocomplete' localhost:8000/autocomplete/ showed me all the registered autocompletes but nevertheless those autocompletes were unusable in forms.py i had to import autocomplete_light_registry to get rid of the KeyError as i mentioned before i got it to work somehow but im quite sure i didn't import autocomplete_light_registry so if someone has a tip where the "real" error lies ... thank you very much

Categories : Python

How to create a Django custom Field to store MYSQL DATETIME(6) and enable fractional seconds (milliseconds and or microseconds) in Django/MySQL?
I've tried this succesfully, but my approach is quite different: I split the info in a DateTimeField (UTC) and a IntegerField (microseconds = uS): from datetime import datetime, timedelta import pytz class MyModel (models.Model): # My model stuff and other fields here _UTC = models.DateTimeField () _uS = models.IntegerField() And then I set a property in the class to return UTC with microseconds and zone info aware (because my database doesn't support zoneinfo) @property def UTC (self): utc = self._UTC us = self._uS # add microseconds utc += timedelta(microseconds=us) return utc.replace(tzinfo=pytz.utc) @UTC.setter def UTC (self,utc): self._UTC = utc-timedelta(microseconds=utc.microsecond

Categories : Django

How to reverse a custom admin url in Django 1.5?
Try changing name of the view to include application and model names: ... my_urls = patterns('', url(r'^settings/([A-Za-z0-9]*)', self.admin_site.admin_view(self.settings), name="common_variable_settings")) ... The admin_urlname template filter returns "full" names, see it's source code: @register.filter def admin_urlname(value, arg): return 'admin:%s_%s_%s' % (value.app_label, value.module_name, arg) So definitely You need to name Your view "appname_modulename_settings". Maybe then try changing regular expression to something like this: r'^settings/([A-Za-z0-9]+/)?$'

Categories : Python

Cant get Custom widget to work by replacing django's default date time widget in django admin
For a jQuery widget you'll need to include the jQuery.js (or whatever name you have) core library file in your html header. The TypeError: $ is undefined ... makes it seem as if you might have forgotten to do that. The TimeZoneDate widget is claiming the widget is called id="date_time_tz" but the js is attempting to work with something called $('#date-time-tz') I'd suggest changing one or the other so that they match! Maybe in the widget; id="date-time-tz"

Categories : Python

Django Admin custom list_display name and ordering
Figured it out; I named the reference tot he _class Model wrong; Ordering should be: ordering = ('level', '_class__name') Order field should be: class_.admin_order_field = '_class__name'

Categories : Django

How do I add a custom button next to a field in Django admin?
In my case I am making an API call with a button I create so I'll throw in how I did that too. Ofcourse your button can do whatever you like. First, in your model create a function that will output your button. I will use my example, i.e. models.py: class YourModel(models.Model): .... def admin_unit_details(self): # Button for admin to get to API return format_html(u'<a href="#" onclick="return false;" class="button" ' u'id="id_admin_unit_selected">Unit Details</a>') admin_unit_details.allow_tags = True admin_unit_details.short_description = "Unit Details" I then added the field as readonly and added it to the fieldsets, note you can only have either fields or fieldsets defined on the model admin. I aslo added media to

Categories : Django

Custom User Model in admin on Django 1.5
As you say, the UserCreationForm references auth.User directly. The Django docs on custom users and built in auth forms state that you must rewrite it for any custom user model. UserCreationForm Depends on the User model. Must be re-written for any custom user model. There is a related ticket Ticket 20086, which was initially closed as invalid, because the user creation form is working as documented. There is a full example on the same page, which shows you how to rewrite the forms and register a custom user model in the admin.

Categories : Python

Django admin sortable custom fields
You don't. The admin screen relies on QuerySet.order_by(); it can only do the ordering that can be represented in an ORDER BY clause. Relevant source: https://github.com/django/django/blob/a89c856a7aadc830951342a1fa49c1a1b5ac9156/django/contrib/admin/views/main.py#L387 Consider what would happen with large datasets - in order to have the pagination be consistent, the admin would have to evaluate your normalization function for every row in the database, for every request.

Categories : Django

django-admin.py can't find custom settings file
What I recommend doing: Create a normal settings.py file and import one of the others in there. This avoids duplication of settings shared among the three scenarios + it is actually the recommended way of doing it according to the DRY principle. Typically, you will only have the set the debug parameter, database settings and private keys in the specific settings files. All the other settings should be shared among all scenarios to avoid forgetting to update one and getting hard to debug errors.

Categories : Django

Custom Filter in Django Admin returns SuspiciousOperation
This appears to be a bug in Django, when you have double-underscores for the filter path (first element of the tuple)... in your case 'model1__model2__property' NOTE: now fixed in Django 1.7 More details here: https://code.djangoproject.com/ticket/19182 It's quite ugly but so far the only workaround I found was to paste this fixed and overridden method into the ModelAdmin where you want to use that list_filter: def lookup_allowed(self, lookup, value): """ Copy and pasted from ModelAdmin to fix bug in Django https://code.djangoproject.com/ticket/19182 """ from django.db.models.constants import LOOKUP_SEP from django.db.models.sql.constants import QUERY_TERMS from django.contrib.admin import FieldListFilter from django.contrib.admin import widgets mod

Categories : Django

Django custom field gives an error when editing in admin
Well, I've figured that out. The problem is inside the very Django core. Fields just can't return Python objects containing some models.Field attributes like prepare_database_save, otherwise an error occures. My hack to solve that was to return tuple (MyClassObject, ) instead of just MyClassObject in to_python(). Odd, but what can I do... Maybe I'll try to post an issue somewhere on Django's Github page.

Categories : Django

Django override base_site.html for a custom admin
You can use change_form_template or change_list_template template as per your need. Example : class xxxxAdmin(admin.ModelAdmin): change_form_template ='admin/cutomize_form.html' Regards, Ansh J

Categories : Django

django admin - add custom form fields that are not part of the model
It it possible to do in the admin, but there is not a very straightforward way to it. Also, I would like to advice to keep most business logic in your models, so you won't be dependent on the Django Admin. Maybe it would be easier (and maybe even better) if you have the two seperate fields on your model. Then add a method on your model that combines them. For example: class MyModel(models.model): field1 = models.CharField(max_length=10) field2 = models.CharField(max_length=10) def combined_fields(self): return '{} {}'.format(self.field1, self.field2) Then in the admin you can add the combined_fields() as a readonly field: class MyModelAdmin(models.ModelAdmin): list_display = ('field1', 'field2', 'combined_fields') readonly_fields = ('combined_fields',)

Categories : Django

Django custom forms for Admin deleting fields dynamically
Definitely your best bet is ModelAdmin. I think you got it right except for the if test. You should be able to do it like this: class GiftAdmin(admin.ModelAdmin): model = Gift def get_form(self, request, obj=None, **kwargs): self.exclude = [] # self.instance.pk should be None if the object hasn't yet been persisted if obj is None: self.exclude.append('giftbought') return super(GiftAdmin, self).get_form(request, obj, **kwargs) admin.site.register(Gift, GiftAdmin) Notice there are minor changes to the method code. You should check the docs, I'm sure you'll find everything you need there. Hope this helps!

Categories : Django

Raise django admin validation error from a custom view
Not sure I understood what you want well: You have a view, by definition a public page. You want it to display an error message in the admin pages (by definition privates page) ? It's odd. But if you want so. To display an error in the admin pages, use the Django Message Framework. It's what is in use to display the yellow rows with errors/notifications on the top of the pages. from django.contrib import messages messages.error(request, "Something goes wrong sending transaction mail"); Indeed, validation errors an only displayed with forms. And thus, they are to be raised only in the clean() method of a form, a formset, or a field.

Categories : Django



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.