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