w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
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

how to add Django media javascript on the fly to a widget in an ajaxed form?
Nevermind! This was working as expected - I just didn't check the ajaxed head for the JS. And my widgets just appeared not to be working because they where covered by the bootstrap dialog. Increased their z-index to 10000 and everything works.

Categories : Jquery

How to create a custom date time widget for the django admin?
I think you can create a more generic widget. First, separate your js, html and media for create a unique widget. widgets.py class DatTimeField(forms.Textarea): def render(self, name, attrs = None): final_attrs = self.build_attrs(attrs,name=name) return "Here you have to return the html of your widget, for example: mark_safe(u'<input type=text %s value=%s class='your_css_class'/>' % (flatatt(final_attrs), value))" Now in your admin class, try this: class YourClassAdmin(admin.ModelAdmin): class Media: css = { "all": ("my_styles.css",) } js = ("my_code.js",) formfield_overrides = { models.DateTimeField : {'widget': DatTimeField()}, } If you want to customize your widgets, I suggest you to see the

Categories : Python

Django forms.MultiValueField with widget set to widget.MultiWidget; proper way to do validation?
You can also catch exceptions in the compress method of the MultiValueField, which would allow you to add an exception for the field as a whole. I maintain a Feet and Inches form widget that extends MultiValueField as well. The init and compress portions are: class FeetAndInchesField(MultiValueField): widget = FeetAndInchesWidget def __init__(self, *args, **kwargs): errors = self.default_error_messages.copy() if 'error_messages' in kwargs: errors.update(kwargs['error_messages']) localize = kwargs.get('localize', False) fields = ( IntegerField(min_value=0, required=False, localize=localize), IntegerField(min_value=0, localize=localize), FloatField() ) super(FeetAndInchesField, self).__

Categories : Jquery

How do you dynamically create a multi-form wizard in Django from the same form?
I don't know if there's a way to do this in the exact way you describe, but the Django docs has a tutorial describing how to implement this use case.

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 create my own login form Django
So, I think you are confusing two different things: one is what you want to ask the user. The second is what you want to store in the database. The first issue is implemented in views and forms, while the latter is implemented in models, in particular User profiles. Normally a form is associated with an action you want to perform to your database. Either insert new content or modify existing content (which includes user login). So, my answer to your question is: you should try to read these 4 links I added. You have to understand the underlying idea of views as server responses to users requests, forms as tools to modify database with user input without damaging it, and models as data structures to store information in a structured way. Hope this helps.

Categories : Python

Widget configure activity does not create the widget
So it turns out that Sherlock was innocent, my problem was something else altogether. Apparently, a widget configuration activity cannot have android:launchMode="singleInstance". A singleInstance activity just never creates a widget! So I changed it to singleTop and now it works. This is also referred to in this question: Android AppWidget Configuration - Start in new task

Categories : Misc

How to create template tags in django and use Form?
First of all, will try include block to your template file: {% for field in form %} <div class="fieldWrapper"> {{ field.errors }} {{ field.label_tag }} {{ field }} </div> {% endfor %} Secondly, Is exist view post at the views.py for redirect(reverse('post', args=[request.POST.get('url')]), form=form)? Besides exist entry url(...) of the urlpatterns at the urls.py for post view? If both exists add it it to question's code

Categories : Django

How can I create custom form for User model Django
you want to create a form? create a form say forms.py from django.contrib.auth.models import User from django import forms class CreateUserForm(forms.Form): required_css_class = 'required' username = forms.RegexField(regex=r'^[w.@+-]+$', max_length=30, label="Username", error_messages={'invalid': "This value may contain only letters, numbers and @/./+/-/_ characters."}) email = forms.EmailField(label="E-mail") password1 = forms.CharField(widget=forms.PasswordInput, label="Password") password2 = forms.CharField(widget=forms.PasswordInput, label="Password (again)") def clean_username(self):

Categories : Python

