These are chat archives for django/django

29th
Jan 2018
Renato César
@rencesar
Jan 29 2018 10:03
In django 1.11 have any way to bind in a specific port in live test server instead of bind in port 0?
Umar Sohail
@UMAR-SOHAIL
Jan 29 2018 14:04
Someone can tell me what classes i have to define for a blog app ???
In models
Fortune Tede
@fortunetede
Jan 29 2018 15:30
hey anyone figured how to use sorl-thumbnail in django 1.11.6
Kyle Mulka
@mulka
Jan 29 2018 15:33
@UMAR-SOHAIL Whatever you want. Depends on what features you want your blog app to have. At minimum there would probably be a Post model.
Luke-VideoLibre
@LukeVideo
Jan 29 2018 16:18
@UMAR-SOHAIL with generic views you can with close to no coding get a list view and a post/detail view
Anyilloyd
@Anyilloyd_twitter
Jan 29 2018 16:19
Hello guy, please how do i archive a password authentication system that can authenticate students to check there result online. example. i want to create an application that can generate a code which students will use as serial number to check there results online after typing there student id. The serial number will be able to fetch each student id from the database in other to display the students result. The interface will be STUDENT ID.................... SN............................ Am still new in python django
Luke-VideoLibre
@LukeVideo
Jan 29 2018 16:20
That pretty much does it for a minimalist blog app. But if you want some special sorting algorithms, a comment engine, a users database it will involve a bit more work. Let us know as you progress.
Fortune Tede
@fortunetede
Jan 29 2018 16:25
@Anyilloyd_twitter if you have access to the result DB then it achievable
Anyilloyd
@Anyilloyd_twitter
Jan 29 2018 16:29
@fortunetede yes it will have access to the database
Umar Sohail
@UMAR-SOHAIL
Jan 29 2018 16:32
@LukeVideo I have done the views and it works. I just wanted to have more features like comment engine for now.
Fortune Tede
@fortunetede
Jan 29 2018 16:35
@Anyilloyd_twitter okay so you have a user database
@Anyilloyd_twitter where you can login to a profile
what i will suggest is that you create another model that store random char
then later in your views..you write a condition to do the checkings
@Anyilloyd_twitter what do you thing
Anyilloyd
@Anyilloyd_twitter
Jan 29 2018 16:40
@fortunetede _twitter the user db contains the students profile and results. while the serial number which is the random generated will authenticate the user to display his result through the user db. each student will have a unique code which will expire at a given time.
@fortune Tede _twitter Ok
emihir0
@emihir0
Jan 29 2018 16:44
@fortunetede @Anyilloyd_twitter simply make a Student model that has a one to one relationship to User model, which stores the UID. You can check out apps like allauth to check how they create & store such random tokens (you dont actually need to even store it, for example you can look at when the User was created and do some hash arithmetic on it to generate a key).
basically your Student model should contain both the student ID, and the SN. From my understanding of your domain, SN basically acts as a password to legitimise the Student user...
in your views you can have a simple FormView, where the form itself will have the two fields you require (student_id, serial_number), and in your clean method validate that this corresponds to some User and return the result
Anyilloyd
@Anyilloyd_twitter
Jan 29 2018 16:48
@emihir0 Thanks to you guys. You people are making a whole lot of sense. I will try out that now.
emihir0
@emihir0
Jan 29 2018 16:50
I mean if you don't want students to be able to login, then you dont need the one to one relationship to User model
so it's easier for you to change stuff in future; it's a real pain to adjust swappable models once you have data
Anyilloyd
@Anyilloyd_twitter
Jan 29 2018 16:54
@emihir0 ok
Luke-VideoLibre
@LukeVideo
Jan 29 2018 17:00
@UMAR-SOHAIL add a model for your comments. Link them to the blog posts with a external key. You will need a form to submit new comment. I would add that to the detail view. You can add a condition so that it only shows up if user is connected. Sorry it might be a bit rough description but alas for the moment I'm on mobile app. If you want more advice ping me later. ;-)
Prateek Dabas
@dprateek11
Jan 29 2018 18:29

latest_question_list = Question.objects.order_by('-pub_date')[:5]

[:5] ------ What does this means

??
Renato César
@rencesar
Jan 29 2018 18:34
Order by reversed by pub_date and take the first five elements
[0:5] 0 element to four
Slice a queryset is the same that slice a list
David Jackson
@davidwallacejackson
Jan 29 2018 22:43
I have a JSONField that gets pretty large and to save memory I'd like to not turn it into a dictionary unless I explicitly deserialize it. Is there a straightforward way to do that? I've been thinking about subclassing the postgres JSONField, but that seems like... a lot.
Ideally I'd just keep it as a string 90% of the time, including when sending it to the client, but I'd like to keep the jsonb column type so I can query on json keys in the future if I need to.