# django\_manage module detailed explaination

**URL:** <https://forum.ansible.com/t/django-manage-module-detailed-explaination/17135>\
**Category:** Ansible Project\
**Created:** [December 23, 2014, 11:13am UTC](https://forum.ansible.com/t/django-manage-module-detailed-explaination/17135 "2014-12-23T11:13:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric\_sharma](https://avatars.discourse-cdn.com/v4/letter/e/5daacb/32.png) [@Eric\_sharma](https://forum.ansible.com/u/Eric_sharma)\
**Post date:** [December 23, 2014, 11:13am UTC](https://forum.ansible.com/t/django-manage-module-detailed-explaination/17135/1 "2014-12-23T11:13:37Z")

</div>

The module provide here  
[http://docs.ansible.com/django\_manage\_module.html](http://docs.ansible.com/django_manage_module.html)  
needs to have some more example for manage.py command.

example: createsuperuser. How can we create superuser with a specific username and password? is there any way to pass this information in this module

`

- name: Django Create Superuser

` `  
django\_manage: command=createsuperuser  
app\_path={{app\_path}}  
settings={{django\_settings}}  
tags:

- django

`

and how do we use latest django’(1.7)'s makemigration command where we have to give app name (I mean  
`python manage.py makemigration app1`  
)

for same environment/path settings collectstatic command works perfectly

`

- name: Django Collectstatic  
django\_manage: command=collectstatic  
app\_path={{app\_path}}  
settings={{django\_settings}}

`

Could somebody please provide example of these

Thanks

---

<div class="post-metadata">

**Author:** ![Chris\_Church1](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Church1](https://forum.ansible.com/u/Chris_Church1)\
**Post date:** [December 25, 2014, 5:25am UTC](https://forum.ansible.com/t/django-manage-module-detailed-explaination/17135/2 "2014-12-25T05:25:28Z")

</div>

The createsuperuser command doesn’t support a command line option to set a password; you can only set username and email when running with the --noinput flag. There are hackish workarounds for creating an initial superuser with password ([http://source.mihelac.org/2009/10/23/django-avoiding-typing-password-for-superuser/](http://source.mihelac.org/2009/10/23/django-avoiding-typing-password-for-superuser/)), but these wouldn’t use the django\_manage module. Your other option would be writing your own custom management command for creating superusers.

For running django management commands not specifically listed in the docs, or to use custom command options, you can specify your command and options as a single string, e.g.:

- django\_manage: command=“makemigrations --noinput app1” app\_path={{app\_path}} settings={{django\_settings}}

---

<div class="post-metadata">

**Author:** ![Eric\_sharma](https://avatars.discourse-cdn.com/v4/letter/e/5daacb/32.png) [@Eric\_sharma](https://forum.ansible.com/u/Eric_sharma)\
**Post date:** [December 25, 2014, 3:59pm UTC](https://forum.ansible.com/t/django-manage-module-detailed-explaination/17135/3 "2014-12-25T15:59:38Z")

</div>

Thanks Chris

Your solution for makemigrations command working perfect but I didn’t find similar thing in docs. have I missed something?  
I’ve two more small queries.

1. how do I pass multiple app name in makemigrations command which is in a variable (I mean using ansible’s **with\_items** )

`

- name: Django makemigrations  
django\_manage: command=“makemigrations --noinput app1” app\_path={{app\_path}} settings={{django\_settings}}

with\_items:

- app1
- app2
- app3

`

1. how do I pass username and password in createsuperuser command?  
I run this task but it didn’t work?

`

- django\_manage: command=“createsuperuser --noinput myuser [myemail@xyz.com](mailto:myemail@xyz.com) mypassword” app\_path={{app\_path}} settings={{django\_settings}}

`

Thanks again for **–input** thing 🙂

---

<div class="post-metadata">

**Author:** ![Chris\_Church1](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Church1](https://forum.ansible.com/u/Chris_Church1)\
**Post date:** [December 26, 2014, 6:33am UTC](https://forum.ansible.com/t/django-manage-module-detailed-explaination/17135/4 "2014-12-26T06:33:07Z")

</div>

To use with\_items, replace app1 in your command with the variable {{item}}:

- django\_manage: \>  
&nbsp;&nbsp;&nbsp;&nbsp;command="makemigrations --noinput {{item}}"  
&nbsp;&nbsp;&nbsp;&nbsp;app\_path={{app\_path}}  
&nbsp;&nbsp;&nbsp;&nbsp;settings={{django\_settings}}  
&nbsp;&nbsp;with\_items:  
&nbsp;&nbsp;&nbsp;&nbsp;- app1  
&nbsp;&nbsp;&nbsp;&nbsp;- app2  
&nbsp;&nbsp;&nbsp;&nbsp;- app3

The createsuperuser command doesn't support setting a password from the  
command line. I've found a simple third-party app (  
[https://github.com/ActiveState/django-stackato](https://github.com/ActiveState/django-stackato)) to add a management command  
for changing a user's password, so after installing it you could run  
something like:

- django\_manage: \>  
&nbsp;&nbsp;&nbsp;&nbsp;command="createsuperuser --noinput --username=myuser --email=  
myemail@xyz.com"  
&nbsp;&nbsp;&nbsp;&nbsp;app\_path={{app\_path}}  
&nbsp;&nbsp;&nbsp;&nbsp;settings={{django\_settings}}  
- django\_manage: \>  
&nbsp;&nbsp;&nbsp;&nbsp;command="changepassword2 myuser mypassword"  
&nbsp;&nbsp;&nbsp;&nbsp;app\_path={{app\_path}}  
&nbsp;&nbsp;&nbsp;&nbsp;settings={{django\_settings}}

The django\_manage documentation does indicate that "Other commands can be  
entered, but will fail if they're unknown to Django.", but it doesn't give  
an example of running one that's not in the list of built-in commands.  
I've submitted a fix (  
[https://github.com/ansible/ansible-modules-core/pull/574](https://github.com/ansible/ansible-modules-core/pull/574)).
