These are chat archives for django/django

22nd
Nov 2016
Ryan Moore
@xHeliotrope
Nov 22 2016 00:04
Trying to get whitenoise provisioned for heroku using the settings from their docs. When I Debug=False it, my logging shows
The joined path (/DataTables/datatables.min.css) is located outside of the base path component (/Users/me/development/my_project/myapp/staticfiles)
anyone have experience with this?
Noli Bravo
@nolibravo_twitter
Nov 22 2016 01:34
this is another newbie q and i hope id get a clear direction on how to get closer a new career in relates to what i already have (sort of) accomplished? I am a Professional Musician (Vicalist/Pianis) for a living, has a Home Studio with Logic Pro X and other gadgets along with it... I also released my self-produced album last year...My question: I wanna change career as a programmer of some sort but also wanna be able to be around the Music-Making or similar bcuz this is where i think i can be a lot more happier and even more productive and most of all, high-paying jobs. I noticed that my salary is never enough having 6 kids to feed :worried: fast-forward... Gratey appreciate all of your real advice, the more it hurts the more it's real.. so please have at it! :+1: Thanks!
Mark Heppner
@mheppner
Nov 22 2016 03:08

@jdaltonchilders sure, something like this:

import json
from myapp.models import Thing
lines = []
with open('/path/to/file.json') as f:
    lines = json.loads(f.read())
for line in lines:
    Thing(**line).save()

you'd have to make sure each json entry has the exact fields as your model, or else you'd just have to make a new dict and reassign as needed

Mark Heppner
@mheppner
Nov 22 2016 03:14
@nolibravo_twitter i was in the same boat, but not as far as you. i started college as a music education major. i quickly saw how high-stress and relatively low-pay the field was and switched to computer science. i can't answer you on how to do such a huge career change, but i do understand how difficult it can be to change your mindset. i'd suggest getting into webdev more, and try to become equally strong in server-side and frontend code. it's a pretty popular field to be in right now
Aji Pratama
@atamadev
Nov 22 2016 04:53
Hallo.. can i build CRUD function just use Views & Template without model & database?
Noli Bravo
@nolibravo_twitter
Nov 22 2016 06:14
@mheppner Thanks a lot, Mark! Great advice and direction as a starting point. I just signed up for Complete Node.js Dev Course 2.0 at Udemy. Also, signed up for Python BootCamp Course. Would this be a good choice to you? Not knowing which course would end up giving me higher pay rate at the end, i have no idea. Any more pointer can you possibly share with me? Again, thank you for your kind support!
Shaifali Agrawal
@exploreshaifali
Nov 22 2016 08:55
Hello!
I am stuck at a point while using celery with django
I am using django-celery-beat to create periodic tasks..... problem is whenever I create/update/delete a periodic tasks, I have to restart beat to make the changes work.... else beat runs the task as it is
I am not sure if I am missing some setting or anything else to make it work wtihout restarting the beat
I have set settings beat_scheduler = 'django_celery_beat.schedulers:DatabaseScheduler'
any idea why do I always need to restart the beat?
Kaushal Kumar
@kaushal087
Nov 22 2016 09:34
I want to create an application in django in which user will login with facebook. Users friends list , photos , email and other information will be fetched and after that some other operations will be done. I am using "python social auth" to authorise with facebook. But the problem is that I can't test it on localhost. How should I create a facebook app with localhost domain. How should I proceed? Any help please
Slava
@scream4ik
Nov 22 2016 09:40
on your fb app you need add your test domain with port 8000 for example http://example.com:8000/ and on your local hosts add 127.0.0.1 example.com
when you open http://example.com:8000/ its will be from local. Then you can login with fb and he'll redirect you to your local project
sukianto
@sukianto
Nov 22 2016 09:55
@nonamime_twitter I prefer create_or_update but Thanks! fix my prob :)
rjvcoder
@rjvcoder
Nov 22 2016 12:07
hi!! How can i change the primary key? I think the default is id.
rjvcoder
@rjvcoder
Nov 22 2016 12:12
thanks! I think missed that in the pdf version. :worried:
Robert
@rtpm
Nov 22 2016 14:14
Hello. Have some problem with inlines. When adding a new inline in changeView (save and continue) button, a new parent object is created, instead of adding this inline value to the existing one. https://gist.github.com/rtpm/129c15e940001281a0d2421a936617f6 Do I miss something ?
Slava
@scream4ik
Nov 22 2016 14:16
why you inherit from admin.ModelOptions instead of admin.ModelAdmin?
Robert
@rtpm
Nov 22 2016 14:17
nah.. gist mistake. I inherit from ModelAdmin. sorry
Slava
@scream4ik
Nov 22 2016 14:19
it seems with your code all fine. May be problem in other place
Robert
@rtpm
Nov 22 2016 14:29
Got it! Seems like forgot to check if the object created in Galllery save() method is new as I am generating the Photo.id dynamically. Spent 3 hours on searching for a bug.. Hope someone reads it in the future.. Thanks for help and your time
Thanks @scream4ik for confirming my admin is correct. Wouldn't search for that bug outside admin.py without your opinion:)
Slava
@scream4ik
Nov 22 2016 14:32
np
J. Dalton Childers
@jdaltonchilders
Nov 22 2016 19:29
@mheppner Thank you or table structure an integer value called ‘study’ and a json value field called ‘data’.
So far I have
filepath = "BreastCancer201510/*_activities.json.gz"
    files = glob.glob(filepath)
    for file in files:
        with gzip.open(file) as f:
            lines = json.loads(f.read())
            for line in lines:
                cur.execute("INSERT INTO study_tweet (study,data) VALUES (%s,%s)", (study,line))
