Anonymous
inchidi
LOL
no, drf is life, drf is love
Anonymous
What is drf?
Django Bot
>> Blogs - Moving to Relay in Django backend
inchidi
What is drf?
best rest framework, django rest framework
Anonymous
I mean you can handle requests via django easily.
inchidi
I mean you can handle requests via django easily.
am gonna leave this link here http://ngenworks.com/technology/how-django-rest-framework-changed-my-life/
Anonymous
What's great in that
Anonymous
Django already have it
inchidi
you dont need to handle your json tho, drf will do it for you
Anonymous
I prefer it to do myself
Anonymous
Hi guys
Anonymous
And thanks for changing the group user name for us .
Django Bot
>> Blogs - A Complete Beginner's Guide to Django - Part 1
Anonymous
Do we have links for getting started with django
inchidi
#starterpack
Group Butler
#starterpack
New to Django? here is some resource to start Official docs tutorial Step by step tutorial Video tutorial Another video tutorial Books Django by Example Tango With Django
Anonymous
Yeah
Anonymous
Welcome
Abhi
i have a two level of adding url
Abhi
like i made an app the url are url(r'^nodes/', include('nodes.urls', namespace='nodes')),
Anonymous
And
Abhi
and in that app i have again included url like this
Abhi
url(r'^api/', include('nodes.api.urls', namespace='api-url')),
Abhi
in in the api folder, i have the url
Abhi
url(r'^verification_token/$', VerificationTokenAPIView, name='verification_token')`
Anonymous
What are you trying to say?
Anonymous
Can you come to the point please
Abhi
okay
Abhi
reverse('nodes:api-url:verification_token')
Abhi
should it work ?
Abhi
based on above url structure that i gave ?
Anonymous
should it work ?
*will it work?
Abhi
we get the url using reverse function right ?
Anonymous
Yes, it should work. But I have only read the docs. And never tried it myself. So, can't say much.
Abhi
but sadly it is not workng
Anonymous
How is that sad?
Abhi
i though it should work
Anonymous
Is it working or not?
Abhi
no now working
Anonymous
Welcome.
Anonymous
i though it should work
Clarify what are trying to do please.
Abhi
leave it for now
Anonymous
As you wish :)
Anonymous
guys this is no error but me trying to understand this point of creating models
Anonymous
class School(models.Model): name = models.CharField(max_length=265) principal = models.CharField(max_length=256) location = models.CharField(max_length=256)
Anonymous
class Students(models.Model): name = models.CharField(max_length=256) age = models.PositiveIntegerField() school = models.ForeignKey(School)
Anonymous
so i understand the basic ForeignKey concept
Anonymous
but what i don't understand is why it refers to the field "name" since we just passed the name of the model "School", we never passed anything refer to name
Will
Foreign key is a primary key of another table
Will
So it will just take the primary key from school, which is the id in django
inchidi
but what i don't understand is why it refers to the field "name" since we just passed the name of the model "School", we never passed anything refer to name
just like what Will said. its not, if you get Students object student = Students.objects.get(name="valid name") and print student.school it will print School object by default. but if you override magic method __str__ for School model and you returning name return self.name in that def __str__(self): then print(student.school) will print School name and not School object
Abhi
my view function is returning like this return HttpResponse(count, status=200)
Abhi
i assigned that response from this to a variable called response
Abhi
how do i fetch that count varialble that is getting returned ?
Abhi
yeah
inchidi
you can use client
Abhi
i am already using that
Abhi
response = c.get('/nodes/all/count/')
Abhi
and correspondin to that url i have HttpResponse(count, status=200)
inchidi
response.content?
Abhi
let me check
Elizaveta
Hey! Can anyone help me please? I need to modify admin.py in django I need to write something like this: if 'state' == 1 or 'state' == 2: list_display_links = ['question_text',] but I don't know how to rewrite it properly so it will work Also here: if obj.get_state() == 1: if obj.choice_set.all(): choice_set.all() isn't what I need, if anyone colud help to rewrite ^^
Elizaveta
I have Question and Choice. Choice has field question which is foreigh key to Question
8
I have Question and Choice. Choice has field question which is foreigh key to Question
could be rewriting the queryset depending on what you want to display, you use forms, or is it in a view where you want to implement that code?
Elizaveta
It is all in django admin
Elizaveta
I need to get question's choices to decide, can i change it's status or not
Elizaveta
and in QuestionAdmin class I need to get states for every question before 'list display links' works
Elizaveta
so to make link or not to make link
8
I would have to see the code to say exactly what code it would be, but if it should be able to modify the queryset
Elizaveta
Okay, I will show you it at the moment. By the way, I figured out what I need to do in the first case, so now I only need to rewrite list_display_links
Elizaveta
class QuestionAdmin(admin.ModelAdmin): fields = ['question_text',] inlines = [ChoiceInline] actions = [make_active, make_closed, make_new, delete_selected] if 'state' == 1 or 'state' == 2: list_display_links = ['question_text',] list_display = ['question_text', 'state', 'pub_date']
Elizaveta
Class Question has 3 fields: