Handling Ajax request in Django

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')), 


Last updated:7/16/2018 2:12:40 AM

1 Answers

Prakash nidhi Verma
Prakash nidhi Verma

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