Opened 16 years ago
Closed 16 years ago
#12316 closed (invalid)
GenericForeignKey produces an error when submitting from a form
| Reported by: | Daniel Gonzalez Gasull | Owned by: | nobody |
|---|---|---|---|
| Component: | Uncategorized | Version: | 1.1-beta |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I apologize for not making a better report, but I cannot afford the time right now to write the minimum amount of code to reproduce this.
Snippet from my models.py:
class Subscription(models.Model):
user = models.OneToOneField(User, primary_key=True)
promotion = models.ForeignKey(Promotion)
start_date = models.DateTimeField(auto_now_add=True)
# Foreign key to AuthorizeNetSubscription u other model
payment_gateway_subscription = generic.GenericForeignKey()
is_active = models.BooleanField(default=True)
class AuthorizeNetSubscription(models.Model):
subscription_id = models.CharField('subscriptionId in the ARB API call return',
max_length=16, primary_key=True)
Snippet from my forms.py:
authorize_net_subscription = AuthorizeNetSubscription(
subscription_id=result_dict.subscription_id.text_)
user = User.objects.create_user(
username = form_list[1].cleaned_data['display_name'],
email=email,
password=password,
)
subscription = Subscription(
user=user,
promotion=promotion,
start_date=start_date,
payment_gateway_subscription=authorize_net_subscription
)
It fails in the line that creates the Subscription instance with a TypeError exception "'object_id' is an invalid keyword argument for this function" coming from line 320 in django/db/models/base.py
Note:
See TracTickets
for help on using tickets.
You appear to have skipped steps 1 and 2 listed here: http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#id1
Step 3 alone is not all you need in your model to have a working GenericForeignKey, you need to include 1 and 2 as well.