Ok I think I've honed my problem down a bit further and more concisely: So I'm trying to create an Info object that is attached to a League object, but I can't do this through the urlconf the way I have it now because create_object() does not take an object id as an argument. Somehow, I need to grab the League id number when a user clicks on a league they want to enter their info for so that the user only signs up for that one particular league. Is there a way to write a wrapper to the generic create_object view to do this or do I need to scrap generic views altogether in this instance and write my own view?
On Nov 8, 5:56 pm, Ross <[email protected]> wrote: > 'm new to Django and programming in general. I'm trying to make a > simple site that allows players of a sport sign up for leagues that > have been created by the admin. In my models.py, I created two models: > `from django.db import models from django.forms import ModelForm > > class League(models.Model): league_name = models.CharField > (max_length=100) pub_date = models.DateTimeField('date published') > > class Info(models.Model): league = models.ManyToManyField(League) name > = models.CharField(max_length=50) phone = models.IntegerField() email > = models.EmailField() def unicode(self): return self.info > > class InfoForm (ModelForm): class Meta: model = Info exclude = > ('league')` > > From what I've read, I can probably use the Create/Update/Delete > generic views to display a form for the user to sign up for the > league. So with my app, I want the user to come to a simple homepage > that lists the leagues, be able to click on the league and enter their > info to sign up. Here's what my urlconf looks like:`from > django.conf.urls.defaults import * from mysite.player_info.models > import League, Info, InfoForm > > info_dict = { 'queryset': League.objects.all(), } > > InfoForm = {'form_class' : InfoForm} > > urlpatterns = patterns('', (r'^$', > 'django.views.generic.list_detail.object_list', info_dict), (r'^(?P\d > +)/$', 'django.views.generic.list_detail.object_detail', info_dict), > url(r'^(?P\d+)/results/$', > 'django.views.generic.list_detail.object_detail', dict(info_dict, > template_name='player_info/results.html'), 'league_results'), (r'^(?P\d > +)/info/create/$', 'django.views.generic.create_update.create_object', > InfoForm), )` > > Here's my problem: When I click on a league to sign up for on the > homepage with my current setup, I get this error: TypeError at /league/ > 1/info/create.... create_object() got an unexpected keyword argument > 'object_id'. What am I doing wrong? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---

