w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Django-allauth: custom signup form for socialaccount
As of now you can defined SOCIALACCOUNT_FORMS in your settings to set your own custom social signup form: SOCIALACCOUNT_FORMS = { 'signup': 'myproject.myapp.forms.CustomSocialSignupForm' }

Categories : Django

django-allauth: verifying email only on non social signup
it seems that the doc says SOCIALACCOUNT_EMAIL_VERIFICATION (=ACCOUNT_EMAIL_VERIFICATION) As ACCOUNT_EMAIL_VERIFICATION, but for social accounts. if you set this one, django-allauth may do the difference when the user logs in did you try it too ?

Categories : Python

Django-allauth: send welcome email on signup (without verification)
No there is no such settings, but you can listen to a user_signed_up signal, which will have the user and request in parameters. Once it received send an email to the user. Put the below code some where in models.py file: from allauth.account.signals import user_signed_up from django.dispatch import receiver @receiver(user_signed_up, dispatch_uid="some.unique.string.id.for.allauth.user_signed_up") def user_signed_up_(request, user, **kwargs): # user signed up now send email # send email part - do your self

Categories : Django

How to add extra fields after fb auth in Django allauth
Answer to block one can be found here How to customize user profile when using django-allauth for Block 2, Add this to your settings.py INSTALLED_APPS = ('allauth.socialaccount.providers.linkedin', )

Categories : Django

