Django-nonrel cannot login into the admin interface - django

I have a Django app which I am trying to get to Django-nonrel so that I can get it on GAE. The problem though is that numerous times have I tried creating superuser for the admin interface still when I do syncdb, it shows me:
You just installed Django's auth system, which means you don't have
any superusers defined.
everytime.Also, I am never able to login into my admin interface by the created superuser. Also, when I do this:
python manage.py shell
>>> from django.contrib.auth.models import User
>>> User.objects.all()
[]
SO no users are created it seems. I tried to look for the solution and and had a look at a few questions like these:
django-nonrel and the admin page
and a few others. Didn't help either. I would like to mention that I am using zip downloaded version of django-nonrel 1.6 and djangoappengine by copying them in my project directory
I also tried creating a user by the python manage.py shell and granting it is_staff= True.
The user is now being shown in the User.objects.all() but I cannot still not login by this user.

Related

Django Admin does not work after deployment Heroku

After deploying my application the admin of the website does not work. I am able to use the website, create an account and do all the crud, but the admin does not work.
1 - I created the superuser with
python manage.py createsuperuser
2 - I deployed and tried to access the admin
https://djangotodowoo.herokuapp.com/admin
Although, every time that I try to access this page it redirects to:
https://djangotodowoo.herokuapp.com/admin/login/?next=/admin/
I am not sure if that's the problem, but it's a hint at least.
This is happening because I have on my settings.py the following line
LOGIN_URL = '/login'
That checks if someone is trying to access a page without login and redirects to the login page.
I am not sure what the problem actually is, any ideas on how to solve the issue?
Thank you very much folks!
I found out that everything was working locally, the reason I was not able to log into the admin with my admin account is that I have to create a superuser on the Heroku side as well.
The solution was:
Create Heroku Super User
heroku run python manage.py createsuperuser

Creating users in django (NOT NULL constraint failed: auth_user.last_login)

I'm coding a web app with django and now I'm starting to handle users.
I'm trying to do the easy part, just create a new user throught admin interface, but when I try to do it I get a error and I don't find any info about it.
I enter django admin, log in with superuser, go to users, add user.
It only asks for: username and password.
When I submit changes then I get a NOT NULL constraint failed, this:
NOT NULL constraint failed: auth_user.last_login
I revised django documentation, and there it says to create a user like this:
from django.contrib.auth.models import User
user = User.objects.create_user('john', 'lennon#thebeatles.com', 'johnpassword')
So, I open a terminal, and do "./manage.py shell" "import django" "import User" and then I try this code, but fails too, it says:
NameError: name 'User' is not defined
Maybe I've changed something in the first part of the project? I've created models, templates, urls and used /static/ for references to files.
Thanks for your help!
last_login field changed in django 1.8. Just run the migrations
python manage.py migrate
Same issue, Had to run python manage.py migrate --fake and then python manage.py migrate and it worked perfectly.
In the app folder there is migration folder.. remove all files from it just keep pycache folder and init.py
then execute python manage.py migrate and then python manage.py makemigrations ..
simply we are removing the older migrations and migrating them again

Creating additional Superuser in Django 1.6

Is it possible to create more than one superusers in Django? When I create a new django app it automatically asks for creating a superuser. But I don't know how I can create more than one superuser to give admin access to other people ?
Use this command:
python manage.py createsuperuser
More: https://docs.djangoproject.com/en/dev/ref/django-admin/#createsuperuser

What is my user and pass? Deploy django on AWS EC2 but can not login admin

I've followed this youtube instruction from amazon to deploy django web app to AWS EB EC2. The website successfully ran. But I can not login to admin. The admin that came with django polls example. I recall that during the setup process, it prompt me for RDS setup and since my web app use MySQL, I had to pick RDS setup. When I setup the RDS, it did not prompt me to create a user, but only prompted me to create a password, which dutifully I did.
https://www.youtube.com/watch?v=YJoOnKiSYws
Similar instructions can be found on AWS, too.
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Python_django.html
I've tried username 'root' and password is 'blank' which works on my local pc, but of course that would make things too simple.
After that attempt failed, I did some searching in EC2 and RDS dashboard on AWS, and I found username=ebroot.
So I tried username 'ebroot' and password [rds_password_from_setup], but that didn't work.
I've tried many other combinations of usernames and passwords but nothing works. This might be a stupid question to ask the online community, but what do you suppose is my username and password that RDS might accept?
In order to create an admin user for my Django app on Beanstalk I created a custom Django command that I invoke in containers_commands, so there is no need for human input at all! Moreover I defined the user/password as environment variables so I can put my code under version control safely. The implementation of my command is something similar to this:
import os
from django.core.management.base import BaseCommand
from com.cygora.apps.users.models.User import User
class Command(BaseCommand):
def handle(self, *args, **options):
username = os.environ['SUPER_USER_NAME']
if not User.objects.filter(username=username).exists():
User.objects.create_superuser(username,
os.environ['SUPER_USER_EMAIL'],
os.environ['SUPER_USER_PASSWORD'])
then in my beanstalk config:
container_commands:
02_create_superuser_for_django_admin:
command: "python manage.py create_cygora_superuser"
leader_only: true
ps: if you never created a custom Django commands before, all you have to to is to create a package: management.commands in your desired app (ie: /your_project/your_app/management/commands/the_command.py), Django will load it automatically (and you can see it when typing python manage.py --help)

django: cannot import settings, cannot login to admin, cannot change admin password

It seems that I am completely lost here. Yesterday I noticed that I cannot login to the admin panel (don't use it much, so it's been some weeks since last login). I thought that I might have changed the admin password and now I can't remember it (though I doubt it).
I tried django-admin.py changepassword (using django 1.2.1) but it said that 'changepassword' is unknown command (I have all the necessary imports in my settings.py. Admin interface used to work ok).
Then I gave a django-admin.py validate. Then the hell begun. django-admin.py validate gave me this error: Error: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
I then gave a set DJANGO_SETTINGS_MODULE=myproject.settings
and then again a django-admin.py validate
This is what I get now: Error: Could not import settings 'myproject.settings' (Is it on sys.path? Does it have syntax errors?): No module named myproject.settings
and now I am lost. I tried django console and sys.path.append('c:\workspace') or sys.append('c:\workspace\myproject') but still get the same errors.
I use windows 7 and my project dir is c:\workspace. I don't use a PYTHONPATH variable (although I tried setting it temporarily to C:\workspace but I still get the same error). I don't use Apache, just the django development server.
What am I doing wrong? My web page works fine. I think that the fact that I can't login as admin is related to the previous import error, no?
PS: I also tried this: http://coderseye.com/2007/howto-reset-the-admin-password-in-django.html but still I couldn't change admin password for some reason. Although I could create another admin user (with which I couldn't login).
-EDIT- I forgot to mention that I use postgresql.
django-admin.py doesnot have changepassword option;
python manage.py does