[Tutor] SQLite Django

Alan Gauld alan.gauld at yahoo.co.uk
Thu Aug 4 04:55:49 EDT 2016


Forwarding to list. Please use REplyAll when responding to tutor messages.

On 04/08/16 09:19, Trevor H wrote:
> Hi Alan,
>
> Thank you for the reply. I'll try show the graphic as a website. Would
> I have to make the data entries as a model in Django?
>

I'm not a Django expert so don;t know where you would put the code to
generate the image.  But based on usual MVC practice I'd assume it
would be a model somewhere.

However the image itself will just be a file on the server and would
be stored in the same place as any other images such as logos etc.
The key difference is that the image filename will need to be injected
into your HTML template somehow and I assume you do that by
linking a model variable to a marker in the template. Again I'm
no Django expert I've only watched a few YouTube tutorials...

> I'm new to this sorry for the newbie question.

Newbie questions are what we are here for. Although Django specific
issues might be better addressed to the Django list. But we will usually
have a pop at them if they are not too Django specific.

> I have to link all my data like so to give a plot. Just don't know how.
>
> SQLi command to join my tables:
> To join all tables:

> SELECT devices.id AS id,
>             macs.address AS mac,
>             oses.name AS os,
>             browsers.name AS browser
> FROM devices
> JOIN macs ON devices.mac = macs.id
> JOIN oses ON devices.os = oses.id
> JOIN browsers ON devices.browser = browsers.id;
>

Getting the data and generating the plot are two separate issues.
You can experiment with the SQL using the SQLIte interpreter till
you have a query that delivers what you need. If you don't already
have it installed I strongly recommend doing so.

Without knowing what you're trying to plot and what your schema
looks like I can't really comment on the SQL

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list