Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

documentation on registering the User model

See original GitHub issue

This is more of a suggestion: I am using Userena with actstream, and I am not at all sure if I did this right to register the User model.

class StubsConfig(AppConfig):
    name = 'stubs'

    def ready(self):
        from django.contrib.auth.models import User

Either way it would be nice to mention in the docs the right way to register the user model.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:7
  • Comments:18 (1 by maintainers)

github_iconTop GitHub Comments

todorvelichkovcommented, Jul 14, 2015

Actually I migrated my models registration into a separate app like end0. Now my code looks like:

from actstream import registry
from django.apps import AppConfig
from django.apps import apps as django_apps

class StreamsConfig(AppConfig):
    name = 'myproject.streams'

    def ready(self):
        registry.register(django_apps.get_model('core', 'UserProfile'))
        registry.register(django_apps.get_model('anotherapp', 'AnotherModel'))
end0commented, Jan 11, 2015

Not sure for <1.7, but for 1.7, if you want to register models outside of the current app, you can do the following. For my use case, I created a wholely separate “activity” app which points to both the User model and the models on which I want actions. According to the Applications docs you can call up any registered app by using the app_label.model syntax. This is a minor difference from the current docs, which use self.get_model() to register apps. That works, but is limited only to the models in the current application.

from django.apps import AppConfig, apps
from actstream import registry

class ActivityConfig(AppConfig):
    name = 'activity'

    def ready(self):
        registry.register(apps.get_model('auth.user')) #registers the User (assuming you're using auth.User)
        registry.register(apps.get_model('')) #registers the other apps
Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom user models — django-registration 3.3 documentation
In general, django-registration will work with a custom user model, though at least some additional configuration is always required in order to do...
Read more >
Registering users | LoopBack Documentation
The built-in User model provides methods to register new users and confirm their email addresses. Page Contents. Registering users with the LoopBack User...
Read more >
Building a User Registration Form with Django's ...
Django's UserCreationForm​​ The doc on authentication in Django mentions that it is "a ModelForm for creating a new user." It comes with three ......
Read more >
A Guide to User Registration, Login, and Logout in Django
This article will cover how to allow user registration, login, and logout functionality on a site built using the Django Web Framework.
Read more >
Enabling user registration - Xperience 13 Documentation
Create a view for the Register action and display an appropriate registration form. We recommend using a strongly typed view based on your ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found