Heroku warnings in logs using django-celery - python

I am trying to deploy my first app with heroku, and I keep running into issues. Essentially, now whenever I try to open my app with heroku open, I get the "Application Error" page telling me to check my logs. I successfully was able to get through the tutorial, but now following the same steps with my own project, I haven't had any luck. As far as I can tell from the logs, the relevant warnings I am getting are:
WARNING/MainProcess] celery#ce7e5946-3bc3-4622-856f-863b49f442d4 ready
WARNING/Beat] Reset: Account for new version field
WARNING/Beat] Reset: Account for utc_enabled field
WARNING/Beat] Reset: Account for new tz field
The last three all seem to stem from the PersistentScheluler class within celery/beat.py, but I don't understand why. I have no idea about the first warning (or why that is even a warning). Any insight? Thanks in advance for the help.

have you tried to set DEBUG to True in Django settings ?
that should give you enough information about the error to fix it.

Related

Python Django /w Microsoft Graphs - I keep getting value error "state missing from auth_code_flow"

Python Django /w Microsoft Graphs -
I'm following this Microsoft Tutorial for building Django apps with Microsoft Graph (using it on my existing Django webapp), and I am having an issue with authentication: https://learn.microsoft.com/en-us/graph/tutorials/python
I'm on the step 'Add Azure AD authentication' and, after implementing,
I hit the sign in button and enter credentials...and I keep getting value error "state missing from auth_code_flow".
The "callback" method is only making it to result=get_token_from_code(request) and then fails.
Here is the get_token_from_code method:
def get_token_from_code(request):
cache = load_cache(request)
auth_app = get_msal_app(cache)
# Get the flow saved in session
flow = request.session.pop('auth_flow', {})
result = auth_app.acquire_token_by_auth_code_flow(flow, request.GET)
save_cache(request, cache)
return result
What I'm trying to do is eventually access excel online from my webapp.
Any help is greatly appreciated!
I just had this issue and resolved it. It is one of these two things:
You are starting out at 127.0.0.1:8000 and then when you're redirected you're at localhost:8000, which is a different domain. The sessions aren't remembered from one domain to the other. The solution is to start out on localhost:8000 so that the session persists across login.
Your browser is using super-strict cookie settings. Microsoft Edge appears to default to this mode on localhost and 127.0.0.1. There is a lock or shield icon in or near your address bar that lets you relax the restrictions on your cookie settings.
Try one or both of these and you should succeed.
I'm a beginner coder, so i'm pretty sure im just circumventing around the error. But replacing the website URL with http://localhost:8000/# and re running it somehow got around the error. maybe that could be of some use.
If you are running on chrome, rather than running application on http://127.0.0.1:8000 run it on http://localhost:8000, because chrome isn't saving the cookies when the ip address is being used.

Odoo Session Expired Randomly

i keep getting the message ''Odoo Session Expired'' randomly. I have no idea why. I restarted my local instance/server but this didn't solve the problem.
This error comes when you run multiple instances of odoo in local and browse from same browser.

Django Deploying 500 status when debug=False

I'm using Django to build my own blog now and I think it's good. But now I've noticed a problem. When I change the DEBUG const to False, System checks are OK but It'll return a 500 error status. When I change it to True,The bug won't happen again. So what's the problem? Can anybody help me?

500 Internal Server Error Heroku

I have a little system built for learning purposes with Flask-SQLAlchemy and deployed on Heroku(python/postgresql:
http://monkey-me.herokuapp.com/
https://github.com/coolcatDev/monkey-me
My app works fine locally and I have unit tested its functionality and use cases through 14 successfully passed tests.
When I deploy everything seems to go perfectly. Its deployed, I define environment variable APP_SETTINGS>>>config.BaseConfig, I run the db_create.py script to initialize the db. I create some users:
username-userpassword:
Alex-passwordAlex
Jack-passwordJack
Sara-passwordSara
But one thing is missing...I go to the users page from the main navigation bar and I get a 5oo internal server error saying:
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
My app code on app.py has debug mode on:
if __name__ == '__main__':
app.run(debug=True)
But no further error is displayed.
Notice that if I access the system on heroku and I am logged out, if I go to Users I am as I should redirected to the login page so thats how far I have gone with the debug...
If I set the environment variable LAUNCHY_DEBUG on heroku to either true or false everything goes crazy and new problems appear...like I cant delete a user, the profile images wont load....
If I remove the LAUNCHY_DEBUG var from heroku the new problems(images wont load, can't remove user..) persist among the original 500 error of the users page.
Thanks in advance for any suggestion with the debugging
Use the following to get more feedback written in logs:
import logging
app.logger.addHandler(logging.StreamHandler(sys.stdout))
app.logger.setLevel(logging.ERROR)
That reveals the problem:
ProgrammingError: (ProgrammingError) column "user_bf.id" must appear in the GROUP BY clause or be used in an aggregate function
Modify query:
userList = (
users.query
.add_column(db.func.count(friendships.user_id).label("total"))
.add_column(user_bf.id.label("best_friend"))
.add_column(user_bf.userName.label("best_friend_name"))
.outerjoin(friendships, users.id == friendships.user_id)
.outerjoin(user_bf, users.best_friend)
.group_by(users.id, user_bf.id)
.order_by(test)
.paginate(page, 6, False)
)
Regarding the images disappearing:
Any file written on a filesystem hosted on heroku will be deleted on dynos end of lifecycle.

django on a vps - getting "model is already registered" when restarting server

asked this question over the weekend, but for some reason all replies have died. started it again as i now have new information
when i restart apache on my vps, i get
the model "category" is already registered
from init.py
i think this is because the object is getting discovered and registered twice.
i didn't think this would be an issue, it isn't in dev where i don't get these errors. also, i dont get the error the first time i run the server after a syncdb.
so upload code, syncdb, start apache, no error message. restart apache and the error message appears.
i can hide it, by commenting out the line that registers the model, but this means that the object doesn't appear in admin unless i uncomment the line and upload it after the admin site has loaded the first time.
this only appears to happen the first time after an apache reset, doesn't happen subsequent times.
anyone come across this before? using apache with mod_wsgi on debian, django 1.2.3
The error message suggests that model registration code is being repeated. Are you registering your models in the models.py file? The recommended way is to write a separate admin.py file to register the models.
This can be due to the order with which you have subclassed other models. For instance, if you subclass both Django-polymorphic's PolymorphicModel and another model, e.g., Django-extensions' TimeStampedModel, you need to subclass PolymorphicModel first or it will raise this error:
class MyClass(TimeStampedModel, PolymorphicModel): # Raises error
class MyClass(PolymorphicModel, TimeStampedModel): # Does not raise error

Categories

Resources