django adding fields to model form
Use two separate forms - UserForm, created out of models.User & AddStaffForm but exclude the 'user' field in the AddStaffForm. Use only ONE submit button for both. So your template will look like: <form method="post" action="/path/to/wherever"> {{ user_form }} {{ add_staff_form }} <button>Submit</button> </form> Then, when the user submits the form, process each form independently in the following order: Process the user form first and save the user instance created by the form to the db. if user_form.is_valid() is True, you can do this by simply doing user = user_form.save() Next, process the AddStaffForm but pass commit=False (i.e. staff = add_staff_form.save(commit=False) since it does not contain the value for the user field just yet. Prov

Categories : Django

Adding checkbox in signup form
For that you can add a new migration to add a new column as boolean field to your users table. http://guides.rubyonrails.org/migrations.html rails g migration AddTermsAcceptedToUsers It will create a migration file in your db/migrate folder. Now you need to add the code to it. class AddTermsAcceptedToUsers < ActiveRecord::Migration def change add_column :users, :terms_accepted, :boolean, :default => false end end Then do rake db:migrate. Now your users table is having a column as terms_accepted. Then add it as attr_accesible. attr_accessible :terms_accepted. Now use this field and show it as checkbox in the registration page. <%= f.check_box :terms_accepted%>

Categories : Ruby On Rails

Customizing Text in WordPress's wp-signup.php
As Dave Kiss said in his comment above, this string isn't filterable so you can't filter the text. The string isn't marked either so you can't use a translation file. I suggest you open a WordPress Trac ticket requesting the text be marked or made filterable. You can open a new ticket here: http://core.trac.wordpress.org/

Categories : Wordpress

Can I have unique urls to the multi step signup form built using Django Wizard.
NamedUrlWizardView should provide the functionality you are looking for.

Categories : Django

How to make some django form fields depend on the value of other fields?
form.clean is the right place to do this. What's not right is calling clean_<field> for other fields - they will have already been cleaned and their values will be in the cleaned_data dict. Take a look at the example in the docs: https://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other It runs through almost exactly this scenario, showing how you can test one field based on another and how you can either raise a form-level error when missing or bind the error to one of the fields.

Categories : Django

Django fixtures for model from imported application (like django-allauth)
I found here that table from model django.contrib.sites.models.Site can be populate using [ { "model": "sites.site", "pk": 1, "fields": { "domain": "myproject.mydomain.com", "name": "My Project" } } ] So model allauth.socialaccount.models.SocialApp probably can by populated by: [ { "model":"socialaccount.socialapp", "pk":1, "fields":{ "id":"1", "provider":"facebook", "name":"facebook", "client_id":"0011223344556677", "key":"", "secret":"012345678901234567890123456" } } ]

Categories : Django

Plug in django-allauth as endpoint in django-rest-framework
While I'm not quite sure how to use allauth and rest-fremework together, allauth does not offer such an endpoint. Suggestion: make your own that does a variation of the following: Call allauth.socialaccount.providers.facebook.views.fb_complete_login(None, socialtoken) where socialtoken is as created in login_by_token. That performs (a few functions deeper) a django.contrib.auth.login, possibly creating the acct. After that, for use on mobile devices, it might be possible to the the auth (not FB) token: get the user data (from session?), and call rest_framework.authtoken.views.obtain_auth_token Notes: 1. This offers no way to resolve email conflicts or connect social/local accts. 2. I haven't tried it - please post code if you can get it working.

Categories : Python

How do I preserve the information keyed in by the user in Django form fields when the submission fails validation while using a CSS customized form?
You can use {{form.name.value}}, and it will repopulate the value entered for a particular field when an invalid form is redisplayed. <input class="box" type="text" name="name" id="id_name" maxlength="100" value="{{form.name.value}}"/>

Categories : Django

Django Unittest for form with password
In this case you just have to use a data arg instead of initial: def test_new_user_joining(self): form_data = { 'full_name': #invalid value, 'email': 'test_email@gmail.com', 'password': 'password' } form = SignupForm(data=form_data) if form.is_valid(): self.fail('Form should not be valid') form_data['full_name'] = # valid value form = SignupForm(data=form_data) if not form.is_valid(): self.fail('Form should be valid')

Categories : Django

What is the right way to use django-allauth with tastypie?
I used requests library to deal with facebook API and it works great, I think no social login plugin for Django works for others but the author, if you want to do something seriously. PS. I used django-rest-framework to build the rest backend for mobile apps, also including local account login and social site login.

Categories : Python

Django AllAuth Installation
1) Have a look here: https://speakerdeck.com/tedtieken/signing-up-and-signing-in-users-in-django-with-django-allauth (specifically, slide 61 and above) 2) Simply use 127.0.0.1:8000 in your redirect URLs 3) By default allauth redirects to LOGIN_REDIRECT_URL, which is set out of the box to /accounts/profile/: https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url 4) As I am the author of allauth I will skip answering this question myself. Browse through the complete presentation referred to by 1) -- the initial slides provide a good comparison of the various options.

Categories : Django

django form without any fields
I found a solution which fits my needs: Just take any_field and make it a hidden field: from django.forms import HiddenInput class MyModelForm(ModelForm): class Meta: model = MyModel widgets = {'any_field': HiddenInput(),} Dont forget to exclude all the other fields.

Categories : Django

Testing Django 1-5 Reset Password Form - how to generate the token for the test?
Ok, I was just searching for info on how to do this and your question prompted me to figure it out myself. I'm not sure if you're still working on this, but here's how I got it to work: # First we get the initial password reset form. # This is not strictly necessary, but I included it for completeness response = self.c.get(reverse('password_reset')) self.assertEqual(response.status_code, 200) self.assertEqual(response.template_name, 'authentication/password_reset_form.html') # Then we post the response with our "email address" response = self.c.post(reverse('password_reset'),{'email':'fred@home.com'}) self.assertEqual(response.status_code, 302) # At this point the system will "send" us an email. We can "check" it thusly: self.assertEqual(len(mail.outbox), 1) self.assertEqual(mail.outb

Categories : Django

Social Avatar with Django-Allauth
Disregard, I actually do/did have it set up correctly. I was just logged in with a test account that had gone through auth and profile creation prior to configuring my avatar settings and adding avatar to my db tables. Leaving this up for reference in case it's helpful to anyone else.

Categories : Python

How to override template in django-allauth?
I eventually resorted to loading my app before django-allauth. In settings.py: INSTALLED_APPS = ( ... 'myapp', 'allauth', 'allauth.account' ) This solution goes against what's presented in example app, but I was not able to solve it in other way.

Categories : Python

Difficulty using Django-AllAuth Example application
uni_form_tags not found. It means you didn't install django-uni-form or it not included to your template by {% load uni_form_tags %}

Categories : Python

Django-allauth 0.8.1 Twitter integration
Best option is to update allauth to 0.8.3 or newer :) After hours of debugging and frustration , i finally had my answer. Twitter updated their API few months ago, so its not compatible with allauth == 0.8.1 anymore. allauth.socialaccount.providers.views.py Line - 17 url = 'https://twitter.com/account/verify_credentials.json' this should be url = 'https://api.twitter.com/1.1/account/verify_credentials.json'

Categories : Misc

Form fields in django templates
According to the documentation here you should be iterating on the form object itself not the fields. So instead of form.fields, just use form. {% for field in form %} {{ field.label_tag }}: {{ field }} {% endfor %} I just found this duplicate question as well: django: form.fields not iterating through instance fields

