Login

Tag "object-creation"

Snippet List

create_model_instances management command

This management command is run like this: `./manage.py -a someapp filename.cfg` it looks in `someapp`'s directory for a file called `/config/filename.cfg` with the format explained in the help text, and creates the model instances described in the config file. It uses the configobj module. this would be an example config file: [project.Profile] [[fields]] receive_notifications = False [[children]] [[[auth.User]]] [[[[fields]]]] username = AnnonymousUser password = ! # set unusable password. There's no way yet to hash and set a given password email = [email protected]

  • model
  • instance
  • object-creation
  • config-file
Read More

Create multiple related objects at once

The following code takes two related models and creates one user interface to for create and update operations that handles them both. It enables the creation or update of instances from both models in one shot, without having to create very complex forms. As I could not find examples for creation of related objects together, I thought this might be useful for someone.

  • forms
  • object-creation
  • related-objects
Read More

2 snippets posted so far.