0

I have followed various tutorials and solutions on how to add additional fields to django-registration module. Some of them did the trick, but after I synced the database, data is not saved. Here are my files:

models.py

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

# Create your models here.

class Organization(models.Model):
    #user = models.ForeignKey(User, unique=True)
    name = models.CharField(max_length=100, null=True, unique=True)

forms.py

from registration.forms import RegistrationForm
from django import forms
from drugisok.models import Organization

class OrganizationForm(forms.ModelForm):
    class Meta:
        model = Organization


RegistrationForm.base_fields.update(OrganizationForm.base_fields)

class CustomRegistrationForm(RegistrationForm):
    def save(self, profile_callback=None):
        user = super(CustomRegistrationForm, self).save(profile_callback=None)
        org, c = Organization.objects.get_or_create(user=user, name=self.cleaned_data['name'])

There is a table in the database with name drugisok_organization which corresponds to the model created. In that table there is a column named name which also corresponds to the model. HTML form itself shows one additional text input for name, but name is not saved when the form is submitted.

ivica
  • 1,388
  • 1
  • 22
  • 38
  • what do you mean by data is not saved? Are those fields created in the database? – karthikr Mar 06 '13 at 18:19
  • Yes, the fields are created. However, I've found out that it's better to use dmitko's approach explained [here](http://dmitko.ru/django-registration-form-custom-field/). Sadly, it also gives me strange errors, so my next question is about that. – ivica Mar 06 '13 at 20:44

0 Answers0