Wednesday, June 1, 2011

Re: Contact us form

On Wednesday, 1 June 2011 08:01:33 UTC+1, Pulkit Mehrotra wrote:
I am trying to make a contact us form which will send a mail to me using the smtp server .It will load the thank you page after form submission .Everything is working something ,the thank you page is loading and i am not getting any errors ,but i am not getting the mails.

here is my views.py file.:
from django.shortcuts import render_to_response
from django.core.mail import send_mail
from django.http import HttpResponseRedirect
from django.template import RequestContext
def contacts(request):
    errors=[]
    if request.method=='POST':
        if not request.POST.get('subject',''):
            errors.append('Enter a subject')
        if not request.POST.get('email') and '@' not in request.POST['email']:
            errors.append('Enter a valid email address')
        if not errors:
            send_mail(
                request.POST['subject'],
                request.POST['message'],
                request.POST.get('email','mehrotr...@gmail.com'),
                ['mehrotr...@gmail.com'],
            )
            return HttpResponseRedirect('/contact/thankyou/')
    return render_to_response('form.html',{
        'errors':errors,
        'subject':request.POST.get('subject',''),
        'email':request.POST.get('email',''),
        },context_instance=RequestContext(request))


Why don't you use an actual Django form? It will take care of the validation for you.
--
DR. 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/bFVfQm1CdU1SMW9K.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: getting 'NoneType' object is unsubscriptable errors

On Wednesday, 1 June 2011 08:48:13 UTC+1, saureen adani wrote:

Hi,

I am getting the following errors on some of the web pages

-----------------------------------------------------------

'NoneType' object is unsubscriptable

Request Method: GET
Request URL: http://nerd.hoonur.com/mypage/4605f1e14430950e07b74b5374472f00
Exception Type: TypeError
Exception Value:

'NoneType' object is unsubscriptable

Exception Location:
/home/balaji/new-staging-setup/trunk/hydra_classifieds/root/balaji_classifieds/classifieds/views.py
in get_gadget_data, line 2570 

<snip>


You didn't think it would be useful to show us some of the actual code?

Although to be honest, if your views.py is over 2570 lines long, you've got more problems than we can sort here.
--
DR. 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/MVZVN0hWU2M0d3dK.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Contact us form

It's probably your sendmail configuration on your server. Can you send email from the command-line? Try using the command "mail my@email.com"
You can also tell django to use a different mail server than localhost using the EMAIL_HOST, EMAIL_PORT, etc settings in your settings.py file.

On 1 Jun 2011, at 08:01, Pulkit Mehrotra wrote:

> I am trying to make a contact us form which will send a mail to me using the smtp server .It will load the thank you page after form submission .Everything is working something ,the thank you page is loading and i am not getting any errors ,but i am not getting the mails.

--
Brett Hutley, CTO Stimuli Limited
brett@stimuli.org
brett@hutley.net

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Chained forms

On May 31, 6:55 pm, Marc Aymerich <glicer...@gmail.com> wrote:
> Hi!,
> I'm writing an admin action.
> This action needs to collect some information before execute the "final
> task".
> In order to collect this information the user should fill 3 consecutive
> forms, (once they submitted one, another is rendered).
>
> My question is,
> How can I store the form fields state submitted on each form, and retrieve
> this fields states on the final form, before execute the 'final task'?


This is a well-known problem, with 2 well-known solutions: 1/ store
the state in hidden fields or 2/ use sessions.

The form-wizard contrib app mentionned by DrBloodmoney uses the first
approach, which makes it "more general" since you can use it without
having to resort to sessions. OTHO, I didn't find it quite as easy to
use and flexible as I would have liked, specially when I had to fork
it to give users the possibility to navigate backward. You should
nonetheless give it a try first and see if it works for you. If it
doesn't, you may want to roll your own session-based solution.

HTH

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

getting 'NoneType' object is unsubscriptable errors

Hi,

I am getting the following errors on some of the web pages

-----------------------------------------------------------

'NoneType' object is unsubscriptable

Request Method: GET
Request URL: http://nerd.hoonur.com/mypage/4605f1e14430950e07b74b5374472f00
Exception Type: TypeError
Exception Value:

'NoneType' object is unsubscriptable

Exception Location:
/home/balaji/new-staging-setup/trunk/hydra_classifieds/root/balaji_classifieds/classifieds/views.py
in get_gadget_data, line 2570
Python Executable: /usr/bin/python
Python Version: 2.6.2
Python Path:
['/home/balaji/new-staging-setup/trunk/hydra_classifieds/root/',
'/usr/local/lib/python2.6/dist-packages/pymongo-1.7-py2.6-linux-x86_64.egg',
'/usr/local/lib/python2.6/dist-packages/simplejson-2.1.1-py2.6.egg',
'/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2',
'/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old',
'/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages',
'/usr/lib/python2.6/dist-packages/PIL', '/var/lib/python-support/python2.6',
'/var/lib/python-support/python2.6/gtk-2.0',
'/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode',
'/usr/local/lib/python2.6/dist-packages',
path('/home/balaji/new-staging-setup/trunk/python_modules'),
path('/home/balaji/new-staging-setup/trunk/hydra_classifieds/root/balaji_classifieds/python_modules')]
Server time: Wed, 1 Jun 2011 12:51:55 +0530

-----------------------------------------------------------

I tried putting the code line where the error was occuring under
try-catch-exception but still the error exits.

What could be the reason for the above error and possible solution to get
rid of above error?

Help would be highly appreciated !
--
View this message in context: http://old.nabble.com/getting-%27NoneType%27-object-is-unsubscriptable-errors-tp31747339p31747339.html
Sent from the django-users mailing list archive at Nabble.com.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Auditing Record Changes in All Admin Tables

The model code still needs to stay in the model, it is just the save_model method had to be moved to the admin.py.  I think the following is what you are looking for:

models.py
---------------
from django.db import models
from django.contrib.auth.models import User

class AuditedTable(models.Model):
    created = models.DateTimeField(auto_now_add=True)
    created_by = models.ForeignKey(User, editable=False)
    updated = models.DateTimeField(auto_now=True)
    updated_by = models.ForeignKey(User, editable=False)
   
    class Meta:
        abstract = True

class Entity1(AuditedTable):
    title = models.CharField(max_length=20)
   
    def __unicode__(self):
        return self.title

admin.py
-------------
from django.contrib import admin
from app.models import Entity1

class AuditAdmin(admin.ModelAdmin):
    def save_model(self, request, obj, form, change):
        if change:
            obj.updated_by = request.user
        else:
            obj.created_by = request.user
        obj.save()

class Entity1Admin(AuditAdmin):
    pass

admin.site.register(Entity1, Entity1Admin)

Hope that helps,

Ryan

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/NV9uTUJxUVRkTW9K.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Contact us form

I am trying to make a contact us form which will send a mail to me using the smtp server .It will load the thank you page after form submission .Everything is working something ,the thank you page is loading and i am not getting any errors ,but i am not getting the mails.

here is my views.py file.:
from django.shortcuts import render_to_response
from django.core.mail import send_mail
from django.http import HttpResponseRedirect
from django.template import RequestContext
def contacts(request):
    errors=[]
    if request.method=='POST':
        if not request.POST.get('subject',''):
            errors.append('Enter a subject')
        if not request.POST.get('email') and '@' not in request.POST['email']:
            errors.append('Enter a valid email address')
        if not errors:
            send_mail(
                request.POST['subject'],
                request.POST['message'],
                request.POST.get('email','mehrotra.pulkit@gmail.com'),
                ['mehrotra.pulkit@gmail.com'],
            )
            return HttpResponseRedirect('/contact/thankyou/')
    return render_to_response('form.html',{
        'errors':errors,
        'subject':request.POST.get('subject',''),
        'email':request.POST.get('email',''),
        },context_instance=RequestContext(request))

def thankyou(request):
    return render_to_response('thankyou.html')

here is my form.html:

<html>
<head>
    <title>Contact Us </title>
</head>
<body>
<h1>Contact us </h1>
    {% if errors %}
        <ul> {% for error in errors %}
            <li> {{ error }} </li>
              {% endfor %}
        </ul>
    {% endif %}
   
    <form action="/contact/" method="POST">   
    {% csrf_token %}
        <p>Subject:<input type="text" name="subject" value="{{ subject }}" ></p>
        <p>Email :<input type="text"name="email" value="{{ email }}"></p>
        <p>Message :<textarea name="message" rows="10" columns="50" ></textarea></p>
        <input type="submit" value="Submit">
    </form>
    </body>
    </html>    

and here is my thankyou.html:

<html>
<h1>thank you</h1>
</html>

i am using the postfix smtp server

any help would be appreciated,thank you

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/cTl4LTcwblFiVzhK.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.