Handling Ajax request in Django

Total Post:113

Points:791
 165  View(s)
Ratings:
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. Post:140

    Points:984
    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)

    Migration:

    $ 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 
    admin.site.register(Post) 
    admin.site.register(Like)

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!