Categories : Django

Adding non-entity fields to a form
You can add it as any other widget to the form's widgetSchema. Of course you have to remember to also add a validator or the validation will fail with an unexpected field error. Symfony is smart enough to ignore the field when persisting the object to the database.

Categories : Forms

Django allauth login with google account
You have configured a HTTPS redirect URI, whereas your Django app is using HTTP URIs. Either add http://tutor.herokuapp.com/accounts/google/login/callback over at the Google API console, or use HTTPS for your Django project.

Categories : Api

Django allauth scope SOCIALACCOUNT_PROVIDERS documentation
The scope related parameters are really provider dependent. You will have to look up the parameters and what is possible up in the documentation of the particular provider (for FB, check here for info on scope: https://developers.facebook.com/docs/reference/dialogs/oauth/). As for e-mail on Twitter: they simply do not hand over this information. So, your app will have to cope with that. See: https://dev.twitter.com/discussions/4019

Categories : Django

django-allauth social network error
You mention that visitting http://127.0.0.1:8000/accounts/socialnetwork/login/ (where I assume socialnetwork is one of google/twitter/facebook) works fine. Congratulations! -- because these are the proper entry points for logging in with a third party provider. You should not be visitting the callback url directly yourself. It is meant to be redirected to by the third party provider. In doing so, it passes along authentication related codes that can be used to login. If you visit the url directly these codes are not passed, hence, the system will complain with "an error has occurred"... As for the issue with respect to the social connections url: what you see here is all third party accounts connected to the local user account. So, if it varies from time to time I can only assume you are

Categories : Django

django-allauth HTML email not send
For those facing the same issue : When it comes to email confirmation django_allauth checks if its a new user or not and looks for template accordingly : So you'll have to override : email_confirmation_message.txt email_confirmation_signup_message.txt and add HTML version email_confirmation_message.html email_confirmation_signup_message.html

Categories : Django

Django-allauth with multiple profile models
Take a look at the allauth.account.signals.user_signed_up signal, which is triggered just after the user (social or normal) signs up. You can do your stuff with your account there: from django.dispatch import receiver from allauth.account.signals import user_signed_up @receiver(user_signed_up) def do_stuff_after_sign_up(sender, **kwargs): request = kwargs['request'] user = kwargs['user'] # Do your stuff with the user user.save() From django-allauth repo: # Typically followed by `user_logged_in` (unless, e-mail verification kicks in) user_signed_up = Signal(providing_args=["request", "user"]) To learn how to use signals in django, read the official documentation about it. I hope it helps you! EDIT I'm glad you found your way through your problem, but since middlewa

Categories : Django

django form multiple fields dynamically
i did this without using django forms .. just using html forms to upload multiple as many as user wishes.. this is my template.html file which has normal form without any input file field initially the js method adds a new input file field to the form when clicked on "add new item" href <form action="{{request.path}}" method="post" enctype="multipart/form-data" id="upload_form"> {%csrf_token%} <input type="text" name="name" id="name" value="{{request.POST.name}}" placeholder="Person Name"/> <input type="text" name="categorie" id="categorie" value="{{request.POST.categorie}}" placeholder="Categorie"/> <div class="file_inputs" id="file_inputs"> <!-- <-- field where im adding multiple files initially empty --> </div>

Categories : Python

Django dynamic form & ordering of fields
When things start to become unmanageable inside my forms __init__, I generally take one of the following approaches: Create a Factory Leveraging closures, write a function to build out the fields dynamically then return that class. def TicketForm(): fields = ['title', 'date', 'content'] for custom_field in custom_fields: fields.append(custom_field) fields.append('ticket_content') fields.append('ticket_attachment1') class _TicketForm(forms.ModelForm): class Meta: model = Ticket fields = fields return _TicketForm Multiple forms I'll create several different forms based on the use case, then within my view determine which one should be returned. I posted an example of this yesterday. For further reading, check out a po

Categories : Django

How would I make Django form fields have children?
The problem is that you're outputting fields not associated with any forms. I'll suggest you to create the dictionary overriding the __init__ method of the form: def __init__(self, *args, **kwargs): super(DetailForm, self).__init__(*args, **kwargs) self.fields_dict = {self['a']: [self['a1']], self['b']: [self['b1'], self['b2']], self['c']: [self['c1'], self['c2'], self['c3']] } Hope this helps!

Categories : Django

Django "Instance" Form Fields Not Rendering
Form.fields holds the fields themselves, what you want for rendering are the BounFields that you can get directly from the form itself, ie: def iter_email(self): for k in sorted(self.fields.keys()): if k.startswith('email_'): yield self[k]

Categories : Python

django form constructor not returning fields?
Because you haven't defined any fields on the form. You can't just set them in __init__ and hope that will work: there's complicated metaclass stuff going on, and the definitions have to be at the class level. What you can do in __init__ is override the choices of the existing field: class eventForm(forms.Form): event = forms.ChoiceField() def __init__(self, *args, **kwargs): user=kwargs.pop('user') super(eventForm, self).__init__(*args, **kwargs) elist = [(e.id,e.name) for e in Event.objects.filter(organizer_id__exact=user)] self.fields['event'].choices = elist

Categories : Django

Adding fields to Access table from a form
Make a new table that will hold your extra items. Foreign key it back to the table that the form is bound to, and include two fields, Name and Value. Something like: tblItemExtraInfo ---------------- ItemExtraInfoID (pk) OrigItemID (fk) Name (e.g. item1) Value In this way, your additional data items effectively become name-value pairs, and you don't have to deal with messy DDL in the middle of your form. Worse, IIRC, the database needs to be opened exclusively in order for DDL to be executed, which means nobody would be able to be in the db at the same time.

Categories : Ms Access

Copy form object and adding new fields
I don't think you can, but try to make the UserName field mapping optional so it doesn't get in your way when you don't need it: mapping( UserName -> optional(nonEmptyText.verifying(Messages(UserNameAlreadyTaken), userName => { UserService.find(IdentityId(userName, providerId)).isEmpty })), ... ) Since the case class corresponding field already is optional, there won't be any harm. Still, the Password mapping isn't the same for the two forms. So you should keep them all, refactoring the similar parts.

Categories : Scala

Turn off user social registration in django-allauth?
Looks like you need to override is_open_for_signup on your adapter. See the code.

Categories : Django

how to integrate single sign on from disqus with django allauth
Disqus has a guide at: http://help.disqus.com/customer/portal/articles/236206-integrating-single-sign-on "Access to Single Sign-On (SSO) is currently available as a free add-on for your Disqus account. Please contact our support team via this contact form and ask them to enable it for your account." "Single sign-on (SSO) allows users to sign into a site and fully use Disqus Comments without again authenticating with Disqus. SSO will create a site-specific user profile on Disqus so as not to clash with existing users of Disqus."* Disqus itself is not a SSO provider. But if your users authenticate to your site, they can access disqus without an additional login.

Categories : Django

Saving custom user model with django-allauth
Side note With Django 1.5 custom user model, the best practice is to use the get_user_model function: from django.contrib.auth import get_user_model # forms.py class SignupForm(forms.Form): first_name = forms.CharField(max_length=30) last_name = forms.CharField(max_length=30) age = forms.IntegerField(max_value=100) class Meta: model = get_user_model() # use this function for swapping user model def save(self, user): user.first_name = self.cleaned_data['first_name'] user.last_name = self.cleaned_data['last_name'] user.age = self.cleaned_data['age'] user.save() # settings.py ACCOUNT_SIGNUP_FORM_CLASS = 'web.forms.SignupForm' Maybe it's not related, but I thought it would be worth noticing.

Categories : Python

Django form with dynamic fields and manytomany relationschips
For problem 1, this makes sense because if you create a model which is refered to by other models, said model key must exist. What I'd suggest you do is look into saving multiple models with a transaction. 2 is pretty easy, just use jQuery/Javascript to show/hide the appropriate fields in the browser based on the user's selection event. Based on your comment, here's an example of how I handle data to and from the server //Submit data to server, assuming you have already extracted out the relevant data values $("some_button").click(function(e){ $.ajax({ url : "someUURLLocation/", type : "POST", data : {"data" : JSON.stringify({"field1" : var1, "field2" :var2}), dataType : "json", success : function(results){ if (results.success == "true") { //handle D

Categories : Python

Django form with __init__ doesn't clean fields
Based on the code you posted, it looks as though you are passing request.POST into the request parameter for your RegistrationForm. i.e. you are doing the equivalent of: form = RegistrationForm(request=request.POST) What you really want to do is this: form = RegistrationForm(request=request, data=request.POST) Try this and see if it works for you.

Categories : Django



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