#django

/

      • knbk
        reverse() returns a url, which is just a string, but post() must return a HttpResponse
      • could do return redirect("pacientes:paciente_registro", documento=documento)
      • d3c0
        knbk: but I need send this variable or variables to another view to process, for instance: 'q' search or select element.
      • tm007_ has quit
      • HttpResponse do that ?
      • what about redirect ?
      • mikeliss joined the channel
      • knbk
        yes, this should do what you want
      • redirect() just calls reverse() and returns a HttpResponseRedirect
      • ironfroggy_ joined the channel
      • govg joined the channel
      • jas02 joined the channel
      • greg_f joined the channel
      • ironfroggy joined the channel
      • jas02 joined the channel
      • backnforth joined the channel
      • d3c0
        moldy: thank you
      • knbk: is working now
      • la_croix
        Could somebody please walk me through getting daphne to run through supervisor?
      • d3c0
        knbk: the las step was do this: return redirect("pacientes:paciente_registro", documento=documento)
      • lordofthekebabs joined the channel
      • I was doing : return redirect("pacientes:paciente_registro", {documentodocumento})
      • I was doing : return redirect("pacientes:paciente_registro", {documento:documento}) in a dict
      • felixx has quit
      • mirk0 has quit
      • jtrob joined the channel
      • felixx joined the channel
      • greg_f has quit
      • chocoelho joined the channel
      • bukensik_ has quit
      • ironfroggy joined the channel
      • khomesh joined the channel
      • glumanda has quit
      • felixx has quit
      • Donitzo joined the channel
      • tonythomas has quit
      • Kangermu has quit
      • felixx joined the channel
      • Ryanar has quit
      • jessamynsmith joined the channel
      • danjac joined the channel
      • Donitzo has quit
      • Ryanar joined the channel
      • jessamynsmith has quit
      • lxer
        I'm trying to update a datetimeField , so I give it a datetime.datetime object, but now it complains 'expected string or bytes-like object'
      • That doesnt make sense, right?
      • eperzhand joined the channel
      • lordofthekebabs
        Hey i have a question. I am not wondering what necessarily causes the problem since I was guessing the `queries` while coding . I am asking how should i query this simple snippet so that i could use the right query the snippet is self explained in its comments: https://dpaste.de/Eow0
      • greg_f joined the channel
      • lxer I had the same problem but in a different use case i suppose instead of fixing the problem i just used models.DateField(default=timezone.now) to update my publish date
      • energizer joined the channel
      • its probably not the same thing but it worked for me :P
      • darkhanb joined the channel
      • but i dont know if it would help dont trust me im just a beginner
      • asimon joined the channel
      • lxer
        lordofthekebabs: I have to update the datetimeField with a new date that I get from somewhere.
      • lordofthekebabs: you have to use try/except blocks. line 30 and 32 fail when current_user is None
      • eperzhand has quit
      • lordofthekebabs
        lxer it updates when the form submits ? I mean yeah i had the same problem I needed i publish_date for my `posts` when the post form was submitted . Instead of fixing the dateField problem that i had i just improted `from django.utils import timezone` in models and used `publish_date = models.DateField(default=timezone.now)` it worked for me i dont know if it is helpful tho
      • and yes i do have try except condiions in my code the snippet is just a demonstration
      • Nizumzen
        if I have a TextField() in a django model using the PostgreSQL database - do I need both blank=True and null=True or will PostgreSQL save the result of blank=True as an empty string or will it use null meaning I also need to specifiy null=True?
      • knbk
        Nizumzen: if you don't have null=True, it'll save an empty string
      • generally you don't want null=True on Char/TextField unless you need null for a unique constraint
      • Nizumzen
        knbk: awesome thank you
      • lordofthekebabs
        knbk could you help me with this query that i am having trouble coding it ? https://dpaste.de/Eow0
      • chocoelho has quit
      • knbk
        lordofthekebabs: sorry, don't have much time to get into it right now
      • lordofthekebabs
        knbk alrighty thank you anyway :)
      • Ryanar joined the channel
      • thiras has quit
      • la_croix
        Does anybody have a working supervisor conf.d for running daphne? All I've found from googling is examples of conf.ds that don't work!
      • khomesh has quit
      • |oLa| has left the channel
      • Tykling
        I do
      • Ikoru joined the channel
      • but it depends on the daphne version
      • channels2 and channels1 are different
      • thiras joined the channel
      • nobodi has quit
      • darthdeus joined the channel
      • lordofthekebabs
        can i use 2 foreign keys in the same model
      • darthdeus
        hey guys, probably a nub question, but I'm just starting my first django app and after I've setup my models (using an existing database) I don't see any of them in the admin, even though they work in the shell and I have registered them in admin.py
      • lordofthekebabs
        both pointing to the same User class that django auth sys provides
      • darthdeus
        also I have added it to the INSTALLED_APPS
      • lordofthekebabs
        darthdeus im a beginner too i always forget to import the models in the admin.py before registering
      • maybe you skipped that but i doubt it :P
      • darthdeus
        lordofthekebabs: uhm I don't think that's it, I have from .models import *
      • ironfroggy joined the channel
      • and also using pycharm which kinda helps me with imports :x
      • lordofthekebabs
        well try `from .models import modelName, modelName2` i do it that way but again i doubt that is the issue
      • instead of trying to import * all at once
      • i dunno
      • darthdeus
        didn't help :(
      • lordofthekebabs
        :( at least i tried
      • darthdeus
        oh shit I found it :D I was doing admin.register() instead of admin.site.register() :x
      • lordofthekebabs: thanks for the help anyway :)
      • lordofthekebabs
        :)
      • lavalamp joined the channel
      • fmul
        lordofthekebabs: you can have two foreign keys but you cannot have a composite foreign key if that's what you want
      • bradfordli123 joined the channel
      • thiras has quit
      • GraysonBriggs
        "Cannot use ImageField because Pillow is not installed. HINT: Get Pillow at https://pypi.python.org/pypi/Pillow or run command pip install Pillow.", except Pillow is installed
      • lordofthekebabs
        fmul alright thanks
      • wreed has quit
      • Wooble
        GraysonBriggs: are you sure you're running the python you installed it for?
      • ironi joined the channel
      • lordofthekebabs has quit
      • GraysonBriggs
        Wooble: i'm pretty sure, the only version of Python running on it is Python 3.5
      • and i installed it with pip3
      • bradfordli123 has quit
      • Wooble
        GraysonBriggs: are you using django in a virtualenv?
      • GraysonBriggs
        no
      • bradfordli123 joined the channel
      • samuelpiecz joined the channel
      • lxer
        always use virtualenv
      • chocoelho joined the channel
      • rv0 joined the channel
      • Wooble
        If you installed django and pillow with the same pip3 it should definitely be able to find it, though. :/
      • GraysonBriggs
        its running on a RPi 3 as basically a Kiosk
      • the server on the device as well
      • Kangermu joined the channel
      • darthdeus
        damn 10 years spent in ruby on rails, and after 3 days of django I feel really stupid for not having it tried sooner :xs
      • thiras joined the channel
      • khomesh joined the channel
      • Tykling
        darthdeus: :)
      • GraysonBriggs
        hmm, this error makes me sound like an idiot, but i've been struggling with it the last couple hours. I think ill wipe Python out and just restart
      • mirk0 joined the channel
      • shiriru joined the channel
      • greatgatsby joined the channel
      • scunion has quit
      • glumanda joined the channel
      • thiras has quit
      • greatgatsby
        Hello. I'm trying to add some validation in forms.py. I'm using Django 2.0.3. I'd like to access request.user in the form. I've been able to use get_form(self) in views.py to set form.fields['user'] = self.request.user, but when I try to access the user model in forms.py I'm getting "'User' object has no attribute 'disabled'" and the user object seems to by of a lazyload type. I can think of some workarounds, but I'd like to know th
      • e correct way for achieving this.
      • ironfroggy joined the channel
      • chocoelho has quit
      • codestr0m has quit
      • Kangermu
        ot spimds ;ole ypi
      • oh boy, sorry
      • it sounds like you're accessing the User object, just trying to access a field that doesn't exist
      • ahmad0461 joined the channel
      • could you paste the relevant code
      • ironfroggy has quit
      • ironfroggy joined the channel
      • greatgatsby
        Kangermu: thanks for the help, I'll put something up on pastebin
      • lxer
        greatgatsby: request.user is usually the logged-in user. it seems like you should just call it username in your form
      • rv0 has quit
      • Kangermu
        greatgatsby: one simple thing....are you trying to access "is_active"? which is a default field on the django.auth User model