#django

/

      • Kangermu
        woops.... so instead of a field user_type, make a property user_type that returns "a if hasattr(self, 'userA') else b" or whatever
      • dashdanw has quit
      • Rundll has quit
      • firefox
        ok and i still want to create a OneToOne relationship with these 2 user profile models right? As in, each user profile model has a OneToOne with the base user model
      • jax
        yes
      • firefox
        ok
      • will i need 2 different log in forms as well?
      • masterrex joined the channel
      • without that user_type field, how would the app know which userprofile model to use?
      • masterrex has quit
      • Kangermu
        because it will have it or it wont
      • masterrex joined the channel
      • jaddison
        It's very much personal preference, but based on project requirements, of course. I prefer a single model with user_type field. Redundant data doesn't matter as much to me now as it once did - space is cheap.
      • You can make it work either way - and each has it's own complexities to work out.
      • fikka joined the channel
      • Kangermu
        thats probably the best answer at the end of the day ^
      • jaddison
        Lots of {% if <something> %} regardless of which path. :)
      • morenoh149
        what do you need to add to a view function in order for reverse() to find it?
      • jaddison
        a name.
      • jax
        we got an easy way to do a GROUP_CONCAT in django (postgres) ?
      • jaddison
      • hop
        morenoh149: you can't reverse a view function, technically, but a url pattern
      • Rundll joined the channel
      • jaddison
        covered in the tutorial too: https://docs.djangoproject.com/en/2.1/intro/tut... <-- on that page
      • masterrex has quit
      • pwrentch has quit
      • hop
        who needs those, when they can waste our time ;)
      • jaddison
        Django has some incredible documentation, quite well organized, and very discoverable via search engine effort.
      • morenoh149
        no mention of reverse on chap 3
      • hop
        if only it were heroin
      • jaddison
        It's worth it for any dev to spend an hour or two browsing through the different sections - clicking the next/prev links
      • hop
        strike that, even h you have to try once
      • jaddison
        morenoh149 apologies then. https://docs.djangoproject.com/en/2.1/intro/tut... equates to it on that page, as that template tag gets you a url by name
      • masterrex joined the channel
      • Kangermu has quit
      • morenoh149 some further googling nets me this as well: https://docs.djangoproject.com/en/2.1/topics/ht... a good description.
      • hop
        chapter 3 in the tutorial does indeed explain that
      • morenoh149
        I'm working backwards from the word reverse
      • hop
        it just doesn't mention `reverse()`, because let's be honest, who needs it
      • morenoh149
        in any case I think my test runner is having issues finding the named route/view https://gist.github.com/morenoh149/948c8190d945...
      • jaddison
        I googled `django reverse url` for that last link I posted
      • hop
        morenoh149: while all the while you should be working forwards from "start here"
      • morenoh149
        you'll either help or not, I have done the tutorial twice
      • hop
        i believe we did help before making fun of you ;)
      • jaddison
        morenoh149 do you namespace polls in your urls.py?
      • your top-level urls.py
      • masterrex has quit
      • morenoh149
        hop: you make fun of everyone. its toxic
      • csotelo joined the channel
      • jaddison: yeah it's the namespacing I bet
      • hop
        i don't
      • morenoh149
        thanks
      • hop
        next time, ask the real question
      • jaddison
        morenoh149 lots of people in here haven't done the tut, but still ask questions. Again, (my) apologies if I pointed you at a resource that didn't help because I assumed (it's the canadian in me)
      • hop
        you assumed on the information given, which wasn't nearly enough
      • jaddison
        I did indeed.
      • So, it's not namespacing? Hmmm, I can't think of anything else that would affect it, honestly.
      • hop I should have asked, rather than assumed, whether he'd done the tutorial. that blame lies with me!
      • also maybe she, not he
      • hop
        jaddison: you get some leeway for trying to help
      • but it's true, i'm too cranky. off to bed
      • jaddison
        Good riddance! :)
      • morenoh149 can you reverse any other of your url pattern names in your tests?
      • Rundll has quit
      • micahscopes has quit
      • morenoh149 I wonder if (in your tests), you need to use the `urlconf` param for `reverse()`? see https://docs.djangoproject.com/en/2.1/ref/urlre...
      • phiofx has quit
      • jessamynsmith
        morenoh149: did you paste your views and urls somewhere?
      • (also, the code that's calling reverse)
      • tdy has quit
      • phiofx joined the channel
      • morenoh149
        it's solved it was the app namespacing.
      • firefox
        when you set a field name in a model to be a OneToOne to another model, what does it actually put in that field?
      • jaddison
        morenoh149 Glad you got it fixed.
      • firefox it's a 'restricted' foreignkey field.
      • Django itself manages the 'one to one' nature of it.
      • firefox
        oic
      • jessamynsmith
        morenoh149: oh great
      • Buliarous joined the channel
      • stahl has quit
      • UncleVasya has quit
      • daydreamm has quit
      • buff3r has quit
      • Rundll joined the channel
      • slav0nic has quit
      • ironi joined the channel
      • jax has quit
      • Rundll has quit
      • mrig has quit
      • Rundll joined the channel
      • Rundll has quit
      • morenoh149 has quit
      • derk0pf has quit
      • firefox
        why does admin.py need access to my custom user creation form?
      • astarrh has quit
      • adsworth has quit
      • bendog joined the channel
      • nvm
      • graphene joined the channel
      • astarrh joined the channel
      • kushal joined the channel
      • dodobrain_ joined the channel
      • astarrh has quit
      • astarrh joined the channel
      • beeman joined the channel
      • beebot_ joined the channel
      • derk0pf joined the channel
      • beebot_ has quit
      • is models.CharField(max_length=10, default='') best way to add nothing to the field when creating it?
      • eribol
        hi again
      • with silly questin about rest framework
      • i have 2 models(User and Post)
      • i am using ListAPIView for User
      • but lets say, i want to use Post in the same template
      • i want to add some Posts to my context and use it in my template
      • GinFuyou
        firefox, for charfield - yes, you probably want blank=True too
      • eribol
        how can i do that?
      • PtxDK
        so i need to install django-sitemaps to use django.contrib.sitemaps?
      • csotelo_ joined the channel
      • with install i mean through pip
      • do*
      • GinFuyou
        no, it's django.contrib so it's part of django
      • astarrh has quit
      • PtxDK
        ty :)
      • newdimension
        The context that is passed to template tags include "object". But it's a list named "dict" and is a bunch of dictionaries. Is there a reliable way to access "object"
      • Let me rephrase: "object" is in a dict that is part of a list
      • GinFuyou
        you mean you have context like context={'key': [{'object': object,}, {...}, {...},]} ?
      • ibanja joined the channel
      • ibanja
        I just set up a virtualenv in "~/../myproject" ... My question is, do I run "django-admin startproject myproject" from within this same directory or from within the next level "~/../myproject/myproject"?
      • astarrh joined the channel
      • GinFuyou
        i don't think you want 4 levels of myproject/ but it doesn't matter much
      • firefox
        how do i set a field to some text in my model automatically with a form?
      • ibanja
        ok. I made a directory for myproject then ran "python3 -m venv myproject" ... should I have skipped the first step?
      • firefox
        i dont have to actually use a hidden input do i?
      • ibanja
        I ran "python3 -m venv myproject" after cd myproject
      • I think I just answered my own question... since this is a virtualenv, I can make the env then make a directory within it for my project.
      • GinFuyou
        wait
      • firefox
        you dont make your poroject directory IN the env
      • GinFuyou
        ^ that
      • firefox
        put it in the same directory as the env
      • GinFuyou
        and you don't want it in your version control, but it can be managed by excluding if needed
      • ibanja
        ok... so I just answered my own question wrong. Thanks
      • GinFuyou
        firefox, automatically with a form? like how?
      • phiofx has quit
      • you can override form save I guess, or which function saves the instance
      • derk0pf has quit
      • firefox
        as in form A will set user_type field to 'A', form B will set user_type field to 'B'
      • GinFuyou
        yeah, look up how form save it's instance .save() or .save_model() I'm not sure
      • firefox
        so if i create my own def save, im overriding the default one?
      • ok