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;
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
add a comment |
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
add a comment |
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
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
python django django-models
edited Mar 31 at 4:12
Matthew
asked Mar 28 at 6:12
MatthewMatthew
3504 silver badges20 bronze badges
3504 silver badges20 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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>
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 theviews.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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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>
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 theviews.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
add a comment |
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>
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 theviews.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
add a comment |
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>
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>
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 theviews.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
add a comment |
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 theviews.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
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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