Django: Modelform auto-create form in template
One thing you might check is the syntax of the render_to_response call. I believe you'll want to define it like this. (Maybe your syntax will work too, and this isn't the issue, but I have mostly seen the call made like this). This could be the cause of the missing form in the context. return render_to_response('post.html', {'form': form}, context_instance=RequestContext(request)) Let me know if this works. Hope this helps, Joe Reference: https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#django.shortcuts.render_to_response

Categories : Python

How to create such form: each db record has selection, with django forms?
I've found a quick solution like this: FRUITS = [ 'apples', 'lemons', 'strawberries', ] # hardcoded like here or from db ANSWERS = [ (0, u''), (1, u'selling'), (2, u'making'), (3, u'both'), ] # hardcoded like here or from db class ProblematicForm(forms.Form): # regluar fields goes here, like: regular_field = forms.CharField() def __init__(self, *args, **kwargs): super(ProblematicForm, self).__init__(*args, **kwargs) for name in FRUITS: # Here we add our problematic fields self.fields[name] = forms.ChoiceField(choices=ANSWERS) This won't give fieldset (like in linked example), but it wouldn't have. That's it o/

Categories : Django

How to dynamic create django form with the same "name=" attr for each field?
You don't do with multiple BooleanFields. You do it with a single MultipleChoiceField, which is output as a series of checkboxes with the same name.

Categories : Django

Django: ValueError: Cannot create form field because its related model has not been loaded yet
Firstly, you can try reduce code to: def new2(request, number): po=PurcchaseOrder.objects.get(pk=number) form = WorkflowForm(request.POST or None) if form.is_valid(): new_flow = form.save() return HttpResponse('Good') else: return render(request, 'new-workflow.html', {'form': form, 'purchase': po}) Secondly, I not understood why you at other case wrote forms.ModelChoiceField(...) and another case ModelForm instance forms.ModelForm ?

Categories : Python

