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:
https://docs.djangoproject.com/en/1.11/topics/db/managers/
-James
--
You re
>
> 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 em
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
> normalize_username in _create
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 recei
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',
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, bu
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 able
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 fro
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 populate_initial_d
9 matches
Mail list logo