#django

/

      • firefox has quit
      • fikka joined the channel
      • AlwaysHigh
        is there any reason not to just use filter() then all()
      • fikka has quit
      • eperzhand has quit
      • Leeds joined the channel
      • fikka joined the channel
      • fikka has quit
      • RandomSerb
        is 1000 lines in an template a lot?
      • AlwaysHigh
        it it mainly html?
      • slamtime has quit
      • fikka joined the channel
      • fikka has quit
      • miz- has quit
      • graphene has quit
      • audioburn
        what is the best payment processing package for django?
      • graphene joined the channel
      • fikka joined the channel
      • fikka has quit
      • hkc has quit
      • fikka joined the channel
      • VikingHoarder has quit
      • fikka has quit
      • dodobrain joined the channel
      • gcain joined the channel
      • graphene has quit
      • gcain
        I'm trying to move to an SQL database, but because this was my first application and has squillions of db changes I deleted all the migration and cache folder so it would skip all the conflicts from all the changes I did.
      • Now when I run my initial migrate I get this: "Applying admin.0001_initial...Traceback (most recent call last):"
      • "_mysql_exceptions.OperationalError: (1005, 'Can\'t create table `leaderboard`.`#sql-37_32` (errno: 150 "Foreign key constraint is incorrectly formed")')"
      • graphene joined the channel
      • I can't find admin.0001, guessing it is from the internal admin system.
      • Any suggestions?
      • fikka joined the channel
      • fikka has quit
      • I made all migrations individually and then did a migrate and it worked.
      • kristian__ has quit
      • AlwaysHigh
        anyway to only allow updating/creating in drf to superusers
      • RandomSerb
        AlwaysHigh: nope, not mainly html.
      • mainly tags
      • ie django template tags
      • AlwaysHigh
        well if its not affecting the reponse time doesnt sound like an issue
      • jtiai_ joined the channel
      • sunil_bansal joined the channel
      • Haudegen has quit
      • jtiai__ has quit
      • aalmazan has quit
      • mburke05 joined the channel
      • isik
        1000 lines mainly tags? How does that work?
      • fikka joined the channel
      • Are we talking about template syntax aka {{% or tags like var|tag1|tag2
      • fikka has quit
      • djapo has quit
      • fikka joined the channel
      • fikka has quit
      • isik has quit
      • gcain
        Does a DateTimeField use a different format on MySQL to SQLite?
      • Inserts keep failing with invalid format and I can't see why.
      • FunkyBob
        gcain: code + traceback
      • gcain
      • fikka joined the channel
      • Does the "1970-01-01 00:00 UTC" part imply that the value the db is getting is a null or 0?
      • This is what gets printed out in debug "Valid form 2018-09-08 15:00:00 "
      • LiftLeft2 joined the channel
      • FunkyBob
        wait... are you not using a ModelForm?
      • [also, where's the form declaration??]
      • gcain
        FunkyBob: Form declaration included now http://dpaste.com/1AKBNQ8
      • Sorry, was trying to keep the noise down.
      • sunil_bansal joined the channel
      • I'm using forms.Form?
      • FunkyBob
        ok... now... _why_ aren't you using a ModelForm ?
      • is it just you don't know them?
      • gcain
        Maybe because I don't know about them.
      • This is my first app. :)
      • FunkyBob
        ok
      • fikka has quit
      • so with a Modelform, it takes all you told django about your model, and makes a form to suit
      • ALSO... it gives the form a save() method that updates and saves a model instance
      • so MOST of the [tedious] work you've done here, wouldn't be needed
      • gcain
        Like creating the actul form?
      • FunkyBob
        also... don't specify name attributes for widgets
      • gcain
        Does it do it itself?
      • FunkyBob
      • yes
      • let's face it... django would be failing the "protect you from the tedious things" metric if it didn't
      • gcain
        Oh, it does too.
      • Ahhh no. This is what I wanted.
      • FunkyBob
        and if you customised the widgets just to add the form-control attr... there's probably an easier way
      • gcain
        You have no idea how many forms I have. haha.
      • FunkyBob
        like iterating self.fields in an overridden __init__
      • gcain
        Thanks, I'll go update this and report back.
      • FunkyBob
        as for custom widget rendering... django forms now support templates for doing that
      • gcain
        How do I get the post data back into the ModelForm?
      • slamtime joined the channel
      • idiocrash joined the channel
      • Just form = EventAddForm(request.POST) then form.save()?
      • Is this right? date = models.DateTimeField(default=datetime.date.today)
      • FunkyBob
        :)
      • yes, it really can be that simple :)
      • gcain
        I get the identicle validation error on save()
      • FunkyBob
        this is why generic views are possible
      • gcain
        Yeh, crazy how simple it can get with Django.
      • FunkyBob
        so, can you show current updated code, and the error?
      • slamtime_ joined the channel
      • also, if you can, the posted data
      • jgadelange has quit
      • gcain
      • slamtime has quit
      • FunkyBob
        are you trying to create a new Event? if so, why are you pulling one from the DB in get()?
      • fikka joined the channel
      • jgadelange joined the channel
      • gcain
        Yes.
      • fission6 joined the channel
      • The set_event is the current event that has been set as active. I pull it because it generates the menu in the template.
      • However, this is the very first run.
      • micahscopes joined the channel
      • FunkyBob
        a bare "except:" is considered very poor form.. you should catch only the exceptions you know how to handle
      • gcain
        Yes, I'm aware of that now.
      • FunkyBob
        ok... I'm going to rewrite this as a plain view function so you can see the reasoning a little more clearly
      • gcain
        I was trying to do a catch(e){ console.log(` you can an error ${e}`); } type thing.
      • Thanks.
      • READ10 has quit
      • FunkyBob
      • gcain
        So much tidier!
      • fikka has quit
      • FunkyBob
        not quite right, though... given what I know now about your existing event idea
      • is that something you usein the template?
      • gcain
        The set_event? Yes.
      • It always has to be sent back with every call, even if empty.
      • I couldn't work out how else to do it.
      • FunkyBob
      • gcain
        So I don't need to instatiate the event, because event_config /is/ the event.
      • FunkyBob
        "sent back"?
      • gcain
        Og, now I see how except works.
      • FunkyBob
        wait... _is_ theevent? so this is a create-or-update view?
      • gcain
        This is purely for the template view.
      • what does redirect(event) do?
      • Does that send it back to the form, but populated?
      • FunkyBob
        redirect is a handy shortcut that wraps many ideas
      • if you pass it a model instance, and t hat instance has get_absolute_url() method... it will call that to get where to redirect to
      • gcain
        Should add_event be a class or a method?
      • FunkyBob
        or you can pass it a string [and args/kwargs] to use for a redirect() lookup
      • gcain
        ok.
      • FunkyBob
        oops... it should be a function
      • gcain
        Cool, makes more sense.
      • FunkyBob
      • Dunedan__ joined the channel
      • gcain
        Oh, you did both post and get in a single function.
      • Your function returns a 405, method not implemented.
      • is it from the URLs.py config?
      • Working again!