Cool
How can build a song download website in django??
inchidi
How can build a song download website in django??
you can try this https://docs.djangoproject.com/en/2.0/ref/request-response/#streaminghttpresponse-objects
Anonymous
Thanks!
Hello
Anonymous
Thanks!
Wanna talk to u
Anonymous
Good evening people, someone can help please with setting up telegram bot on django, maybe somebody already done it?
Anonymous
>>> django-admin startproject partners >>> python3 manage.py startapp partnersbot /partners/settings.py INSTALLED_APPS = [ 'partnersbot.apps.PartnersbotConfig', ] /partnersbot/urls.py urlpatterns = [ path('', csrf_exempt(views.webhooks), name='webhooks') ] /partnersbot/views.py from partnersbot.config import bot from partnersbot.config import dis def webhooks(request, bot_token): try: upd = Update.de_json(json.loads(request.body.decode("utf-8")), bot) except Exception as e: return JsonResponse({}) dis.process_update(upd) return JsonResponse({}, status=200)
Anonymous
bot does not work(
Django Bot
>> Links - Detailed Error Emails For Django In Production Mode – vilimblog - 使用 Nginx 和 Gunicorn 部署 Django 博客_Django博客教程_追梦人物的博客
inchidi
btw consider edit your message since its contain your bot token 🌐
Anonymous
🤔 you are using any tg api wrapper?
python-telegram-bot, ty already revoke token)
inchidi
hmm i never see things inside ptb but afaik ptb already handle its own http connection
Anonymous
but if its webhook, technically it should tell telegram that telegram must send update there
yep, already done it with curl, if im running this project from server is there any difference between: 127.0.0.1:8000 & serverip:8000 ?
Anonymous
ty for some advices)
inchidi
ty for some advices)
btw whats your reason for using django in this case?
Anonymous
webhooks() missing 1 required positional argument: 'bot_token'
Anonymous
@Inchidi thank you, everything becomes clearer, couple of hours and it will work
Django Bot
>> Links - Model Mommy: Smart fixtures for better tests — Model Mommy 1.2.1 documentat
Anonymous
How can learn django ?
Daniel
How can learn django ?
u can't, u're born with it
Django Bot
>> Blogs - Web Development Tutorial: PHP vs. Python & Django
Maz
hi guys, ran into a small issue during running my dev server...
Maz
https://dpaste.de/T2Ww
Maz
that's the error
Maz
this is my views.py
Maz
what does NoneType mean? This code was running fine just yesterday
inchidi
looks like this is your models.py not your views.py
Maz
oh yeah...lemme do the views.py
Maz
it's the home view that says NoneType...
Maz
https://dpaste.de/4LSo
Maz
the views.py
inchidi
https://dpaste.de/4LSo
coz school null=True, you allow Staff.school to be null
Maz
meaning...
inchidi
means Staff.objects.get(user=request.user).school==None there
Maz
but in the models file, i havent explicitly declared Null=True
inchidi
but in the models file, i havent explicitly declared Null=True
if you want all of your Staff always have 1 school then use OneToOne instead ForeignKey(..., null=True)
Maz
oh yeah...seen it...from the Staff model
Maz
lemme change it and will let you know if it works good
inchidi
you will get conflict on migration btw
Maz
you will get conflict on migration btw
You are trying to change the nullable field 'school' on staff to non-nullable without a default; we can't do that (the database needs something to populate existing rows). Please select a fix: 1) Provide a one-off default now (will be set on all existing rows with a null value for this column) 2) Ignore for now, and let me handle existing rows with NULL myself (e.g. because you added a RunPython or RunSQL operation to handle NULL values in a previous data migration) 3) Quit, and let me add a default in models.py Select an option:
Maz
yes i have actually
inchidi
do you care with your current data?
Maz
haha, yes i do man
Maz
but how come this error pops up now? it was running fine a f
inchidi
then run this in shell: for staff in Staff.objects.filter(school_isnull=True): print(staff.id, staff.school)
inchidi
tell me estimation of printed id
inchidi
or Staff.objects.filter(school_isnull=True).count() should be enough
Maz
failed 😅
inchidi
failed 😅
mind to elaborate?
Maz
https://dpaste.de/h1Yx
inchidi
your task now is make Staff.objects.filter(school_isnull=True).count() == 0
Maz
I know...but i dont want to tamper with default values and nulls since it might corrupt my data...
Maz
question is...why is it throwing this error now? it worked fine before
inchidi
the problem is some Staff data have null value
Maz
so should i manually go into the db and fill in the null value fields to avoid messing with the command line
inchidi
for staff in Staff.objects.filter(school_isnull=True): staff.school = School.objects.get(id=1) # just an example, id should be different for each staff staff.save() via shell, all you need to do is assign staff.school for each iteration
inchidi
well, i thought you have thousand important data -_-
Maz
well, i thought you have thousand important data -_-
no...i have that in the postgres db...but in this sqlite it's important too
inchidi
if thats all your data, running Staff.objects.get(id=10).delete() should fix everything then
Maz
okay
Maz
i've deleted that one record but i still get a RelatedObject DoesNotExist error
Maz
RelatedObjectDoesNotExist at /schoolbus/ Staff has no school. Request Method: GET Request URL: http://127.0.0.1:8000/schoolbus/ Django Version: 1.11 Exception Type: RelatedObjectDoesNotExist Exception Value: Staff has no school. Exception Location: /home/alex/schoolbus_work/env/local/lib/python2.7/site-packages/django/db/models/fields/related_descriptors.py in get, line 194 Python Executable: /home/alex/schoolbus_work/env/bin/python2
Maz
haha, it's always the ORM that messes me up though
inchidi
i've deleted that one record but i still get a RelatedObject DoesNotExist error
that means you still have Staff with null school Staff.objects.filter(school_isnull=True)
inchidi
haha, it's always the ORM that messes me up though
if you want to do it manually its your choice tho. just make sure all schoolbus_staff.school_id column doesnt contain duplicate or null value
Maz
Oh so that's where the problem is
Maz
Of course I have duplicate school ids, because 2 staff members can work at same school