custom User model and login()
I am trying to build a User model with a dedicated LDAP backend. I have no SQL database. def login(request): ... login(request, user) request.user.is_authenticated() ---> return True return HttpResponseRedirect("/manage") def manage(request): print request.user.is_authenticated()--> returns False Shouldn't the manage() show the user being authenticated? What exactly happens when I do a login() call? Does it store some sessions somewhere? If so, what can I do in my custom User model to make it save this session? Thanks, Anil -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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.
too much customization - ldap user model
I am trying to build a custom User model with a custom authentication backend (ldap). Here is what I've done so far: Custom LDAP authentication backend: class LDAPBackend: def get_user(self, user_id): try: return LDAPUser.objects.get(pk=user_id) except LDAPUser.DoesNotExist: return None def authenticate(self, dn=None, password=None): conn = DS(settings.AUTH_LDAP_SERVER) conn.connect(dn, password) try: user = LDAPUser.objects.get_or_create(dn=dn) return user except LDAPUser.DoesNotExist: pass return None = Custom User model: class LDAPUserManager(BaseUserManager): def get_or_create(self, dn): user = LDAPUser(dn) return user class LDAPUser(AbstractBaseUser): dn = models.CharField(max_length=128) is_active = models.BooleanField(default=True) is_admin = models.BooleanField(default=False) objects = LDAPUserManager() USERNAME_FIELD = 'dn' def __unicode__(self): return self.dn … = Based on that, in my view I have: def do_login(): user = authenticate(dn=dn, password=password) user.is_authenticated()<--- returns True return HttpResponseRedirect("/manage") def manage(): print request.session['dn'] print request.user Shouldn't the request.user in manage() be my LDAPUser instance? It shows AnonymousUser. Where is the session stored (if any) when I do the authenticate() ? Sorry for these basic questions, I am new to Django. Also, I feel like I am going to end up having to customize every aspects of the User model… am I going about this the wrong way? What I am really trying to do is create a LDAP based users as well as LDAP based database (no SQL database) for all my data. I looked at Django_auth_ldap, but that won't cut it, I need to have a little bit more customization on it (I think). Thanks for any help! Anil -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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.
Re: too much customization - ldap user model
Actually I did, see my last comment ;) On Nov 15, 2012, at 8:32 PM, Russell Keith-Magee wrote: > Hi Anil, > > Before you started developing your own, did you consider doing a quick google > search to see if there were any existing solutions that implemented LDAP > authentication for Django? > > http://packages.python.org/django-auth-ldap/ > > Yours, > Russ Magee %-) > > On Fri, Nov 16, 2012 at 12:23 PM, Anil Jangity wrote: >> I am trying to build a custom User model with a custom authentication >> backend (ldap). >> Here is what I've done so far: >> >> Custom LDAP authentication backend: >> >> class LDAPBackend: >> def get_user(self, user_id): >> try: >> return LDAPUser.objects.get(pk=user_id) >> except LDAPUser.DoesNotExist: >> return None >> >> >> def authenticate(self, dn=None, password=None): >> conn = DS(settings.AUTH_LDAP_SERVER) >> conn.connect(dn, password) >> try: >> user = LDAPUser.objects.get_or_create(dn=dn) >> return user >> except LDAPUser.DoesNotExist: >> pass >> return None >> >> = >> >> Custom User model: >> >> class LDAPUserManager(BaseUserManager): >> >> def get_or_create(self, dn): >> user = LDAPUser(dn) >> return user >> >> >> class LDAPUser(AbstractBaseUser): >> dn = models.CharField(max_length=128) >> >> is_active = models.BooleanField(default=True) >> is_admin = models.BooleanField(default=False) >> >> objects = LDAPUserManager() >> USERNAME_FIELD = 'dn' >> >> def __unicode__(self): >> return self.dn >> … >> >> >> >> = >> >> >> >> Based on that, in my view I have: >> def do_login(): >> user = authenticate(dn=dn, password=password) >> user.is_authenticated()<--- returns True >> return HttpResponseRedirect("/manage") >> >> def manage(): >> print request.session['dn'] >> print request.user >> >> >> Shouldn't the request.user in manage() be my LDAPUser instance? It shows >> AnonymousUser. Where is the session stored (if any) when I do the >> authenticate() ? >> Sorry for these basic questions, I am new to Django. >> >> Also, I feel like I am going to end up having to customize every aspects of >> the User model… am I going about this the wrong way? >> >> What I am really trying to do is create a LDAP based users as well as LDAP >> based database (no SQL database) for all my data. I looked at >> Django_auth_ldap, but that won't cut it, I need to have a little bit more >> customization on it (I think). >> >> Thanks for any help! >> Anil >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@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. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@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. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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.
Re: too much customization - ldap user model
So, the bottom line is, what do I need to do after I do a authenticate() to have the login persist in the session and in the other views? Thanks On Nov 15, 2012, at 8:23 PM, Anil Jangity wrote: > I am trying to build a custom User model with a custom authentication backend > (ldap). > Here is what I've done so far: > > Custom LDAP authentication backend: > > class LDAPBackend: >def get_user(self, user_id): >try: >return LDAPUser.objects.get(pk=user_id) >except LDAPUser.DoesNotExist: >return None > > >def authenticate(self, dn=None, password=None): > conn = DS(settings.AUTH_LDAP_SERVER) > conn.connect(dn, password) > try: >user = LDAPUser.objects.get_or_create(dn=dn) >return user >except LDAPUser.DoesNotExist: > pass > return None > > = > > Custom User model: > > class LDAPUserManager(BaseUserManager): > >def get_or_create(self, dn): >user = LDAPUser(dn) >return user > > > class LDAPUser(AbstractBaseUser): >dn = models.CharField(max_length=128) > >is_active = models.BooleanField(default=True) >is_admin = models.BooleanField(default=False) > >objects = LDAPUserManager() >USERNAME_FIELD = 'dn' > >def __unicode__(self): >return self.dn >… > > > > = > > > > Based on that, in my view I have: > def do_login(): > user = authenticate(dn=dn, password=password) > user.is_authenticated()<--- returns True > return HttpResponseRedirect("/manage") > > def manage(): >print request.session['dn'] >print request.user > > > Shouldn't the request.user in manage() be my LDAPUser instance? It shows > AnonymousUser. Where is the session stored (if any) when I do the > authenticate() ? > Sorry for these basic questions, I am new to Django. > > Also, I feel like I am going to end up having to customize every aspects of > the User model… am I going about this the wrong way? > > What I am really trying to do is create a LDAP based users as well as LDAP > based database (no SQL database) for all my data. I looked at > Django_auth_ldap, but that won't cut it, I need to have a little bit more > customization on it (I think). > > Thanks for any help! > Anil > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@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. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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.
custom signup form
New to Django. When I submit a signup form with this, the password is human readable in the database. It seems like it should be hashed? Looking at some Google pages, it seems I need to subclass UserCreationForm. I tried that instead of forms.ModelForm and now it complains my form doesn't have "password1" and "password2"; which is not what I want. I just want a single password field. Can someone give me pointers on how I should go about this? Thanks! Models: class User(models.Model): name = models.CharField(max_length=32) username = models.CharField(max_length=16, primary_key=True) mail = models.EmailField(max_length=254) password = models.CharField(max_length=64) status = models.CharField(max_length=32) create_tstamp = models.DateTimeField(auto_now_add=True) def __unicode__(self): user = "%s: %s, %s" % (self.username, self.mail, self.name) return user class SignupForm(forms.ModelForm): class Meta: model = User fields = ["username", "mail", "password"] View: def signup(request): if request.POST: form = SignupForm(request.POST) if form.is_valid(): newUser = form.save() return HttpResponseRedirect(reverse('dashboard')) else: form = SignupForm() return render(request, "registration/signup.html", {'form': form,}) I am using Bootstrap and here is my signup.html for reference: {% csrf_token %} Signup for Globexch account It's free. You can also Login. {% if form.username.errors %} {{ form.username.errors|join:", " }} {% endif %} {% if form.mail.errors %} {{ form.mail.errors|join:", " }} {% endif %} {% if form.password.errors %} {{ form.password.errors|join:", " }} {% endif %} Let me in -- 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 email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
Re: custom signup form
I tried that too earlier. I added these to the SignupForm class: def clean_password(self): password = self.cleaned_data.get("password") return password def save(self, commit=True): user = super(SignupForm, self).save(commit=False) user.set_password(self.cleaned_data["password"]) if commit: user.save() return user That throws this exception: AttributeError: 'User' object has no attribute 'set_password' On Sep 8, 2013, at 10:06 AM, Jonathan Baker wrote: > You need to run the password through the 'set_password' method of the User > class to hash it. See: > https://docs.djangoproject.com/en/1.0/topics/auth/#django.contrib.auth.models.User.set_password > > Hope this helps, > JDB > > > On Sun, Sep 8, 2013 at 11:02 AM, Anil Jangity wrote: > New to Django. > When I submit a signup form with this, the password is human readable in the > database. It seems like it should be hashed? > Looking at some Google pages, it seems I need to subclass UserCreationForm. > > I tried that instead of forms.ModelForm and now it complains my form doesn't > have "password1" and "password2"; which is not what I want. I just want a > single password field. > > Can someone give me pointers on how I should go about this? > > Thanks! > > > Models: > class User(models.Model): > name = models.CharField(max_length=32) > username = models.CharField(max_length=16, primary_key=True) > mail = models.EmailField(max_length=254) > password = models.CharField(max_length=64) > status = models.CharField(max_length=32) > create_tstamp = models.DateTimeField(auto_now_add=True) > > def __unicode__(self): > user = "%s: %s, %s" % (self.username, self.mail, self.name) > return user > > class SignupForm(forms.ModelForm): > class Meta: > model = User > fields = ["username", "mail", "password"] > > > View: > def signup(request): > if request.POST: > form = SignupForm(request.POST) > if form.is_valid(): > newUser = form.save() > return HttpResponseRedirect(reverse('dashboard')) > else: > form = SignupForm() > return render(request, "registration/signup.html", {'form': form,}) > > > I am using Bootstrap and here is my signup.html for reference: > > > {% csrf_token %} > Signup for Globexch account > It's free. You can also Login. > > {% if form.username.errors %} > {{ form.username.errors|join:", " > }} > {% endif %} > form.username.value %}value="{{ form.username.value }}" {% endif %} > class="input-block-level" placeholder="Login name"> > > > {% if form.mail.errors %} > {{ form.mail.errors|join:", " }} > {% endif %} > %}value="{{ form.mail.value }}" {% endif %} class="input-block-level" > placeholder="u...@example.com"> > > > {% if form.password.errors %} > {{ form.password.errors|join:", " > }} > {% endif %} > class="input-block-level" placeholder="Password"> > > Let me > in > > > > -- > 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 > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > For more options, visit https://groups.google.com/groups/opt_out. > > > > -- > Jonathan D. Baker > Developer > http://jonathandbaker.com > > -- > 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 > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > For more options, visit https://groups.google.com/groups/opt_out. -- 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 email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
Re: custom signup form
class SignupForm(forms.ModelForm): class Meta: model = User fields = ["username", "mail", "password"] def clean_password(self): password = self.cleaned_data.get("password") return password def save(self, commit=True): user = super(SignupForm, self).save(commit=False) print user, type(user) user.set_password(self.cleaned_data["password"]) if commit: user.save() return user I copied this from some other site. On Sep 8, 2013, at 10:39 AM, Jonathan Baker wrote: > Can you post your entire SignupForm class? I think a bit more context will > help me diagnose. > > > On Sun, Sep 8, 2013 at 11:27 AM, Anil Jangity wrote: > I tried that too earlier. > > I added these to the SignupForm class: > > def clean_password(self): > password = self.cleaned_data.get("password") > return password > > def save(self, commit=True): > user = super(SignupForm, self).save(commit=False) > user.set_password(self.cleaned_data["password"]) > if commit: > user.save() > return user > > That throws this exception: > AttributeError: 'User' object has no attribute 'set_password' > > > On Sep 8, 2013, at 10:06 AM, Jonathan Baker > wrote: > >> You need to run the password through the 'set_password' method of the User >> class to hash it. See: >> https://docs.djangoproject.com/en/1.0/topics/auth/#django.contrib.auth.models.User.set_password >> >> Hope this helps, >> JDB >> >> >> On Sun, Sep 8, 2013 at 11:02 AM, Anil Jangity wrote: >> New to Django. >> When I submit a signup form with this, the password is human readable in the >> database. It seems like it should be hashed? >> Looking at some Google pages, it seems I need to subclass UserCreationForm. >> >> I tried that instead of forms.ModelForm and now it complains my form doesn't >> have "password1" and "password2"; which is not what I want. I just want a >> single password field. >> >> Can someone give me pointers on how I should go about this? >> >> Thanks! >> >> >> Models: >> class User(models.Model): >> name = models.CharField(max_length=32) >> username = models.CharField(max_length=16, primary_key=True) >> mail = models.EmailField(max_length=254) >> password = models.CharField(max_length=64) >> status = models.CharField(max_length=32) >> create_tstamp = models.DateTimeField(auto_now_add=True) >> >> def __unicode__(self): >> user = "%s: %s, %s" % (self.username, self.mail, self.name) >> return user >> >> class SignupForm(forms.ModelForm): >> class Meta: >> model = User >> fields = ["username", "mail", "password"] >> >> >> View: >> def signup(request): >> if request.POST: >> form = SignupForm(request.POST) >> if form.is_valid(): >> newUser = form.save() >> return HttpResponseRedirect(reverse('dashboard')) >> else: >> form = SignupForm() >> return render(request, "registration/signup.html", {'form': form,}) >> >> >> I am using Bootstrap and here is my signup.html for reference: >> >> >> {% csrf_token %} >> Signup for Globexch account >> It's free. You can also Login. >> >> {% if form.username.errors %} >> {{ form.username.errors|join:", " >> }} >> {% endif %} >> > form.username.value %}value="{{ form.username.value }}" {% endif %} >> class="input-block-level" placeholder="Login name"> >> >> >> {% if form.mail.errors %} >> {{ form.mail.errors|join:", " }} >> {% endif %} >> > %}value="{{ form.mail.value }}" {% endif %} class="input-block-level" >> placeholder="u...@example.com"> >> >> >> {% if form.password.errors %} >> {{ form.password.errors|join:", " >> }} >> {% endif %} >> > class="input-block-level" placeholder="Password"> >> >> Let me >> in >> >> >> >> -- >>
Re: custom signup form
No, I am not using the custom user model, but it seems like I should be? (even though, I don't think I am changing anything that requires this). I still have user name as the authenticator. When I subclass UserCreationForm, it was complaining about not having password1 and 2 not in my form. On Sep 8, 2013, at 10:52 AM, Jonathan Baker wrote: > Are you using a custom User model? Your code is very similar to the > UserCreationForm django.contrib.auth.forms, and you might want to consider at > least subclassing it so you can make use of some of its features (like > clean_username). > > > On Sun, Sep 8, 2013 at 11:41 AM, Anil Jangity wrote: > class SignupForm(forms.ModelForm): > class Meta: > model = User > fields = ["username", "mail", "password"] > > def clean_password(self): > password = self.cleaned_data.get("password") > return password > > def save(self, commit=True): > user = super(SignupForm, self).save(commit=False) > print user, type(user) > user.set_password(self.cleaned_data["password"]) > if commit: > user.save() > return user > > I copied this from some other site. > > On Sep 8, 2013, at 10:39 AM, Jonathan Baker > wrote: > >> Can you post your entire SignupForm class? I think a bit more context will >> help me diagnose. >> >> >> On Sun, Sep 8, 2013 at 11:27 AM, Anil Jangity wrote: >> I tried that too earlier. >> >> I added these to the SignupForm class: >> >> def clean_password(self): >> password = self.cleaned_data.get("password") >> return password >> >> def save(self, commit=True): >> user = super(SignupForm, self).save(commit=False) >> user.set_password(self.cleaned_data["password"]) >> if commit: >> user.save() >> return user >> >> That throws this exception: >> AttributeError: 'User' object has no attribute 'set_password' >> >> >> On Sep 8, 2013, at 10:06 AM, Jonathan Baker >> wrote: >> >>> You need to run the password through the 'set_password' method of the User >>> class to hash it. See: >>> https://docs.djangoproject.com/en/1.0/topics/auth/#django.contrib.auth.models.User.set_password >>> >>> Hope this helps, >>> JDB >>> >>> >>> On Sun, Sep 8, 2013 at 11:02 AM, Anil Jangity wrote: >>> New to Django. >>> When I submit a signup form with this, the password is human readable in >>> the database. It seems like it should be hashed? >>> Looking at some Google pages, it seems I need to subclass UserCreationForm. >>> >>> I tried that instead of forms.ModelForm and now it complains my form >>> doesn't have "password1" and "password2"; which is not what I want. I just >>> want a single password field. >>> >>> Can someone give me pointers on how I should go about this? >>> >>> Thanks! >>> >>> >>> Models: >>> class User(models.Model): >>> name = models.CharField(max_length=32) >>> username = models.CharField(max_length=16, primary_key=True) >>> mail = models.EmailField(max_length=254) >>> password = models.CharField(max_length=64) >>> status = models.CharField(max_length=32) >>> create_tstamp = models.DateTimeField(auto_now_add=True) >>> >>> def __unicode__(self): >>> user = "%s: %s, %s" % (self.username, self.mail, self.name) >>> return user >>> >>> class SignupForm(forms.ModelForm): >>> class Meta: >>> model = User >>> fields = ["username", "mail", "password"] >>> >>> >>> View: >>> def signup(request): >>> if request.POST: >>> form = SignupForm(request.POST) >>> if form.is_valid(): >>> newUser = form.save() >>> return HttpResponseRedirect(reverse('dashboard')) >>> else: >>> form = SignupForm() >>> return render(request, "registration/signup.html", {'form': form,}) >>> >>> >>> I am using Bootstrap and here is my signup.html for reference: >>> >>> >>> {% csrf_token %} >>>
updating site domain with data migration
I wanted to update the site domain/name using data migrations in Django 1.7: $ python manage.py makemigrations main Migrations for 'main': 0001_currencies_locations_posts_userprofile.py: - Create model Currencies - Create model Locations - Create model Posts - Create model UserProfile $ $ python manage.py syncdb Operations to perform: Synchronize unmigrated apps: allauth, account, socialaccount Apply all migrations: sessions, admin, auth, sites, contenttypes, main Synchronizing apps without migrations: Creating tables... Creating table account_emailaddress Creating table account_emailconfirmation Creating table socialaccount_socialapp_sites Creating table socialaccount_socialapp Creating table socialaccount_socialaccount Creating table socialaccount_socialtoken Installing custom SQL... Installing indexes... Running migrations: Applying contenttypes.0001_initial... OK Applying auth.0001_initial... OK Applying admin.0001_initial... OK Applying main.update_site...Traceback (most recent call last): File "/Users/ajangity/Dev/lib/python3.4/site-packages/django/contrib/sites/models.py", line 52, in get_current current_site = SITE_CACHE[sid] KeyError: 1 ... sqlite3.OperationalError: no such table: django_site I have a main/migration/update_site.py: def update_site(apps, schema_editor): current_site = Site.objects.get_current() current_site.domain = "example.com" current_site.name = "Example" current_site.save() class Migration(migrations.Migration): operations = [ migrations.RunPython(update_site), ] Doing a syncdb throws this error. It's probably because the "Site" hasn't been created by the time I am trying to update it. So, the question is, how do I programmatically update the Site info? Thanks -- 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 email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/EC345DAE-1F0E-40A8-B8DE-4F0109636F88%40me.com. For more options, visit https://groups.google.com/d/optout.
Re: updating site domain with data migration
Thanks, looks like I need to do a second pass at the documentation. ;-) In my dev environment, I was trying to do a clean/fresh install; including the creation of the super user account. If I don't use syncdb, I should also create the super user account using data migration? If so, it seems like I need to go do User.objects.create_superuser(). Thanks! On Sep 21, 2014, at 6:55 PM, Markus Holtermann wrote: > Hey Anil, > > On Sun, Sep 21, 2014 at 05:29:18PM -0700, Anil Jangity wrote: >> $ python manage.py syncdb > > Just as a side note: "syncdb" is deprecated and is being replaced by > "migrate". > >> >> I have a main/migration/update_site.py: >> def update_site(apps, schema_editor): >> current_site = Site.objects.get_current() >> current_site.domain = "example.com" >> current_site.name = "Example" >> current_site.save() >> >> >> class Migration(migrations.Migration): >> >> operations = [ >> migrations.RunPython(update_site), >> ] > > > You are missing a dependency to the sites app in your migration as well > as to the previous migration in the "main" app. Have a look at > https://docs.djangoproject.com/en/1.7/topics/migrations/#dependencies > > Adding > > dependencies = [ > ("main", "whatever_the_name_of_the_previous_migration_is"), > ("sites", "0001_initial"), > ] > > should work. > > I tried to explain the way dependencies in Django's new migration > framework work in a blog post: > https://markusholtermann.eu/2014/09/django-17-database-migrations-done-right/#how-do-dependencies-between-migrations-work > Might be interesting. > > /Markus -- 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 email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/538B6FC0-500E-4E2D-A3E6-295FBABAEBCF%40me.com. For more options, visit https://groups.google.com/d/optout.
Re: updating site domain with data migration
Markus, one specific question re your blog post. "What happens when you call python manage.py makemigrations? First of all, since no apps are given, Django reads the migrations from all apps listed in INSTALLED_APPS. In our case, this is ('author', 'book',). " I have the following in INSTALLED_APPS: In [2]: apps.get_app_configs() Out[2]: ValuesView(OrderedDict([('admin', ), ('auth', ), ('contenttypes', ), ('sessions', ), ('messages', ), ('staticfiles', ), ('sites', ), ('allauth', ), ('account', ), ('socialaccount', ), ('main', )])) But it seems it doesn't see my "main" app. Your note seems to indicate that it will 'make migrations' for INSTALLED_APPS. $ python manage.py migrate --list admin [ ] 0001_initial auth [ ] 0001_initial contenttypes [ ] 0001_initial sessions [ ] 0001_initial sites [ ] 0001_initial socialaccount (no migrations) I have to explicitly run with 'main' app. Just wondering if I am missing something in my config. $ python manage.py makemigrations main Migrations for 'main': 0001_initial.py: - Create model Currencies - Create model Locations - Create model Posts - Create model UserProfile On Sep 22, 2014, at 9:16 AM, Markus Holtermann wrote: > On Mon, Sep 22, 2014 at 08:41:36AM -0700, Anil Jangity wrote: >> If I don't use syncdb, I should also create the super user account >> using data migration? If so, it seems like I need to go do >> User.objects.create_superuser(). > > There still is the option of running "python manage.py createsuperuser" > after the migrations are applied. If I don't need a superuser account > during the migration, this would be my way of doing it. > > /Markus -- 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 email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/C9A4828C-8B10-4300-9BA0-7AB768BDF39D%40me.com. For more options, visit https://groups.google.com/d/optout.
multi org and user site
I would like to create a web site that will have multiple organizations with it's own set of user accounts. Something like a "reseller" account. e.g. Org1 user1, user2, user3 Org2 user1, userA, userB Each Org would have it's own billing, user info. Does anyone have any sample demo code that does something like this? If not, what are some suggestions on how I should go about doing this? The default User model in Django won't work clearly. I think in the newer Django versions we can create custom User models, but it seems then we would have to do a lot of custom modules to make it work (?). Thanks for the feedback! -- 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 email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2A0C86B3-7CB0-42D9-A570-F10FF8E20835%40me.com. For more options, visit https://groups.google.com/d/optout.