Re: Using data migration to create initial users errors

2017-09-09 Thread James Schneider
On Sep 7, 2017 10:36 AM, "Tim Huang" wrote: Hi Melvyn, I am lack of knowledge how to use model manager. Would you mind give a quick example? Thanks - timh There's a fairly substantial doc page for model managers:

Re: Using data migration to create initial users errors

2017-09-07 Thread Tim Huang
> > Hi Melvyn, I am lack of knowledge how to use model manager. Would you mind give a quick example? Thanks - timh -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an

Re: Using data migration to create initial users errors

2017-09-05 Thread Melvyn Sopacua
This is an old thread about 1.7. Things have improved since then: https://docs.djangoproject.com/en/1.11/topics/migrations/#model-managers On Wed, Sep 6, 2017 at 4:01 AM, Tim Huang wrote: > My instinct tells me that there may be something wrong with the classmethod >

Re: Using data migration to create initial users errors

2017-09-05 Thread Tim Huang
My instinct tells me that there may be something wrong with the classmethod normalize_username in _create_user method. What Matias suggested works. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop

Re: Using data migration to create initial users errors

2015-02-21 Thread Matías Iturburu
Hey Ben. The only gotcha I had is that the password needs to be hashed. I ended up doing this to create a superuser: from django.db import migrations from django.contrib.auth.hashers import make_password def create_admin_user(apps, schema_editor): User = apps.get_registered_model('auth',

Re: Using data migration to create initial users errors

2014-11-28 Thread Markus Holtermann
Hey all together, unfortunately there isn't a way to add users through their manager in RunPython yet. The only solution I can see so far, is doing it manually, e.g. doing what your `create_user` method does inside RunPython. There is a patch though #23822 [1] that needs some tests and docs,

Re: Using data migration to create initial users errors

2014-11-28 Thread Guillaume Cisco
Did you find a way to use method create_user in a data migration? I can't see a way to import the manager for using it. Le jeudi 16 octobre 2014 23:19:43 UTC+2, Collin Anderson a écrit : > > Hi Ben, > > Yes, the custom manager objects are not available within migrations. I bet > you might be

Re: Using data migration to create initial users errors

2014-10-16 Thread Collin Anderson
Hi Ben, Yes, the custom manager objects are not available within migrations. I bet you might be able to import the UserManager and stick it on the User model yourself. Collin -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe

Using data migration to create initial users errors

2014-10-14 Thread BenW
I am trying to create initial users in Django 1.7 via a simple data migration like so: # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.conf import settings from django.contrib.auth import get_user_model from django.db import models, migrations def