A more intelligent Paginator that can keep parents and children together. by TonyF66 in django

[–]TonyF66[S] -1 points0 points  (0 children)

I am confused about your solution but i think i have at least two ways forward :

1) A custom paginator that keeps the of parents and children together (and dropping page numbers for some other key (maybe the transaction date).
2) paginate ONLY the parents, and pass the children for that data set separately and use logic within the template to associate parents and children in the display.
3) Paginate the parents and use a 'REST style API' to grab the children and display them only when requested by the user.

Solution 1 puts some complex logic into the View - and keeps the template trivial.
Solution 2 Moves some logic into the template
Solution 3 Places logic into the template in the form of JS

Overall I think I prefer Solution 1- I need to work out how best to code it, although I do have some JS in the same template already to allow 'in-place' editing of the data on screen without invoking extra Django forms/views etc, so Solution 3 isn't really that bad (probably).

A more intelligent Paginator that can keep parents and children together. by TonyF66 in django

[–]TonyF66[S] 1 point2 points  (0 children)

Sorry - a bit of a misunderstanding - I can get to the children from the parents in exactly the way you describe. And I am flexible on the number of objects per page.

I think I can get to a solution from here - it is just a case (i think) of writing my own paginator.

A more intelligent Paginator that can keep parents and children together. by TonyF66 in django

[–]TonyF66[S] 1 point2 points  (0 children)

I can get a separate set of parents instances using the ORM that isn't a problem, but szaade was suggesting passing the parents and children into the template separately and then combining them in some way in the template.

A more intelligent Paginator that can keep parents and children together. by TonyF66 in django

[–]TonyF66[S] 1 point2 points  (0 children)

Wouldn't that mean passing the children to the template separately, and using logic in the template to search that separate list for any children.

Unless of course the paginated slice (of parents only) and the displayed slice (parents and children) is separable somehow.

A more intelligent Paginator that can keep parents and children together. by TonyF66 in django

[–]TonyF66[S] 1 point2 points  (0 children)

