How to track and manage pages a user visits in Django (History App).

Поделиться
HTML-код
  • Опубликовано: 10 сен 2024
  • Learn how to track and manage the pages a user views in your django project.
    Data is becoming an integral part in building modern systems and applications. This type of data can be used to create Recommender Systems using machine learning.
    I urge you to think of different types of data you could collect (remember to tell your users that you collect some data in the EUA) to enhance your user experience.
    We would be the using the contentype app from django to achieve this.
    Source code: github.com/fle...
    Link to my previous tutorial: • Prevent Multiple Devic...
    Here's a link to the contenttypes documentation: docs.djangopro...

Комментарии • 40

  • @nabeelalawadhi6283
    @nabeelalawadhi6283 4 года назад

    Thank you so much. Very clear tutorial

    • @fleepgeek
      @fleepgeek  4 года назад

      I'm glad you liked it

  • @johnandrew721
    @johnandrew721 5 лет назад +1

    The video on preventing multiple logins was a success!! @Emmanuel Okiche.. So, you were saying?? About tracking how many times a visitor has bought something from my site and to notify him/her after, say, 5 transactions, if he/she wants to be a permanent member.

  • @shobabestan6453
    @shobabestan6453 11 месяцев назад

    How did you make history app?

  • @johnandrew721
    @johnandrew721 5 лет назад +1

    @Emmanuel Okiche, does this mean I have to build a History App first and only then will I be able to make use of recommendations and suggestions using Machine Learning?

    • @fleepgeek
      @fleepgeek  5 лет назад +1

      No. You must not build a history app first. There are different ways to achieve this but most importantly, you have to feed your recommendation system some data for it to give recommendations. This data could be stored could be product ids stored somewhere maybe in a session, localstorage or in the db just like the history app.

  • @michaelarthurholloway9539
    @michaelarthurholloway9539 2 года назад

    Genuine question: why use Signals and custom Mixins for this example? Instead of importing the custom mixin across apps, you could just import the History model itself, and create instances of it as needed inside the get_object() method of your class-based views. This way, you don't need to use Signals (which are arguably problematic, anyway) and you also don't need to create a custom Mixin... Seems easier / cleaner to me, unless I'm missing something? The only 'required' thing here is ContentTypes + Generic ForeignKey; the rest seems more complex than actually necessary, unless you are specifically avoiding importing the History model into your other apps for some reason (it wouldn't be a circular import, since the History model doesn't import any other models, the whole point being that its relations will be 'generic'....)

    • @fleepgeek
      @fleepgeek  2 года назад +1

      Thanks for the question.
      My tutorial showed you one way of the doing it.
      Your comment shows another way of doing it.
      I prefer my method and i have no issues with signals.
      Also, we think differently and this is what i came up with.
      Thanks for the comment.
      I'm glad the video made you think of other ways you could achieve this.
      All the best :]

  • @cmj3153
    @cmj3153 3 года назад

    hi i am getting error
    in blog detail page when user not logged in
    TypeError at /blog/What is Lorem Ipsum
    'AnonymousUser' object is not iterable
    how to avoid this?

    • @fleepgeek
      @fleepgeek  3 года назад +1

      At 16:16 i added a check in the mixin for authenticated users so you shouldn't get that error.
      Try cross check your code.

  • @isaacbamidele9899
    @isaacbamidele9899 5 лет назад

    Thank you so much Emmanuel

    • @fleepgeek
      @fleepgeek  5 лет назад

      You're welcome. Don't forget to share and subscribe. More django tutorials coming soon.

  • @thebestandweirdthings1660
    @thebestandweirdthings1660 3 года назад

    Nice job!

    • @fleepgeek
      @fleepgeek  3 года назад

      Thanks!
      I'm glad you liked it

  • @sudipbala9647
    @sudipbala9647 4 года назад

    can i use this to keep track of data edited in a model as record to view no. of times edited and also the previos state after editing?

    • @fleepgeek
      @fleepgeek  4 года назад

      Hmmm...you can use some of the logic to store the num of times edited but a simpler way would be to add a field to the model that tracks th e edit count ans increment it whenever the data changes.
      i think the Django admin keeps track of the previous state.
      The previous state logic would be something like making a post model something like a category model.
      So every new edit is a new insert into the post group.
      So the edit count would be total post in the category - 1
      Check to confirm if Django admin does this.

  • @johnandrew721
    @johnandrew721 5 лет назад +1

    Could you make a tutorial on how to track the number of times an IP address has visited my site? Is there a plugin for this or do I have to create a Python file that manually does this then passes data as a dictionary to the views? The idea in mind is to prompt the user if they wanna be a permanent member, after the user has, say, bought several items from my site.

    • @fleepgeek
      @fleepgeek  5 лет назад

      My tutorial on preventing multiple user login could give you an idea on how to achieve this.
      The main idea is to have a model that stores the ip then you use a middleware to check if the current ip is in your db then increment the count.
      Just checkout the tutorial. I believe it would be helpful for this.
      All the best

    • @johnandrew721
      @johnandrew721 5 лет назад +1

      @@fleepgeek Thanks bro. I've already downloaded it and will watch it as soon as I'm done with Django Auth customization. I'll give you the feedback!

    • @johnandrew721
      @johnandrew721 5 лет назад

      @@fleepgeek Okay, now it's time to put this to the test. It totally makes sense now that I've seen the video on Preventing Multiple Device Login.

  • @moslihtaha-yassine4211
    @moslihtaha-yassine4211 3 года назад

    how could I track ListView using mixins like what you do in this tuto and it is a great tuto. and there is a way tou get same result using views based on functions?

    • @fleepgeek
      @fleepgeek  3 года назад

      Maybe decorators could do it but i haven't tried it out.

  • @saedetohidi1847
    @saedetohidi1847 3 года назад

    how i can use it with function base view?

    • @fleepgeek
      @fleepgeek  3 года назад

      You could use decoratiors instead of mixins.

  • @vickytuite8261
    @vickytuite8261 2 года назад

    Please use larger fonts. It is really hard to read. I'm not a fan of dark mode, but it would be better if the fonts were larger.

    • @fleepgeek
      @fleepgeek  2 года назад

      Thanks for the feedback. Would work on that :]

  • @milamenda8511
    @milamenda8511 5 лет назад

    @Emmanuel Okiche Thanks for this tutorial it really helped me a lot on a very important project. However, I am facing a problem. I am able to see the History page on admin, but it keeps remaining empty. You included ObjectViewMixin on Post Detail View. However my project’s views are all FBV and I am not able to change them because of the concept of the website. Could you please help me to solve this problem? How could I make this tutorial work on my FBV? Thanks a lot!

    • @fleepgeek
      @fleepgeek  5 лет назад

      I'm glad you found it helpful.
      You could use a decorator instead of a mixin to achieve the same effect using a FBV.
      Just study how i implementated the mixin and use the same concept for the decorator.

    • @fleepgeek
      @fleepgeek  5 лет назад

      Secondly, a CBV can always replace a FBV no mattet the concept of the site.
      You just have to dig deep and understand how CBV works.
      I have a CBV course on my channel.
      All the best

  • @iramshahzadi4233
    @iramshahzadi4233 4 года назад

    code is not working, no records r showing in history...:(

    • @fleepgeek
      @fleepgeek  4 года назад

      Code is working, records r showing in history...lol
      Okay seriously, you're might be doing something wrong.
      Did you follow the video step by step?

    • @iramshahzadi4233
      @iramshahzadi4233 4 года назад

      @@fleepgeek no, i run the downloaded code as it is. Sir can uh suggest the possible mistake , that i have made.

    • @fleepgeek
      @fleepgeek  4 года назад +1

      @@iramshahzadi4233 yes of course. I'm here to help.
      The mistake you made was refusing to watch the video and follow step by step.

  • @medinimedini7168
    @medinimedini7168 5 лет назад +1

    source code please

    • @fleepgeek
      @fleepgeek  5 лет назад

      github.com/fleepgeek/django-history-app