Re: Request for new user account via email Django
There was a different problem actually, RequestContext(request) was never called I removed that line and put it in the above return. Worked fine :) thank you for the effort tho On Aug 4, 5:58 pm, Shawn Milochik wrote: > In your view you should be instantiating the form with the data from > request.POST instead of reading the values directly. > > Also, you mention that you get a 403 error when you post your name and > password, but the form and template you pasted don't include password, > so I suspect the error is coming from elsewhere. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Request for new user account via email Django
I am trying to make a little function for a user to request an account and the information he puts in is sent to a person who will make an account. I was following this example mostly http://djangosnippets.org/snippets/261/ but it is very old and might be inaccurate for I have got and thus I have problems with it. I have this code currently: ###account/models.py from django import forms from django.core.mail import send_mail, BadHeaderError # A simple contact form with four fields. class NewAccountForm(forms.Form): first_name = forms.CharField() last_name = forms.CharField() email = forms.EmailField() ###account/views.py from django.http import HttpResponse from django.http import HttpResponseRedirect from django.shortcuts import render_to_response from django.template import RequestContext from account.models import NewAccountForm from django import forms from django.core.mail import send_mail, BadHeaderError def request_account_view(request): first_name = request.POST.get('first_name', '') last_name = request.POST.get('last_name', '') email = request.POST.get('email', '') message = (first_name + ' ' + last_name + ' has requested a new account for the email ' + email) if first_name and last_name and email: try: send_mail('Request for Account', message, email, ['exam...@example.com']) except BadHeaderError: return HttpResponse('Invalid header found.') return HttpResponseRedirect('/thankyou/') else: return render_to_response('new_account.html', {'form': NewAccountForm()}) return render_to_response('new_account.html', {'form': NewAccountForm()}, RequestContext(request)) def thankyou(request): return render_to_response('thankyou.html') ###urls.py (r'^thankyou/$', 'account.views.thankyou'), (r'^new_account/$', 'account.views.request_account_view'), ###templates/new_account.html {% extends "base.html" %} {% block content %} {% csrf_token %} First Name: Last Name: Email: {% endblock %} I am getting an error for: Forbidden (403) CSRF verification failed. Request aborted. which occurs after I input name and password and click submit. My email host is working fine because I previously was working on a "Forgot Password" function. I would really appreciate help. Thank you. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
.css files of the admin pages
I would like to know how to make changes to the built in style sheets in the admin pages I went into this directory where i found images being used in the admin website Django-1.3\django\contrib\admin\media\img\admin and changed images but it didn't effect my project at all. Is that the wrong place? Re running the project didn't help. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Extending the User form
please see this discussion http://groups.google.com/group/django-users/browse_thread/thread/143942b9002c1468/c4fbf04d75471fbf?lnk=gst&q=Shegoroa#c4fbf04d75471fbf I made two by accident and marked this for removing, but they didn't for some reason. I updated it with a new post, which should show up soon. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Extending new User form
On Jul 28, 4:27 pm, Derek wrote: > On Jul 28, 10:31 am,Shegoroa wrote: > > > I am having difficulty figuring out how to make an admin when creating > > a new user to have an extra field specifying users location. > > > I found lots of information on how to extend the user profile and i > > did so > > (source of > > information)http://stackoverflow.com/questions/44109/extending-the-user-model-wit... > > > But now I want the admin every time when he is creating a new user for > > there to be a new field under Personal Information of a user to have > > an extra field for Location of user. > > That is an old post (2008) - you're better off starting with the > current > documentation:https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional... > > Try and follow this and ask back here if you get stuck; showing what > code you have created and identifying where/how it does not work (also > see:https://code.djangoproject.com/wiki/UsingTheMailingList) sorry for the delay in replying I have added an extra field for the User by doing the whole process where making User Profile app and extending the User module. It doesn't seem to error. What I cant figure out, or find anywhere is how to show this new field in the page where an admin creates a new user. So under personal information such as First name and last Name I want there to be Location field that I added to User Profile. my User Profile: from django.db import models from django.contrib.auth.models import User from django.db.models.signals import post_save class UserProfile(models.Model): # This field is required. user = models.OneToOneField(User) # Other fields here location = models.CharField(max_length=20) # definition of UserProfile from above # ... def create_user_profile(sender, instance, created, **kwargs): if created: UserProfile.objects.create(user=instance) post_save.connect(create_user_profile, sender=User) also I would like to know how to make the email mandatory, like password and username. Just changing the user model in the Django folder to: email = models.EmailField(_('e-mail address'), unique=True) didn't work at all. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Extending the User form
I have extended the User Profile by adding my own field, how do I change the New user form in the admin, to show the new field? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.