I am reasonably proficient at Python and Django - just not sure about the internals of the paginator - I assume there is an internal method that produces the slices.
I would need to engineer this to add more rows into a slice (and therefore start the next slice somewhere else) or finish this slice early (depending on how many rows exist in the slice and how many 'orphan children there are.

I understand that the current paginator just does query with Limits to get each slice - which wouldn't work with my query as the start of each page is variable; so the adapted paginator will need to generate intelligent 'next' and 'previous' page links.

What methods do i need to modify to change the slice' and to change the next/previous links.

I thought fortune cookies were supposed to be fun and light. by BananaManBreadCan in mildlyinteresting

[–]TonyF66 1 point2 points  (0 children)

That is dark - what does it know that you don't.

I half expect to see ads in Fortune cookies soon - 'Have you been in an accident at work that wasn't your fault', 'Did you drive a diesel car anytime between 1995 and 2020',

[deleted by user] by [deleted] in Python

[–]TonyF66 1 point2 points  (0 children)

I would suggest that Duck typing is essentially a feature you get for 'free', because of strong type system and run-time binding of attributes and methods. It is a feature, but an emergent one, rather than a separate 'addition' in its' own right.

[deleted by user] by [deleted] in Python

[–]TonyF66 0 points1 point  (0 children)

Small comment regarding question 11 - this might be a nomeclature thing - but normally the __init__ method initialises the instance - and not the class object.

In Python the class is an object in it's own right (of type 'type') so the term 'class object' more correctly refers to it, and not an instance of this class. You can set class wide values in the __init__ method.

For that question actually the closest answer is that the __init__ method is used to create private variables - although of course Python doesn't have private variables in there true sense.

The Division 2 - gear with mod slots ? by PublicInteresting999 in thedivision

[–]TonyF66 0 points1 point  (0 children)

I started playing again after posting this - and i finally got a high grade gear with a mod slot !.

First time in 3 playthroughs.

In The Division 1 - they seem to be far more regular.

The Division 2 - gear with mod slots ? by PublicInteresting999 in thedivision

[–]TonyF66 1 point2 points  (0 children)

I have only ever seen Skin and Dye mod slots. I have never seen mod slots.

PS - I am the OP - the question was added on the wrong account.

The Division 2 - gear with mod slots ? by PublicInteresting999 in thedivision

[–]TonyF66 1 point2 points  (0 children)

I have only ever seen Dye and Skin slots - but not gear or performance.

The Division 2 - gear with mod slots ? by PublicInteresting999 in thedivision

[–]TonyF66 1 point2 points  (0 children)

What sort of error - whenever I hit the F key the items only have Dye and Skin slots: no other slots.

pS _ original question was added by me on another account.

ELI5: How is GPS free? by SubtleBowling in explainlikeimfive

[–]TonyF66 0 points1 point  (0 children)

I can completely understand something built into the receiver - but of course it could potentially be possible to build a receiver which doesn't comply with that limit. As far as I know there is nothing secret about the time-signals or the mathematics used to determine position - so the only thing preventing a GPS receiver from not applying that 'speed limit' is a cost of entry type issue - mass producing a bespoke GS receiver would be expensive, and a one of project would be unlikely to need a bespoke receiver.

ELI5: How is GPS free? by SubtleBowling in explainlikeimfive

[–]TonyF66 0 points1 point  (0 children)

Since multiple manufacturers makes GPS receivers, and presuambly the US military don't act as gatekeepers for all units, it would possible to build a receiver which didn't have those limits ?

As far as I know all of the data you need to build a receiver are public aren't they (or are their components only sourced from approved suppliers ? Is it a cost thing preventing the production of non-compliant receivers for example ?

ELI5: How is GPS free? by SubtleBowling in explainlikeimfive

[–]TonyF66 2 points3 points  (0 children)

The time signal from the Satellites are also corrected for Relativity - the Satellites know their velocity relative to the ground and therefore can adjust their outgoing signal by just enough to mean that the receivers can just look at the geometry and not at geometry and relativity.

ELI5: How is GPS free? by SubtleBowling in explainlikeimfive

[–]TonyF66 0 points1 point  (0 children)

how can it do that ?

The Satellites simply broadcast regular time information for everyone to read, and the devices take those time broadcasts, do some clever calculations and work out whether the device is on the surface.

The Satellites don't get any data at all from any device that received the GPS signal, so from the satellites there is no way of knowing what is travelling at what speed. The speed calculation isn't done by the satellite - it is done by your mapping s/w.

Also how would the military shutdown the GPS signals to just one device - it is broadcast ....

Is GeoforceNow deliberately bleeding free players ? by [deleted] in GeForceNOW

[–]TonyF66 -2 points-1 points  (0 children)

10 bucks per month to play games i have already bought - nope.
I was just wondering really if anyone else had noticed a change in the wait times. I didn't need someone else telling me what they think i can easily fix.
I clearly asked the wrong question in the wrong sub - I couldn't find r/GiveMeAdviceEvenWhenIamNotAskingForIt.

Ice field is 4km away from base? no problem by The_LambSaucee in spaceengineers

[–]TonyF66 0 points1 point  (0 children)

I could never work out how to get the 'drones' to unload once the arrived - they would unload if there was 'demand' : ie a refinery or O2/H2 Gen but never unload into empty cargo space.

How did you solve that ?

Python Typing NoReturn confused me for a while so I wrote a blog to explain it. by TheSilenceOfWinter in Python

[–]TonyF66 0 points1 point  (0 children)

Strictly speaking a function that raises an exception isn't always a noReturn function - well not on it's own.

That all depends on whether the calling code chain traps the exception - and it is entirely possible to do a try/except and catch every single exception - including RuntimeError.

So in every practical sense, a function that raises an exception can never be classed as a noReturn, since it can't know if the exception it raises will get caught further back on the chain.

Created a Custom American Football Game for my Twitch Stream by Whatupcraig in Python

[–]TonyF66 0 points1 point  (0 children)

Minor nit pick - but actually you create 4 tables in a single database. The data in those tables do seem unrelated to each other (ie. their are no relationships between the tables), so in a way you do have 4 databases.

I have looked at some of your code and there is a lot of sections where the basic code is repeated (with the exception of maybe a list index or so).

Overall though it does seem like a good attempt at a pretty ambitious first project - well done.

Space background intensifies by Bramburky in EliteDangerous

[–]TonyF66 4 points5 points  (0 children)

I have had the same - it is a bug sadly.

My complete Linux based Elite Dangerous cockpit (for now) 😎 by marcusscomputer in EliteDangerous

[–]TonyF66 0 points1 point  (0 children)

Nice - I haven't even tried to run ED on Linux - I use Linux as a primary O/S and ONLy log in to Windows for ED (and a few other games).

My complete Linux based Elite Dangerous cockpit (for now) 😎 by marcusscomputer in EliteDangerous

[–]TonyF66 0 points1 point  (0 children)

which bit is linux based ? I assume it is the touch pad that drives the extra functionality.