#django

/

      • okimoyo
        One of the mantras of Python is that "explicit is better than implicit" right?
      • redcricket has left the channel
      • I need to use information that the view contains that the form doens't per say, so where in the view would you do that?
      • dang`r`us
        (nitpick: 'per se')
      • santiago
        dang`r`us: oh, i think that between dbs there is not much difference, unless u had a very specific db for that purpouse (which i dont know of any)
      • dang`r`us
        santiago, okay. So do you have any experience with the performance impact? I mean I'm quite sure I'll be fine, but not 100%
      • djapo
        okimoyo: get_form_class or wherever the form is initiated and pass that info to __init__ or in is_valid or wherever you want
      • ruind has quit
      • i would do it in the view
      • santiago
        no, sorry :/
      • bahoo joined the channel
      • ycon_
        mattmcc, to continue our convo about numbers- would you recommend integer for gender?
      • pastry has quit
      • deitarion joined the channel
      • mattmcc
        Were these the genders that you were receiving from some outside data source, so you can't really restrict them to a set choices list?
      • deitarion
        How would you guys recommend implementing a system where sidebar buttons highlight for descendant pages as well as the pages they directly point to? (Bonus points if I can reuse it in another site I'm porting to Django where the actual content pages have a namespace separate from the various drill-down URL schemes used to reach them)
      • ycon_
        Ah ok. Is it a good idea to relate (fk) directly to my user model? Its for a clothing store, so there will be times when the user might want to shop a dif gender...?
      • mattmcc
        deitarion: A good navigation app can help you render active parent menu items. I'd checkout django-sitetree.
      • deitarion
        Thanks. Looking into it now.
      • keimlink has quit
      • david5aa joined the channel
      • ycon_
        mattmcc, or is it better to store the general as a pk with each product? Seems wasteful/repetive?
      • okimoyo has quit
      • mattmcc
        ycon_: Ah, this must be a different case than the one I'm thinking of.
      • ycon_
        Backend of a mobile app, ~ 1mill clothing products coming through an API if its relevent
      • mattmcc
        So what are you assigning a gender to? A product? A user?
      • xpen joined the channel
      • rmwdeveloper has quit
      • ycon_
        mattmcc, both have it- user gender from their login (social), and obv clothing belongs to one/the other/ both
      • jaddison has quit
      • mattmcc
        And how many distinct values are there? Can the provider of the API data just send along any arbitrary value they want?
      • ruind joined the channel
      • ycon_
        No, we'll predefine a few (but they'd be able to change the api's gender/store etc) django-nap fyi
      • mattmcc
        If it's a predefined set, them I'd just use a single-letter choice. (('w', women'), ('m', 'men'))
      • ycon_
        Within each individual product is fine?
      • mattmcc
        Sure.
      • One way or another, you have to identify a gender for each product.
      • maryokhin has quit
      • ycon_
        So as its' own model (fk with the model)?
      • xpen has quit
      • mattmcc
        No, just a CharField(choices=...)
      • ycon_
        Oh yep, got it
      • mattmcc
        A model buys you nothing here if the choices are fixed.
      • In fact, it would slow things down. You'd have a constraint and an index that don't help you.
      • marlinc has quit
      • doc|work has quit
      • Debnet has quit
      • pydave6367 joined the channel
      • stinky180 has quit
      • marlinc joined the channel
      • cramm has quit
      • SteenJobs joined the channel
      • TeeTime has quit
      • astrosoup joined the channel
      • dang`r`us
        hm. I assumed that switching on ATOMIC_REQUESTS would cause a rollback of everything saved in a view when that view throws an exception. But apparently I was wrong?
      • SteenJobs has quit
      • astrosoup
        Ok, so I bought a MacBook and set Python/Django on it along with a PostgreSQL database. I ended up screwing something up and had to completely reset my migrations for all my project's apps. Now I pull the app back through source control and migrate won't make the necessary changes on my original machine's database.
      • rideh has quit
      • mattmcc
        What steps did you take to 'reset' your app's migrations?
      • astrosoup
        Basically deleted them all
      • and ran initial migrations on a fresh database.
      • mattmcc
        Okay. There's two parts to managing migrations, the Python files and a table in the database that tracks the applied state.
      • dang`r`us
        does ATOMIC_REQUESTS not work with WizardViews?
      • astrosoup
        Ah okay
      • CandyApples has quit
      • But shouldn't my new migrations be named differently than my old ones?
      • Or did deleting everything screw it up entirely?
      • rideh joined the channel
      • I didn't think about the implications of migration python files staying in version control before I cleared everything.
      • dang`r`us
        you can delete the migration files too, you know
      • astrosoup
        I did that on the other machine. My fear is if I do that again, it will cause the same problem when I pull the project again on my laptop
      • I don't want to keep going back and forth
      • coderzm joined the channel
      • dang`r`us
        like mattmcc said there is two parts to migrations
      • I mean, your repo should always be able to bring your db to a consistent state
      • you might need to zap the db for that to happen, depending on what you did to the migration files
      • astrosoup
        So I need to find that migration history table and drop it?
      • AimerPaddle has quit
      • dang`r`us
        that depends on your screwup.
      • mihow has quit
      • but since you cannot pin it down, I'd say the surefire way is zap the db and re-run your migrations
      • (... after recreating the db)
      • astrosoup
        I'm using GeoDjango and its kind of a pain to set my database up
      • I was hoping there was an easier way
      • mattmcc
        There is, actually.
      • bahoo has quit
      • astrosoup
        I found the django_migrations table
      • mattmcc
        When you create your DB, load all the postgis stuff into the public schema like normal. Then create another schema with the same name as your DB user.
      • dang`r`us
        I'm using geodjango too and did what mattmcc recommended a few days ago, it's quite cool
      • mattmcc
        Then, if you want to blow your stuff away, you can drop the schema, not the whole DB.
      • astrosoup
        Oh wow
      • mattmcc
        Postgis stays there.
      • astrosoup
        Yeah that's what I need
      • mattmcc
        This works handily because the default search_path is "$user",public
      • dang`r`us
        mattmcc, I could not get that part to work for some reason though
      • ambar joined the channel
      • so I created a schema 'django'
      • and put this in my db options: '-c search_path=django,public'
      • astrosoup
        I've never worked with multiple schemas before. Anything I should watch out for?
      • dang`r`us
        works like a charm
      • astrosoup, zapping DB then becomes: drop schema django cascade; create schema django;
      • pingupingu joined the channel
      • (without that -c option, django would create tables in the public schema)
      • mattmcc
        dang`r`us: Hmm. "create schema authorization <yourdbusername>" ?
      • dang`r`us
        mattmcc, I'll try it out ... right now I'm under release pressure
      • people in #postgres have been very helpful too so I'm sure I can figure this out ...
      • someday
      • right after I fix this weird transaction problem
      • Technodrome has quit
      • mattmcc
        astrosoup: If you're unfamiliar with them, it'd be worth reading a bit. But they're pretty straightforward. http://www.postgresql.org/docs/9.4/static/ddl-s...
      • holler joined the channel
      • astrosoup
        Great, thank you so much
      • xman has quit
      • holler
        hello, I am using celery and ran into an issue where I get a TypeError but Im not sure why? http://dpaste.com/2E3WV8D#line-67
      • someone told me you can't pass a model instance into a shared_task, is this true? why/
      • CandyApples joined the channel
      • mattmcc
        Well, as a general rule you don't want to pass model instances to tasks because of serialization issues.
      • The model data may be stale by the time the task gets to it, and you're storing a ton of model object attributes that you almost certainly don't need.
      • You can instead just pass the PK and query it from your task.
      • holler
        mattmcc: ok so whats a suggestion, just serialize it and pass that to the task? or^^ ah yea
      • I thought of doing that
      • just pass the id and do a lookup
      • ok sweet.. thx
      • TeeTime joined the channel
      • Contigi joined the channel
      • deitarion has left the channel
      • Ergo has quit
      • ruind has quit
      • InfoTest has quit
      • dang`r`us
        lesson learned: ATOMIC_REQUESTS is an option per db, not toplevel settings.py scope
      • (I'm not quite sure whether I like it this way to be honest)
      • kyheo joined the channel
      • BabySuperman joined the channel
      • kyheo has quit
      • codeitloadit has quit
      • tehnyaz has quit
      • slick666_work joined the channel
      • decaff_ has quit
      • holler has quit
      • any reason why geodjango admin uses openlayers and not leaflet?
      • Atrumx joined the channel
      • I mean, not being able to see cities kinda sucks.
      • but I suppose it's "just" a matter of configuring the template
      • sigh :)
      • slick666_work has quit
      • mattmcc
        Patches welcome? :)
      • slackorama has quit
      • But there is django-leaflet already, so. https://github.com/makinacorpus/django-leaflet#...
      • dang`r`us
        mattmcc, oh, cool
      • mostly concerned with the admin right now but that'S definitely good to know