Extending form types in Symfony2 (aka creating a new form widget)
You should declare your new type as service and inject the Entity Manager into it : namespace YourBundleFormType; use SymfonyComponentFormAbstractType; use SymfonyComponentFormFormBuilderInterface; use SymfonyComponentOptionsResolverOptionsResolverInterface; use DoctrineORMEntityManager; class NewExampleType extends AbstractType { protected $em; public function __construct(EntityManager $entityManager) { $this->em = $entityManager; } public function buildForm(FormBuilderInterface $builder, array $options) { //your code } public function setDefaultOptions(OptionsResolverInterface $resolver) { //your code } public function getParent() { return 'hidden'; } public function getName() {

Categories : Symfony2

Django Management Form is failing because 'form-TOTAL_FORMS' and 'form-INITIAL_FORMS' aren't correctly populated
Update: After looking through the example you provided there's a snippet that reads like this in forms.py at the end of the add_fields() method: # store the formset in the .nested property form.nested = [ TenantFormset(data = self.data, instance = instance, prefix = 'TENANTS_%s' % pk_value) ] The data argument is causing problems because it's initially empty and internally Django will determine whether or not a form is bound by a conditional that's similar to this: self.is_bound = data is not None # Example >>> my_data = {} >>> my_data is not None True And as you can see an empty dictionary in Python isn't None, so your TenantFormset is treated as a bound form even though it isn't. You could fix it with something like the fo

Categories : Django

How to get a time widget in django forms?
You're looking for the DateTime field. birth_time=forms.DateTime() For more info: https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.DateTimeField

Categories : Django

Django ClearableFileInput widget doesn't set FileField to None
I should just withdraw this question, the answer was me confusing None with Empty. I changed if article.docfile != None: to if article.docfile: and all was right with the world.

Categories : Django

Control the size TextArea widget look in django admin
This is a browser-specific problem. According to the thread Height of textarea does not match the rows in Firefox: Firefox always adds an extra line after the textfield. If you want it to have a constant height, use CSS ... You can set a style attribute of the textarea: class RulesAdmin(admin.ModelAdmin): formfield_overrides = { models.TextField: {'widget': Textarea( attrs={'rows': 1, 'cols': 40, 'style': 'height: 1em;'})}, } Works for me - tested on Firefox v. 23 and Chrome v. 29. Hope that helps.

Categories : Python

How to create right GUI widget by using Qt?
You should use QMainWindow if you need to use one of its features: toolbars, dock widgets, main menu or status bar (see QMainWindow docs for more information). If you don't need them, you can use QWidget as your top level widget. When working with QMainWindow, you need to set central widget using QMainWindow::setCentralWidget and add window contents to this widget, not to the QMainWindow itself.

Categories : C++

Django-How to make the django inbuilt auth view recognize the customized form
You should override the URL to pass your custom form class as a view keyword argument. Details in How to override a view from an external Django app.

Categories : Python

HTML5 form attributes with Django forms and django-bootstrap-toolkit
You can set the value of the widget.attrs to pass certain other HTML attributes to the form. >>> from django import forms >>> name = forms.TextInput(attrs={'size': 10, 'title': 'Your name',}) >>> name.render('name', 'A name') u'<input title="Your name" type="text" name="name" value="A name" size="10" />' -Django Docs

Categories : Django

Django : Storing user steps with django admin form
Django form wizard is what you want. You can use SessionWizardView for more easily display the wizard when user comes back again.

Categories : Python

Create widget with customview
yes, it is drawn on a canvas I would do something like this: public Bitmap createCustomView(){ Bitmap bitmap = Bitmap.createBitmap(BITMAP_WIDTH, BITMAP_HEIGHT, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); // draw on the canvas: // ... return bitmap; } and then set the Bitmap to the ImageView: remoteViews.setImageViewBitmap(R.id.imageView1, createCustomView() );

Categories : Android

Create a widget using QStackedLayout
From Qt Assistance The QStackedLayout class provides a stack of widgets where only one widget is visible at a time. So passing index is a key thing to identify the widget need to be displayed on StackedLayout at a particular point of time. Suppose your signal name is "activated(int)" declared in both mainWidget_ and createGameWidget_ So you need to connect like this //MainWindowWidget class. connect(MainWidget, SIGNAL(activated(int)), widgets_ , SLOT(setCurrentIndex(int))); connect(createGameWidget_, SIGNAL(activated(int)), widgets_ , SLOT(setCurrentIndex(int))); //In MainWidget class you need to emit signal MainWidget::ChangeLayout() { emit activated(1); //createGameWidget_will be displayed } //In createGameWidget_class you need to emit signal crea

Categories : Qt

how to create a focusable widget
We should have more information, because I miss some code, for example, where do you attach the Icon and TextNode to the DOM? I have done one example and it works for me. Look: @UiField Label labelText; public MyWidget(String text) { super(); //That is the key. Attach the widgets to the dom setElement(uiBinder.createAndBindUi(this).getElement()); labelText.setText(text); } Also instead of having my internal widgets declared in the class, I have created a UiBinder class. Basically: <!DOCTYPE ui:UiBinder SYSTEM 'http://dl.google.com/gwt/DTD/xhtml.ent'> <ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' xmlns:g='urn:import:com.google.gwt.user.client.ui'> <ui:style> </ui:style> <g:FlowPanel> <g:Label ui:field="labelText">

Categories : Gwt

in Qt how to know which component (placed on a widget or form ) is currently focused?
If you want to stop the keyboard from flickering when the widget it's coming from and the one it's going to are similar then you could perhaps implement a timer. I imagine you have the lost focus signals going to your code that is hiding the keyboard. Instead of really hiding it, you can start a timer like QTimer::singleShot(500, this, SLOT(really_close_keyb())); Within that really_close_keyb() slot you could implement code to check if the widget that currently has focus should have a keyboard or not, and if it should then you don't hide it. With this your keyboard will be up for 1/2 sec after the user focuses out of a line edit, giving enough time to focus on another one without losing the keyboard. Adjust the timing to suit.

Categories : Qt

Can't get django-testapp to work or create a superuser with django-norel
This has nothing to do with django-nonrel. Does your settings.py file exist? If it does, it's probably syntactically incorrect, run python settings.py to identify the SyntaxError.

Categories : Python

Dynamic selector in nested form
Once your form reaches that level of complexity, I'd recommend replacing it with a custom template - Formtastic will only get you so far, unfortunately. In a custom form, you could use jQuery to set the options in the product select to reflect the right values for the campaign - or even drop the product select into a partial and reload it via ajax when the campaign select is changed.

Categories : Ruby On Rails

create widget for wordpress plugin
In your function getLosninger, you start an output buffer ( ob_start() ), but you don't do anything with it. You might be safe removing that line of code, or at least capturing the contents of the output buffer and flushing it.

Categories : Wordpress

Including a PHP-file containing form in WordPress widget
I know you've mentioned that your $this->plugin_directory is set in the constructor as the correct path, have you tested the output of this and/or is it set as the absolute path or relative? I've had issues in the past where plugin files couldn't read the relative path correctly and so therefore I had to switch to an absolute path instead or vice-versa.

Categories : PHP

How do I add a class to each expanded form widget in Symfony2?
You would need to extend Twig, I believe. You can then specify the code in PHP and just bring in the conditions. http://twig.sensiolabs.org/doc/advanced.html

Categories : Symfony2

Create a language selector with xslt
XML has the xml:lang attribute standardized and specified to mark up the language and XSLT/XPath support that by using the lang function http://www.w3.org/TR/xpath/#function-lang. Therefore I would strongly suggest to use that mechanism instead of building your own. With XSLT 2.0 you can easily define <xsl:variable name="my-text"> <list> <text xml:lang="en">Text in English</text> <text xml:lang="fr">Texte en français</text> <text xml:lang="es">Texto en español</text> </list> </xsl:variable> and then use <xsl:template match="Foo"> <block><xsl:value-of select="$my-text/list/text[lang(current()/Language)]"/></block> </xsl:template>

Categories : Xml

Dynamically create a css selector for Chrome
I dont know if this is easier then what you're trying to do with JS. But when i need to override certain styles for a specific browser I just create a check for the browser serverside, and then include an extra stylesheet that overrides the base styles.

Categories : Javascript

Need jQuery selector for hidden form element
$("input[name=myhidden]").val(this.value); just modify the selector. see the docs http://api.jquery.com/category/selectors/

Categories : Jquery

Jquery hidden form data selector by $(this)
if you have current form reference in this , you can do this - var myVar=$(this).find('input#var1').val(); It seems you are having duplicate IDs though -- you can use class instead (as IDs should be unique) If #var1 were unique, you don't need this to reference your input var myVar = $('#var1').val();

Categories : Jquery

Can't create simple Android widget in Idea
The problem was in xml/kbs_widget_provider.xml file. I forgot schema for xmlns:android attribute. The correct one is: xmlns:android="http://schemas.android.com/apk/res/android"

Categories : Android

Symfony2, how create a widget like a standalone class
Symfony doesn't provide such a feature however you can make them yourself. They are few ways of doing it. I'll just admit that we are talking about widgets that could do backend work (i.e. get data from DB, call an API, etc.). 1 - The scalable way The use of the render tag in Twig which allows you to call a controller action from a template. It's scalable because you could use esi tags with Varnish (you can also implement your own caching profiles). As a bonus, the profiler will show details about the specific render calls in the timeline (it will look like a subset of the entire request). 2 - Include a template The included template gathers the data through a Twig function call. By experience, it's a bit faster than the first solution however it's not easily scalable. 3 - Render th

Categories : Symfony2

Android: Create colored TextClock widget
Okay, I think the problem was calling appWidgetManager.updateAppWidget(appWidgetId, views); when the new RemoteView object (views) did not have .setTextColor(color) called on it. I hope that helps someone. Color Clock app source (GPLv3): https://github.com/NightlyNexus/Color-Clock

Categories : Android

$instance in wordpress widget form method is null
The code is crashing because the variable $instance is not an array. The extract() function has to receive an array in order to do it's job. That much is clear and very simple. The problem is that nobody can help you explain why $instance is null unless you provide the code which calls the form() function. There could be a million reasons why $instance is not an array.

Categories : Wordpress



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