These are chat archives for django/django

12th
Oct 2018
Francisco Benavides
@fbenavides69
Oct 12 2018 04:32
Hello everyone, I am integrating a Python/Django backend with a JavaScript/React frontend, and doing it with Webpack, yet I am a newbie in Webpack and the examples and tutorials are not up to date to the latest stable releases. I have read the documentation and it is painfully slow for me to grasp all the knowhow and translate into a working solution. Does anyone know of a working example that I could use? Suggestions? Recommendations? Thank you!
Luke-VideoLibre
@LukeVideo
Oct 12 2018 08:55
@fbenavides69 i'm using django and react and connect them over graphql.
I would suggest the howtographql site. Choose the relevant tutorial at the bottom of the page ;)
Also django-graphene work like a charm.
if your not sure where to start with webpack and all the build tools, go for createreactapp
MilanRgm
@MilanRgm
Oct 12 2018 13:01
@LukeVideo this line gives me a instance company_instance = get_instance(models.Company, id)because my get_instance helper function is like following
def get_instance(_object, encoded_id, otherwise=None):
    try:
        return _object.objects.get(pk=from_global_id(encoded_id)[1])
    except _object.DoesNotExist:
        return otherwise
MilanRgm
@MilanRgm
Oct 12 2018 14:26
@LukeVideo there is very silly mistake i have done, if you notice it.
business_model_instance.company = company,
There is comma after each statement which is making it as tuple
Luke-VideoLibre
@LukeVideo
Oct 12 2018 14:32
Classic !
Dominik Matta
@xdom
Oct 12 2018 15:07
Hey guys!
How do you deal with sth like this:
author = models.Author(name='Herp Derp')
book = models.Book(name='Super book', author=author)
author.save()  # author saved after new book creation => book.author_id remains empty :/
book.author_id = book.author.id  # <-- is there any other way to do this automatically before save?
# book.author = book.author  <-- this works, too
book.save()
Dominik Matta
@xdom
Oct 12 2018 15:34
Documented here: https://code.djangoproject.com/ticket/8892
Looks like this won't fix
If you want your own solution: https://code.djangoproject.com/attachment/ticket/10811/refresh.py
fsecada01
@fsecada01
Oct 12 2018 18:40
I'm wondering why you're not creating a BaseClass of 'Literature' which would include all info on books and authors, and then create author and book models that inherit from that.
Corey Vincent
@CoreyVincent
Oct 12 2018 20:07
can anyone help me with haystack search?
Or search in general?
Eze Sunday
@rexeze
Oct 12 2018 21:49
Hello, guys. I was wondering how embedding works. I mean how I can take a javascript code from drift. Embed it into my website and I'll start seeing a chat widget on my website. Anyone with an idea? I'm trying to understand this concept. I really don't know the right keywords to search on Google right now. I'm creating something that should work that way.