How to use django-siteflags to bookmark site objects?How to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How can I safely create a nested directory?Django foreign key access in save() functionHow do I sort a dictionary by value?Does Django scale?Determine the type of an object?How do I list all files of a directory?differentiate null=True, blank=True in django

When does order matter in probability?

What is the purpose of the rotating plate in front of the lock?

Python reimplementation of Lost In Space by Tim Hartnell

Dynamic Picklist Value Retrieval

Do aarakocra have arms as well as wings?

How many attacks exactly do I get combining Dual Wielder feat with Two-Weapon Fighting style?

k times Fold with 3 changing extra variables

Is there some sort of French saying for "a person's signature move"?

Statistical closeness implies computational indistinguishability

Bit floating sequence

What is the delta-v required to get a mass in Earth orbit into the sun using a SINGLE transfer?

Passport - tiny rip on the edge of my passport page

How do I write a vertically-stacked definition of a sequence?

Why are some hotels asking you to book through Booking.com instead of matching the price at the front desk?

Is mountain bike good for long distances?

Why are UK MPs allowed to abstain (but it counts as a no)?

How to make a pipe-divided tuple?

Compiler optimization of bitwise not operation

More than three domains hosted on the same IP address

Word for something that used to be popular but not anymore

Did "Dirty Harry" feel lucky?

How strong is aircraft-grade spruce?

Laptop failure due to constant fluctuation of AC frequency and voltage

Why can't some airports handle heavy aircraft while others do it easily (same runway length)?



How to use django-siteflags to bookmark site objects?


How to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?How can I safely create a nested directory?Django foreign key access in save() functionHow do I sort a dictionary by value?Does Django scale?Determine the type of an object?How do I list all files of a directory?differentiate null=True, blank=True in django






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















The package is here and here but I cannot get it to work.



Here is my models.py file



class Video(models.Model, ModelWithFlag):
name = models.CharField(max_length=255)

file = models.FileField(upload_to="static/videos/", null=True, verbose_name="", unique=True)

def __str__(self):
return self.name


And the views.py file



def user_bookmarked_video(request, bookmark_id):
video = get_object_or_404(Video, pk=bookmark_id)
# Now a user adds this article to his bookmarks.

video.set_flag(request.user)


How should the urls.py and .html look like ?