Mark Heppner
@mheppner
Nov 22 2016 19:45
@nolibravo_twitter sure, no problem. those courses seem like a great starting point. but don’t think the course you pick is going to directly correlate with your starting pay rate. it’s all about experience and what you are capable of doing, not necessarily what you know. start those courses and get a feel for what it’s like, then start contributing to open source projects, even if it’s just doc fixes. it’s a good way to boost your visibility, get exerpience, and show that you can work with others
@exploreshaifali this is a known issue celery/django-celery-beat#7 but i haven’t been able to figure out why it happens
Shaifali Agrawal
@exploreshaifali
Nov 22 2016 19:47
@mheppner yeah I got that issue after posting there.... I had also commented there. but anyway thanks :)
Mark Heppner
@mheppner
Nov 22 2016 19:48
@jdaltonchilders i thought you wanted to put the json data into your django app? you shouldnt have to mess with plain sql for that.
J. Dalton Childers
@jdaltonchilders
Nov 22 2016 19:49
@mheppner I was attempting with an external file while I was working out the issues.
Mark Heppner
@mheppner
Nov 22 2016 19:50
@exploreshaifali haha i see that now. it seems like all the devs have gone silent after releasing 4.0. i still have another issue in celery itself that i dont understand.
Shaifali Agrawal
@exploreshaifali
Nov 22 2016 19:51
@mheppner haha yeah. It seems same to me too
Mark Heppner
@mheppner
Nov 22 2016 19:52
@jdaltonchilders i strongly suggest not accessing your database outside of django if you plan on using the orm. if the schema changes, or if the data you put into it doesnt match what django expects, youre going to be facing a lot of confusion. if you want to just write a small script, use a management command instead. you can easily call it outside of django but you’ll still have access to the orm
Garrus Napp
@GarrusNapp
Nov 22 2016 21:33
Hello, I want to use a image file that is being updated every few seconds. In html template I have tried using jQuery to change src to filename + ? + current time because if the src were the same it wouldn't refresh the picture but obviously django doesn't like that and gives me 404 "http://192.168.0.16:8000/static/current.jpg%3F1479850283587". Any ideas?
J. Dalton Childers
@jdaltonchilders
Nov 22 2016 21:55
@mheppner I’ll attempt to get it working with the either a Test Case or Management Command.
Mark Heppner
@mheppner
Nov 22 2016 21:57
@GarrusNapp you’re encoding the ? as a url param, so django is trying to route that. change that to filename + ‘?’ + current_time or whatever you have to do to not encode it as %3F.
Garrus Napp
@GarrusNapp
Nov 22 2016 22:05
@mheppner That indeed was the issue, here is mistake '{% static "current.jpg?" %}' . Thank you for help
J. Dalton Childers
@jdaltonchilders
Nov 22 2016 23:03

Has anyone else had this error when inserting json into the database table?

Detail: u0000 cannot be converted to text

I’m trying to use regex to resolve it, but I haven’t had any luck yet.