I've got some code (using Python 3.4, Django 1.7, and PostgreSQL) that I pushed to Heroku. Everything worked fine until I added a login. Just like on my local machine, I used the shell to add a user, create a password, and save the user/password. That pattern worked locally, even with foreman.
The setup that seems to have worked:
heroku run python3 manage.py shell
a = User.objects.get(id=1)
a
The server returns
<User: {'username':'Me'}>.
Asking for a.password returns a hashed password that changes when I do a.set_password('Blah') and then a.save().
That's all good and normal, except that the username/password (unhashed) won't log me in. When I run:
heroku run python3 manage.py changepassword Me
Heroku responds with:
CommandError: user 'Me' does not exist
How can a user be saved and retrievable in the shell, implying it's in the database, but not be found otherwise using "manage.py changepassword"?
Most importantly, how can I log into my website on Heroku?
****Edit****
I ran python manage.py createsuperuser in the Heroku shell to create a user so I could log in. Once I did, I saw that none of my CSS loaded. I'm not sure how that's related, but two big problems at the same time make me suspicious that it's something totally unrelated.
Related
I am new to django and trying to run the django server for the first time. I am trying to run the command for starting a django server in a terminal, i.e. python manage.py runserver. But when I go to http://localhost:8000, it is not giving me the default django output containing a rocket like image.
I even tried using http://my_ip:8000 and http://127.0.0.1:8000 but still it doesn't work. I also tried running the command as python manage.py runserver 8000 but it still does not give me anything on localhost:8000.
I have checked and no firewall / antivirus is blocking this port for me. Also, I am able to access other applications on other ports.
I am not getting any errors on my terminal when I run this command. This is a blocker for me and any help would be really appreciated.
Follow the image of my vs code integrated terminal here
Find my image of browser navigated to http://localhost:8000 over here.
I am using the latest python version 3.9 and my django version is 3.2.
Thanks!
In django after populating the database, I started superuser creation but it fails and shows the error. Since I'm new to django and I cannot understand what is the error is about?
python manage.py createsuperuser
Error:
Superuser creation skipped due to not running in a TTY.
You can run `manage.py createsuperuser` in your project to create one manually.
Try to run the command inside a terminal with the path to manage.py as your working directory.
My goal is to build a realtime notification app using Django(1.8.5). I am using django server, Nodejs as push server, ishout.js[nodejs+redis +express.js API]. So I installed them by following the instructions.
I have build the whole project, Kindly suggest how it can be fixed
Error:1) Now when I am doing "$ python manage.py shell" , I get this error http://pastebin.com/DnGjpYEn
Actually by mistake I entered wrong password in first attempt, username was correct but password parameter got wrong, Now can I reset that to avoid the error depicted in pastebin above. By any ways and means can I repeat that step in correct manner. Also, initially there was some warning message related to sqlite3 in ubuntu terminal, hence in response to that I used "$ python manage.py migrate"
Code can be accessed at https://github.com/arunsingh/real_time_notification
I have a Django application that is running just fine on two other servers. It is using MySQL as the database.
I have the user setup for a new instance of the application on a new server so that I can successfully connection via the mysql command line client to the remote database.
However, when I attempt to run ./manage.py syncdb, it tell me:
django.db.utils.OperationalError: (1045, "Access denied for user 'app_user'#'mynewserver.com' (using password: YES)")
Every place I've looked online tell me to make sure the user is setup in mysql and has permission to the new database and even to run flush privileges;. I have double checked all of those and done this multiple times. That doesn't seem to be the issue.
Any thoughts?
EDIT
Also, I just checked and running the following from the python command line works fine too:
conn = mysql.connect(host='mynewserver.com', user='app_user', passwd='secret', db='myapp').cursor(mysql.cursors.DictCursor)
EDIT 2
I just ran ./manage.py sql myapp > myapp.sql; ./manage.py dbshell < myapp.sql
Everything worked, it created the tables just fine. I'm assuming that would use the same permissions and settings as running ./manage.py syncdb. What gives?!?
Versions
Python==2.7.6
Django==1.6.1
EDIT 3
I guess I should also add that I am using South==0.7.6. If that helps.
I did leave something out that I didn't think was relevant, but is totally relevant.
This application has multiple databases defined. Syncdb only runs on one database at a time, and by default will run using the default database, as noted here:
https://docs.djangoproject.com/en/1.6/topics/db/multi-db/#synchronizing-your-databases
However, when my user didn't have permission on the other database syncdb would fail. It didn't indicate which database it was trying to access.
Running ./manage.py reset_db from django-extensions, worked fine as well, before I made sure that the user had permissions on all databases.
I would assume then that there is a bug in syncdb. After more looking into this, I might have to report a bug to Django.
I'm developing some Python project with Django. When we render the Python/Django application, we need to open the command prompt and type in python manage.py runserver. That's ok on for the development server. But for production, it looks funny. Is there anyway to run the Python/Django project without opening the command prompt?
The deployment section of the documentation details steps to configure servers to run django in production.
runserver is to be used strictly for development and should never be used in production.
You run the runserver command only when you develop. After you deploy, the client does not need to run python manage.py runserver command. Calling the url will execute the required view. So it need not be a concern
If you are using Linux I wrote a pretty, pretty basic script, which I am always using when I don't want to call this command.
Note: You really just should use the "runserver" for developing :)
#!/bin/bash
#Of course change "IP-Address" to your current IP-Address and the "Port" to your port.
#ifconfig to get your IP-Address
python manage.py runserver IP-Address:Port
just name it runserver.sh and execute it like this in your terminal:
./runserver.sh