share|improve this question
































    0















    The package is here and here but I cannot get it to work.



    Here is my models.py file



    class Video(models.Model, ModelWithFlag):
    name = models.CharField(max_length=255)

    file = models.FileField(upload_to="static/videos/", null=True, verbose_name="", unique=True)

    def __str__(self):
    return self.name


    And the views.py file



    def user_bookmarked_video(request, bookmark_id):
    video = get_object_or_404(Video, pk=bookmark_id)
    # Now a user adds this article to his bookmarks.

    video.set_flag(request.user)


    How should the urls.py and .html look like ?










    share|improve this question




























      0












      0








      0








      The package is here and here but I cannot get it to work.



      Here is my models.py file



      class Video(models.Model, ModelWithFlag):
      name = models.CharField(max_length=255)

      file = models.FileField(upload_to="static/videos/", null=True, verbose_name="", unique=True)

      def __str__(self):
      return self.name


      And the views.py file



      def user_bookmarked_video(request, bookmark_id):
      video = get_object_or_404(Video, pk=bookmark_id)
      # Now a user adds this article to his bookmarks.

      video.set_flag(request.user)


      How should the urls.py and .html look like ?










      share|improve this question
















      The package is here and here but I cannot get it to work.



      Here is my models.py file



      class Video(models.Model, ModelWithFlag):
      name = models.CharField(max_length=255)

      file = models.FileField(upload_to="static/videos/", null=True, verbose_name="", unique=True)

      def __str__(self):
      return self.name


      And the views.py file



      def user_bookmarked_video(request, bookmark_id):
      video = get_object_or_404(Video, pk=bookmark_id)
      # Now a user adds this article to his bookmarks.

      video.set_flag(request.user)


      How should the urls.py and .html look like ?







      python django django-models






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 31 at 4:12







      Matthew

















      asked Mar 28 at 6:12









      MatthewMatthew

      3504 silver badges20 bronze badges




      3504 silver badges20 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          1
















          The most of the question is not related to siteflags itself.



          See "Writing more views" to have an example of urls.py.
          For example, it might look like



          path('videos/<int:bookmark_id>/', views.user_bookmarked_video, name='videos_bookmarked'),


          However your bookmark_id is missleading, since it's a video ID, not a bookmark ID. Moreover your view is named user_bookmarked_video(), but it's not what it does — it just sets a flag (bookmark) on some video object.



          If you plan to use this view just to set a bookmark you'd better name it like set_video_bookmark() and redirect at the end of the function, instead of html rendering.



          If your intention was to show all bookmarked videos for current user then there's no need to accept bookmark_id argument for your view and flagging on every view call.



          Your html may look like as you want, depending on what do you want to see.
          For example:



          <h1> video.name </h1>





          share|improve this answer

























          • you are absoultey correct, it is not related to siteflags. But I could not find a single example of siteflags on the internet utilizing the package fully. Therefore, it would have been cool to see one fully working example from A to Z showing your hard-work floirsh :) Thanks for understanding.

            – Matthew
            Mar 29 at 1:48











          • @Matthew I see. Since siteflags is generic you may use it in different scenarios. If you describe what do you want to achieve, we could improve the app docs with useful examples.

            – idle sign
            Mar 29 at 1:53












          • can you please check the views.py, I cannpt seem to remove or set the flag correctly.

            – Matthew
            Mar 29 at 2:27











          • Please do not edit your questions, if such edits change them in a substantial way, making the answers not relevant. If you have questions use the issue you've created — github.com/idlesign/django-siteflags/issues/5, not SO. I've updated the docs, hope it'll help: django-siteflags.readthedocs.io/en/latest/quickstart.html

            – idle sign
            Mar 31 at 3:52












          • my apologies, I will roll back the question and post on the Github instead.

            – Matthew
            Mar 31 at 3:58










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55391168%2fhow-to-use-django-siteflags-to-bookmark-site-objects%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1
















          The most of the question is not related to siteflags itself.



          See "Writing more views" to have an example of urls.py.
          For example, it might look like



          path('videos/<int:bookmark_id>/', views.user_bookmarked_video, name='videos_bookmarked'),


          However your bookmark_id is missleading, since it's a video ID, not a bookmark ID. Moreover your view is named user_bookmarked_video(), but it's not what it does — it just sets a flag (bookmark) on some video object.



          If you plan to use this view just to set a bookmark you'd better name it like set_video_bookmark() and redirect at the end of the function, instead of html rendering.



          If your intention was to show all bookmarked videos for current user then there's no need to accept bookmark_id argument for your view and flagging on every view call.



          Your html may look like as you want, depending on what do you want to see.
          For example:



          <h1> video.name </h1>





          share|improve this answer

























          • you are absoultey correct, it is not related to siteflags. But I could not find a single example of siteflags on the internet utilizing the package fully. Therefore, it would have been cool to see one fully working example from A to Z showing your hard-work floirsh :) Thanks for understanding.

            – Matthew
            Mar 29 at 1:48











          • @Matthew I see. Since siteflags is generic you may use it in different scenarios. If you describe what do you want to achieve, we could improve the app docs with useful examples.

            – idle sign
            Mar 29 at 1:53












          • can you please check the views.py, I cannpt seem to remove or set the flag correctly.

            – Matthew
            Mar 29 at 2:27











          • Please do not edit your questions, if such edits change them in a substantial way, making the answers not relevant. If you have questions use the issue you've created — github.com/idlesign/django-siteflags/issues/5, not SO. I've updated the docs, hope it'll help: django-siteflags.readthedocs.io/en/latest/quickstart.html

            – idle sign
            Mar 31 at 3:52












          • my apologies, I will roll back the question and post on the Github instead.

            – Matthew
            Mar 31 at 3:58















          1
















          The most of the question is not related to siteflags itself.



          See "Writing more views" to have an example of urls.py.
          For example, it might look like



          path('videos/<int:bookmark_id>/', views.user_bookmarked_video, name='videos_bookmarked'),


          However your bookmark_id is missleading, since it's a video ID, not a bookmark ID. Moreover your view is named user_bookmarked_video(), but it's not what it does — it just sets a flag (bookmark) on some video object.



          If you plan to use this view just to set a bookmark you'd better name it like set_video_bookmark() and redirect at the end of the function, instead of html rendering.



          If your intention was to show all bookmarked videos for current user then there's no need to accept bookmark_id argument for your view and flagging on every view call.



          Your html may look like as you want, depending on what do you want to see.
          For example:



          <h1> video.name </h1>





          share|improve this answer

























          • you are absoultey correct, it is not related to siteflags. But I could not find a single example of siteflags on the internet utilizing the package fully. Therefore, it would have been cool to see one fully working example from A to Z showing your hard-work floirsh :) Thanks for understanding.

            – Matthew
            Mar 29 at 1:48











          • @Matthew I see. Since siteflags is generic you may use it in different scenarios. If you describe what do you want to achieve, we could improve the app docs with useful examples.

            – idle sign
            Mar 29 at 1:53












          • can you please check the views.py, I cannpt seem to remove or set the flag correctly.

            – Matthew
            Mar 29 at 2:27











          • Please do not edit your questions, if such edits change them in a substantial way, making the answers not relevant. If you have questions use the issue you've created — github.com/idlesign/django-siteflags/issues/5, not SO. I've updated the docs, hope it'll help: django-siteflags.readthedocs.io/en/latest/quickstart.html

            – idle sign
            Mar 31 at 3:52












          • my apologies, I will roll back the question and post on the Github instead.

            – Matthew
            Mar 31 at 3:58













          1














          1










          1









          The most of the question is not related to siteflags itself.



          See "Writing more views" to have an example of urls.py.
          For example, it might look like



          path('videos/<int:bookmark_id>/', views.user_bookmarked_video, name='videos_bookmarked'),


          However your bookmark_id is missleading, since it's a video ID, not a bookmark ID. Moreover your view is named user_bookmarked_video(), but it's not what it does — it just sets a flag (bookmark) on some video object.



          If you plan to use this view just to set a bookmark you'd better name it like set_video_bookmark() and redirect at the end of the function, instead of html rendering.



          If your intention was to show all bookmarked videos for current user then there's no need to accept bookmark_id argument for your view and flagging on every view call.



          Your html may look like as you want, depending on what do you want to see.
          For example:



          <h1> video.name </h1>





          share|improve this answer













          The most of the question is not related to siteflags itself.



          See "Writing more views" to have an example of urls.py.
          For example, it might look like



          path('videos/<int:bookmark_id>/', views.user_bookmarked_video, name='videos_bookmarked'),


          However your bookmark_id is missleading, since it's a video ID, not a bookmark ID. Moreover your view is named user_bookmarked_video(), but it's not what it does — it just sets a flag (bookmark) on some video object.



          If you plan to use this view just to set a bookmark you'd better name it like set_video_bookmark() and redirect at the end of the function, instead of html rendering.



          If your intention was to show all bookmarked videos for current user then there's no need to accept bookmark_id argument for your view and flagging on every view call.



          Your html may look like as you want, depending on what do you want to see.
          For example:



          <h1> video.name </h1>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 29 at 1:42









          idle signidle sign

          8291 gold badge9 silver badges19 bronze badges




          8291 gold badge9 silver badges19 bronze badges















          • you are absoultey correct, it is not related to siteflags. But I could not find a single example of siteflags on the internet utilizing the package fully. Therefore, it would have been cool to see one fully working example from A to Z showing your hard-work floirsh :) Thanks for understanding.

            – Matthew
            Mar 29 at 1:48











          • @Matthew I see. Since siteflags is generic you may use it in different scenarios. If you describe what do you want to achieve, we could improve the app docs with useful examples.

            – idle sign
            Mar 29 at 1:53












          • can you please check the views.py, I cannpt seem to remove or set the flag correctly.

            – Matthew
            Mar 29 at 2:27











          • Please do not edit your questions, if such edits change them in a substantial way, making the answers not relevant. If you have questions use the issue you've created — github.com/idlesign/django-siteflags/issues/5, not SO. I've updated the docs, hope it'll help: django-siteflags.readthedocs.io/en/latest/quickstart.html

            – idle sign
            Mar 31 at 3:52












          • my apologies, I will roll back the question and post on the Github instead.

            – Matthew
            Mar 31 at 3:58

















          • you are absoultey correct, it is not related to siteflags. But I could not find a single example of siteflags on the internet utilizing the package fully. Therefore, it would have been cool to see one fully working example from A to Z showing your hard-work floirsh :) Thanks for understanding.

            – Matthew
            Mar 29 at 1:48











          • @Matthew I see. Since siteflags is generic you may use it in different scenarios. If you describe what do you want to achieve, we could improve the app docs with useful examples.

            – idle sign
            Mar 29 at 1:53












          • can you please check the views.py, I cannpt seem to remove or set the flag correctly.

            – Matthew
            Mar 29 at 2:27











          • Please do not edit your questions, if such edits change them in a substantial way, making the answers not relevant. If you have questions use the issue you've created — github.com/idlesign/django-siteflags/issues/5, not SO. I've updated the docs, hope it'll help: django-siteflags.readthedocs.io/en/latest/quickstart.html

            – idle sign
            Mar 31 at 3:52












          • my apologies, I will roll back the question and post on the Github instead.

            – Matthew
            Mar 31 at 3:58
















          you are absoultey correct, it is not related to siteflags. But I could not find a single example of siteflags on the internet utilizing the package fully. Therefore, it would have been cool to see one fully working example from A to Z showing your hard-work floirsh :) Thanks for understanding.

          – Matthew
          Mar 29 at 1:48





          you are absoultey correct, it is not related to siteflags. But I could not find a single example of siteflags on the internet utilizing the package fully. Therefore, it would have been cool to see one fully working example from A to Z showing your hard-work floirsh :) Thanks for understanding.

          – Matthew
          Mar 29 at 1:48













          @Matthew I see. Since siteflags is generic you may use it in different scenarios. If you describe what do you want to achieve, we could improve the app docs with useful examples.

          – idle sign
          Mar 29 at 1:53






          @Matthew I see. Since siteflags is generic you may use it in different scenarios. If you describe what do you want to achieve, we could improve the app docs with useful examples.

          – idle sign
          Mar 29 at 1:53














          can you please check the views.py, I cannpt seem to remove or set the flag correctly.

          – Matthew
          Mar 29 at 2:27





          can you please check the views.py, I cannpt seem to remove or set the flag correctly.

          – Matthew
          Mar 29 at 2:27













          Please do not edit your questions, if such edits change them in a substantial way, making the answers not relevant. If you have questions use the issue you've created — github.com/idlesign/django-siteflags/issues/5, not SO. I've updated the docs, hope it'll help: django-siteflags.readthedocs.io/en/latest/quickstart.html

          – idle sign
          Mar 31 at 3:52






          Please do not edit your questions, if such edits change them in a substantial way, making the answers not relevant. If you have questions use the issue you've created — github.com/idlesign/django-siteflags/issues/5, not SO. I've updated the docs, hope it'll help: django-siteflags.readthedocs.io/en/latest/quickstart.html

          – idle sign
          Mar 31 at 3:52














          my apologies, I will roll back the question and post on the Github instead.

          – Matthew
          Mar 31 at 3:58





          my apologies, I will roll back the question and post on the Github instead.

          – Matthew
          Mar 31 at 3:58








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55391168%2fhow-to-use-django-siteflags-to-bookmark-site-objects%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현