Comments (8)
@raushanraj did you run python manage.py migrate (for Django 1.7) or python manage.py syncdb and then python manage.py migrate (for Django 1.6)?
from cookiecutter-django.
@benregn yes,I run python manage.py migrate.nothing to migrate now.
from cookiecutter-django.
I follow step by step from documentation.Every thing is working fine.User Login,User Regestration.But When Admin add user it throws error mentioned aboved.I tried two times the documentation but is not working
from cookiecutter-django.
https://code.djangoproject.com/ticket/19353 please see this issue.some problem in users admin.py .
from cookiecutter-django.
I ran into the same trouble. With the help of this blog post, I managed to fix it. My admin.py looks now like this:
# -*- coding: utf-8 -*-
from django.contrib import admin
from django import forms
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from django.contrib.auth.admin import UserAdmin as AuthUserAdmin
from .models import User
class MyUserCreationForm(UserCreationForm):
def clean_username(self):
username = self.cleaned_data["username"]
try:
User._default_manager.get(username=username)
except User.DoesNotExist:
return username
raise forms.ValidationError(self.error_messages['duplicate_username'])
class Meta(UserCreationForm.Meta):
model = User
class UserAdmin(AuthUserAdmin):
add_form = MyUserCreationForm
update_form_class = UserChangeForm
admin.site.register(User, UserAdmin)
from cookiecutter-django.
thanks!
from cookiecutter-django.
I had the same issue with a Django project.
I created the superuser through manage.py createsuperuser
which worked out fine, but when I tried to log in via the web interface, I got the described error.
The reason was that I was using production settings when I ran the server, but development settings when using manage.py
. So the superuser was created to the development Sqlite database, while the server tried to access the production Postgres database where no migrations had been performed yet.
In case anybody runs into the same issue:
- use
manage.py the_command --settings the.real.settings
- or set the
DJANGO_SETTINGS_MODULE
to hold the right settings.
from cookiecutter-django.
I encountered the same errors as described in this post, but in my case, the issue was that I was using from django.contrib.auth.models import User
instead of from django.contrib.auth import get_user_model
. After some investigation, I realized that the cause of the error was related to my custom User model, which I had created by subclassing AbstractUser
. Once I made the change to use get_user_model()
, the errors were resolved.
from cookiecutter-django.
Related Issues (20)
- Waiting for postgres to become available.. HOT 1
- VSCode extensions are deprecated HOT 6
- mounting /tmp in devcontainer.json not required? HOT 2
- Implement django-allauth's MFA HOT 4
- pre-commit hook id: check-json FAILING on '//' commented out lines devcontainer.json HOT 7
- TypeError: unsupported operand type(s) for |: 'type' and 'NoneType' HOT 2
- Use docker compose watch instead of volumes HOT 1
- error
- [Update Django] Django 5.0 HOT 3
- Sentry is not creating issues HOT 4
- Github Actions Pre Commit Failed HOT 1
- Upgrade debian to 12 bookworm HOT 1
- Prettier Pre-Commit always return failed HOT 5
- Add a citation file HOT 6
- unregistered task of type 'users.tasks.get_users_count' in celery
- Admin login as non-superuser avoids allauth login flow HOT 6
- Add Hadolint
- python: can't open file '/app/manage.py': [Errno 2] No such file or directory
- `DJANGO_ADMIN_FORCE_ALLAUTH` is not covered by tests
- Line length of 88 chars HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cookiecutter-django.