 Anonymous
    Anonymous 
    
    
 
     inchidi
    inchidi 
    
    
        
                    
                        
                            
                            LOL
                        
                    
                
        
        
        no, drf is life, drf is love
    
 
 
     Anonymous
    Anonymous 
    
    
        
        
        
        What is drf?
    
 
     Django Bot
    Django Bot 
    
    
        
        
        
        >> Blogs
        - Moving to Relay in Django backend
    
 
     inchidi
    inchidi 
    
    
        
                    
                        
                            
                            What is drf?
                        
                    
                
        
        
        best rest framework, django rest framework
    
 
 
     Anonymous
    Anonymous 
    
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        I mean you can handle requests via django easily.
    
 
     Anonymous
    Anonymous 
    
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        What's great in that
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Django already have it
    
 
     inchidi
    inchidi 
    
    
        
        
        
        you dont need to handle your json tho, drf will do it for you
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        I prefer it to do myself
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Hi guys
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        And thanks for changing the group user name for us .
    
 
     Django Bot
    Django Bot 
    
    
        
        
        
        >> Blogs
        - A Complete Beginner's Guide to Django - Part 1
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Do we have links for getting started with django
    
 
     inchidi
    inchidi 
    
    
        
        
        
        #starterpack
    
 
     Group Butler
    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
    
 
 
     inchidi
    inchidi 
    
    
 
     inchidi
    inchidi 
    
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Yeah
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Welcome
    
 
     Abhi
    Abhi 
    
    
        
        
        
        i have a two level of adding url
    
 
     Abhi
    Abhi 
    
    
        
        
        
        like i made an app the url are  url(r'^nodes/', include('nodes.urls', namespace='nodes')),
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        And
    
 
     Abhi
    Abhi 
    
    
        
        
        
        and in that app i have again included url like this
    
 
     Abhi
    Abhi 
    
    
        
        
        
        url(r'^api/', include('nodes.api.urls', namespace='api-url')),
    
 
     Abhi
    Abhi 
    
    
        
        
        
        in in the api folder, i have the url
    
 
     Abhi
    Abhi 
    
    
        
        
        
         url(r'^verification_token/$', VerificationTokenAPIView, name='verification_token')`
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        What are you trying to say?
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Can you come to the point please
    
 
     Abhi
    Abhi 
    
    
        
        
        
        okay
    
 
     Abhi
    Abhi 
    
    
        
        
        
        reverse('nodes:api-url:verification_token')
    
 
     Abhi
    Abhi 
    
    
        
        
        
        should it work ?
    
 
     Abhi
    Abhi 
    
    
        
        
        
        based on above url structure that i gave ?
    
 
     Anonymous
    Anonymous 
    
    
 
     Abhi
    Abhi 
    
    
        
        
        
        we get the url using reverse function right ?
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Yes, it should work. But I have only read the docs. And never tried it myself. So, can't say much.
    
 
     Abhi
    Abhi 
    
    
        
        
        
        but sadly it is not workng
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        How is that sad?
    
 
     Abhi
    Abhi 
    
    
        
        
        
        i though it should work
    
 
     Anonymous
    Anonymous 
    
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Is it working or not?
    
 
     Abhi
    Abhi 
    
    
        
        
        
        no now working
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        Welcome.
    
 
     Abhi
    Abhi 
    
    
        
        
        
        leave it for now
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        As you wish :)
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        guys this is no error but me trying to understand this point of creating models
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        class School(models.Model):
            name = models.CharField(max_length=265)
            principal = models.CharField(max_length=256)
            location = models.CharField(max_length=256)
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        class Students(models.Model):
            name = models.CharField(max_length=256)
            age = models.PositiveIntegerField()
            school = models.ForeignKey(School)
    
 
     Anonymous
    Anonymous 
    
    
        
        
        
        so i understand the basic ForeignKey concept
    
 
     Anonymous
    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
    Will 
    
    
        
        
        
        Foreign key is a primary key of another table
    
 
     Will
    Will 
    
    
        
        
        
        So it will just take the primary key from school, which is the id in django
    
 
     Abhi
    Abhi 
    
    
        
        
        
        my view function is returning like this  return HttpResponse(count, status=200)
    
 
     Abhi
    Abhi 
    
    
        
        
        
        i assigned that response from this to a variable called response
    
 
     Abhi
    Abhi 
    
    
        
        
        
        how do i fetch that count varialble that is getting returned ?
    
 
     inchidi
    inchidi 
    
    
 
     Abhi
    Abhi 
    
    
        
        
        
        yeah
    
 
     inchidi
    inchidi 
    
    
        
        
        
        you can use client
    
 
     Abhi
    Abhi 
    
    
        
        
        
        i am already using that
    
 
     Abhi
    Abhi 
    
    
        
        
        
        response = c.get('/nodes/all/count/')
    
 
     Abhi
    Abhi 
    
    
        
        
        
        and correspondin to that url i have HttpResponse(count, status=200)
    
 
     inchidi
    inchidi 
    
    
        
        
        
        response.content?
    
 
     Abhi
    Abhi 
    
    
        
        
        
        let me check
    
 
     Elizaveta
    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 ^^
    
 
     8
    8 
    
    
 
     Elizaveta
    Elizaveta 
    
    
        
        
        
        I have Question and Choice. Choice has field question which is foreigh key to Question
    
 
     Elizaveta
    Elizaveta 
    
    
        
        
        
        It is all in django admin
    
 
     Elizaveta
    Elizaveta 
    
    
        
        
        
        I need to get question's choices to decide, can i change it's status or not
    
 
     Elizaveta
    Elizaveta 
    
    
        
        
        
        and in QuestionAdmin class I need to get states for every question before 'list display links' works
    
 
     Elizaveta
    Elizaveta 
    
    
        
        
        
        so to make link or not to make link
    
 
     8
    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
    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
    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
    Elizaveta 
    
    
        
        
        
        Class Question has 3 fields: