On Nov 3, 4:17 pm, Thomas M <tome2...@googlemail.com> wrote: > Hi, > > I have to save a model with dynamic fieldnames. So the field > identifiers are strings. > > Example: > foo = Genre("genre_id"=2,"name"="ente") > foo.save() > > This creates an error. Is it somehow possible to do this with the > model instance? > Or do I have to use custom SQL? > > Thanks, Thomas
This is invalid Python. You can't use strings as parameter names. What you can do is use a dictionary: values = {genre_id": 2, "name": "ente"} foo = Genre(**values) -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.