django

How to filter an item in one queryset from appearing in another queryset in django

How to filter an item in one queryset from appearing in another queryset in django Question: I have a Django view where I am getting the first queryset of ‘top_posts’ by just fetching all the Posts from database and cutting it in the first four. Within the same view, I want to get "politics_posts" by …

Total answers: 1

Django HttpResponseRedirect() doesn't work – it doesn't redirect to the page

Django HttpResponseRedirect() doesn't work – it doesn't redirect to the page Question: I was trying to implement the function listing(request, listId) that when user wants to post a comment without login, it will be redirected to the login page. This is the code of my listing(request, listId) in views.py def listing(request, listId): if request.method == …

Total answers: 1

Problem in setting up Shopify RecurringApplicationCharge in Django App

Problem in setting up Shopify RecurringApplicationCharge in Django App Question: I am following app structure with reference to https://github.com/Shopify/shopify_django_app repository. I am trying to set up billing for my app using shopify.RecurringApplicationCharge. @shop_login_required def buy_plan(request, id): plan = PlanTable.objects.get(id=id) context = {‘plans’: plan} charge = shopify.RecurringApplicationCharge() charge.name = plan.name charge.price = plan.price charge.test = True …

Total answers: 1

Error After Uninstall in Shopify App Using Django

Error After Uninstall in Shopify App Using Django Question: I am taking reference from https://github.com/Shopify/shopify_django_app repository to make a shopify app. The problem is that the app installs properly and works fine but the problem is that if we access App URL after it is uninstalled from shopify store, it returns the following error. I …

Total answers: 1

Static files won't load

Static files won't load Question: I`ve created a new Django project and ran into a problem with static images. So, apparently when i was connecting my css and javascript files with static it worked well, but when i tried to connect images they won’t load. here is my settings.py STATIC_URL = ‘/static/’ STATIC_ROOT = os.path.join(BASE_DIR, …

Total answers: 1

related_name parameter name conflict in django?

related_name parameter name conflict in django? Question: i have a query regarding "related_name" parameter (used while establishing a relationship between models) suppose i assign the value to related_name= "x" then, it sets the given value to reverse relation manager name ex- parent_model_object.x.all() it sets given name to parent model while filtering objects. ex – child_model.objects.filter(x__name …

Total answers: 1

Django Template how to get the value of a model through the OneToOneField

Django Template how to get the value of a model through the OneToOneField Question: In my Django App i have Two Models and the User model from django.contrib.auth.models from django.contrib.auth.models import User class Room(models.Model): host = models.ForeignKey(User, on_delete=models.CASCADE, null=True) topic = models.ForeignKey(Topic, on_delete=models.SET_NULL, null=True) name = models.CharField(max_length=200) description = models.TextField(null = True, blank = True) …

Total answers: 2

Link from Django Model's "absolute url" to its admin page

Link from Django Model's "absolute url" to its admin page Question: According to the docs, you can specify a get_absolute_url in your Django Model for a "View on site" button to show up on Django Admin. However, how would you do the opposite? A link on the above defined "absolute url" that takes you to …

Total answers: 1