Handling Ajax request in Django

Posted by  Franco Falkov
 533  View(s)
Rate this:

Please help me I cant include URL in my Ajax requsest .

from django.conf.urls import include, url

from django.contrib import admin 

urlpatterns = [

     url(r'^admin/', include(admin.site.urls)),

     url(r'^', include('post.urls')), 


  1. Re: Handling Ajax request in Django

    Create models :

          class Post(models.Model): 
            post_heading = models.CharField(max_length=200)
            post_text = models.TextField()
                def __unicode__(self):
                     return unicode(self.user)

    Create tables:

       class Like(models.Model): 
            post = models.ForeignKey(Post)


    $ python manage.py makemigrations 
    $ python manage.py migrate

    check all above steps properly and set up all tables and models and than use this below code: 

    from django.conf.urls import url 
    from . import views
    urlpatterns = [
            url(r'^/$', views.index, name='index'),
            url(r'^likepost/$', views.likePost, name='likepost'),

    //for register model: 

    from .models import Post, Like