Hi folks--

I've got the following code in a view:

from django.shortcuts import get_object_or_404, render_to_response
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from mysite.officemeetingpoll.models import Meetingtime
from django.contrib.auth.decorators import login_required
from django.contrib.auth import authenticate, login
from django.newforms import form_for_instance

@login_required
def vote(request):
        m = Meetingtime.objects.get(user=request.user)
        UserForm = form_for_instance(m)
        f = UserForm(auto_id=False)
        return render_to_response('officemeetingpoll/form.html', {'form':f})

I'm hoping this will check if the user is logged in, go to the default  
login page & redirect back if not, & then render an edit form for the  
office meeting poll.

Here's the model:

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

class Meetingtime(models.Model):
        time = models.CharField(max_length=40)
        user = models.ManyToManyField(User, blank=True, null=True)
        CONVENIENCE_CHOICES = (
                ('A', 'I can make this time regularly'),
                ('S', 'I could occasionally make this time'),
                ('N', 'I could rarely if ever make this time'),
        )
        convenience = models.CharField(max_length=1,  
choices=CONVENIENCE_CHOICES)
        unique_together = (("user", "time"),)
        def __unicode__(self):
                return self.time
        class Admin:
                list_display = ('time', 'convenience')
                fields = (
                        (None, {'fields': ('time', 'convenience', 'user')}),
                )



However, it doesn't send me to the login page, it generates the  
following error:


DoesNotExist at /officepoll/officepolls/
Meetingtime matching query does not exist.
Request Method:         GET
Request URL:    http://www.rainbow.coop/officepoll/officepolls/
Exception Type:         DoesNotExist
Exception Value:        Meetingtime matching query does not exist.
Exception Location:     /usr/local/lib/python2.5/site-packages/django/db/ 
models/query.py in get, line 263
Python Executable:      /usr/local/bin/python
Python Version:         2.5.1
Python Path:    ['/home/jason/killdjangokill', '/usr/local/lib/python2.5/ 
site-packages/TurboGears-1.0.3.2-py2.5.egg', '/usr/local/lib/python2.5/ 
site-packages/SQLObject-0.9.1-py2.5.egg', '/usr/local/lib/python2.5/ 
site-packages/Cheetah-2.0rc8-py2.5-linux-i686.egg', '/usr/local/lib/ 
python2.5/site-packages/configobj-4.4.0-py2.5.egg', '/usr/local/lib/ 
python2.5/site-packages/DecoratorTools-1.5-py2.5.egg', '/usr/local/lib/ 
python2.5/site-packages/RuleDispatch-0.5a0.dev_r2306-py2.5-linux- 
i686.egg', '/usr/local/lib/python2.5/site-packages/FormEncode-0.7.1- 
py2.5.egg', '/usr/local/lib/python2.5/site-packages/ 
elementtree-1.2.7_20070827_preview-py2.5.egg', '/usr/local/lib/ 
python2.5/site-packages/simplejson-1.7.1-py2.5.egg', '/usr/local/lib/ 
python2.5/site-packages/CherryPy-2.2.1-py2.5.egg', '/usr/local/lib/ 
python2.5/site-packages/TurboKid-1.0.2-py2.5.egg', '/usr/local/lib/ 
python2.5/site-packages/TurboCheetah-0.9.5-py2.5.egg', '/usr/local/lib/ 
python2.5/site-packages/TurboJson-1.1-py2.5.egg', '/usr/local/lib/ 
python2.5/site-packages/PyProtocols-1.0a0dev_r2302-py2.5-linux- 
i686.egg', '/usr/local/lib/python2.5/site-packages/PasteDeploy-1.3.1- 
py2.5.egg', '/usr/local/lib/python2.5/site-packages/Paste-1.4- 
py2.5.egg', '/usr/local/lib/python2.5/site-packages/kid-0.9.6- 
py2.5.egg', '/usr/local/lib/python2.5/site-packages/docutils-0.4- 
py2.5.egg', '/usr/local/lib/python2.5/site-packages/setuptools-0.6c7- 
py2.5.egg', '/usr/local/lib/python2.5/site-packages/ 
SQLAlchemy-0.4.0beta7dev_r3551-py2.5.egg', '/usr/local/lib/python2.5/ 
site-packages/Pylons-0.9.6.1-py2.5.egg', '/usr/local/lib/python2.5/ 
site-packages/Mako-0.1.8-py2.5.egg', '/usr/local/lib/python2.5/site- 
packages/nose-0.10.0-py2.5.egg', '/usr/local/lib/python2.5/site- 
packages/decorator-2.2.0-py2.5.egg', '/usr/local/lib/python2.5/site- 
packages/PasteScript-1.3.6-py2.5.egg', '/usr/local/lib/python2.5/site- 
packages/Beaker-0.7.5-py2.5.egg', '/usr/local/lib/python2.5/site- 
packages/WebHelpers-0.3.2-py2.5.egg', '/usr/local/lib/python2.5/site- 
packages/Routes-1.7.1-py2.5.egg', '/usr/local/lib/python2.5/site- 
packages/Myghty-1.1-py2.5.egg', '/usr/local/lib/python25.zip', '/usr/ 
local/lib/python2.5', '/usr/local/lib/python2.5/plat-linux2', '/usr/ 
local/lib/python2.5/lib-tk', '/usr/local/lib/python2.5/lib-dynload', '/ 
usr/local/lib/python2.5/site-packages', '/usr/local/lib/python2.5/site- 
packages/killdjangokill', '/usr/local/lib/python2.5/site-packages/ 
mysite']

...which is no surprise, since the view is relying upon the logged-in  
user info, & I'm not getting redirected to the login page, so there's  
no user info to match.

Now, this is my first run at this, & frankly (& obviously, no doubt)  
I'm more than a bit baffled by the whole sessions framework business.   
Am I anywhere in the ballpark?  Any advice much appreciated!



--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to