Django: model.ForeignKey referring to field type -


i try build model, e.g. userprofile, in fields chosen in admin panel.

class userprofile(models.model):     user = models.onetoonefield(user)     regfield = models.foreignkey(regfields) 

this model refers second model regfields:

class regfields(models.model):     field_name = models.charfield(max_length = 256, unique=true, blank=false)     field_type = models.foreignkey(foreignkey_to_datatypes) 

i want choose fieldname , fieldtype (e.g. char_field ...) use in second model userprofile, refer field names , field types in regfields model. best approach realize this?

edit:

i don't seek have kind of dynamic database user profile. think achive using "static" choice list, e.g.:

field_type_choices = (     (bigintegerfield,'long int'),     (booleanfield,'boolean'),     (charfield,'char'),     ...     ) field_type = models.charfield(max_length=20, choices=field_type_choices, default=charfield) 

however, way can have required registration fields choosen given set, fieldtypes strings, in turn might lead complicated data validation.

example of try achive: in admin panel want admin have choice kind of data required (additionally username , password) @ registration page. admin might ask (username, password , email) might ask (username, password, email, first_name, last_name, company, department)

allowing users customize forms via forms not simple, , drag more non standard problems... how trying out ready made django package helps building forms?

https://www.djangopackages.com/grids/g/form-builder/


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -