Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Critical Path Method
I am trying to write a code for finding the critical path. I referred to this Github code. However this code fails if there are two or more starting tasks i.e. two or more tasks that have 0 dependencies. I cannot think of a way to encounter this. Can someone please help. This is the example that I tried to execute: The code above shows is_Critial=True for all the tasks, whereas it should show False for both the Curtains tasks. -
How can i fix the importing module in python 3? [closed]
here I have a django project(videoservices) with tow apps(memberships,courses).in courses\models.py I can't import a class from memberships\models.py ,here is the error when I makemigrations courses: ModuleNotFoundError: No module named 'videoservices.memberships' part of the code of courses\models.py: from django.db import models from django.urls import reverse from videoservices.memberships.models import Membership from django.core.validators import MaxLengthValidator class Course(models.Model): slug = models.SlugField() title = models.CharField(max_length=120, validators=[MaxLengthValidator(120)]) description = models.TextField() allowd_memberships = models.ManyToManyField(Membership) def __str__(self): return self.title def get_absolute_url(self): return reverse("courses:detail", kwargs={"slug": self.slug}) @property def lessons(self): return self.lesson_set.all().order_by('position') part of memberships\models.py from django.db import models from django.conf import settings from django.db.models.signals import post_save import stripe stripe.api_key = settings.STRPE_SECRET_KEY # Create your models here. MEMBERSHIP_CHOICES = ( ('Enterprise', 'ent'), ('Professional', 'pro'), ('Free', 'free'), ) class Membership(models.Model): slug = models.SlugField() membership_type = models.CharField(choices=MEMBERSHIP_CHOICES, default='Free', max_length=40) price = models.IntegerField(default=15) stipe_plan_id = models.CharField(max_length=40) def __str__(self): return self.membership_type -
Load json data list in Django models
I'm tring to convert this json list to django models. but I'm confused. How can I solve this question: Json [ { "rank": 1, "employer": "Walmart", "employeesCount": 2300000, "medianSalary": 19177 }, { "rank": 2, "employer": "Amazon", "employeesCount": 566000, "medianSalary": 38466 } ] class Persons(models.Model): rank = models.PositiveIntegerField() employer = models.CharField(max_length=100) employeesCount = models.PositiveIntegerField() medianSalary = models.PositiveIntegerField() verbose_name = 'Person' verbose_name_plural = 'Person' -
social-auth create_user() missing 1 required positional argument: 'phone'
m trying to create a new user with Python Social Auth and my custom user model required a phone number but facebook does not allow it in the SOCIAL_AUTH FACEBOOK PROFILE EXTRA_PARAMS how can i pass a default parameter to avoid this error or just use the id as the phone number or any solution to work around this problem models.py class MyAccountManager(BaseUserManager): def create_user(self, email, username, phone, password=None): if not email: raise ValueError("Users must have an email address") if not username: raise ValueError("Users must have an username") if not phone: raise ValueError("Users must have a phone number") user = self.model( email=self.normalize_email(email), username=username, phone=phone ) user.set_password(password) user.save(using=self._db) return user def create_superuser(self,email, username, phone, password): user = self.create_user( email=self.normalize_email(email), username=username, phone=phone, password=password ) user.is_admin = True user.is_staff = True user.is_superuser = True user.is_active = True user.save(using=self._db) return user class Account(AbstractBaseUser): email = models.EmailField(verbose_name="email",max_length=60, unique=True,) username = models.CharField(max_length=60,unique=True) phone = models.CharField(max_length=60,unique=True) date_joined = models.DateTimeField(verbose_name="date joined",auto_now_add=True) last_login = models.DateTimeField(verbose_name="last login",auto_now=True) is_admin = models.BooleanField(default=False) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) is_superuser = models.BooleanField(default=False) email_confirmed = models.BooleanField(default=False) USERNAME_FIELD = 'username' REQUIRED_FIELDS = ['email','phone'] objects = MyAccountManager() def __str__(self): return self.username def has_perm(self, perm, obj=None): return self.is_admin def has_module_perms(self, app_label): return True settings.py SOCIAL_AUTH_FACEBOOK_KEY = 'XXXXXXXXXX' … -
Compile CakePHP project as shared library
Recently I was asked to find a solution on how to obfuscate the source code of an application developed in Django. After searching for a while, I finally found a good way to obfuscate the source code by compiling it in C as a shared library. For that I managed to use Cython, which converted my python files to .so files. After deleting all python files and remaining only the .so files, I was still able to run the app correctly, and my code wasn't understandable by humans as it was compiled. Now, the fact is that I want to do the same on a PHP project, especially with CakePHP. So I'm asking you if there was a compiler like Cython in PHP or how to proceed to have the same expected result. Thank you for the replies. Have a nice day ! -
Django: TypeError at /save_entry save_entry() missing 1 required positional argument: 'content'
I am can not figure out what is wrong with this code. I am using a form to pass an argument save_entry using action to save my new page and I am getting this that is missing 1 required positional argument: 'content'. What is wrong with 'content', there is no message about 'title', I can not see the problem, maybe because I became blind with this code, because I retyped everything, I read a lot of tutorials and I still can not see the problem. Could somebody help me please? > def save_entry(title, content): > """ > Saves an encyclopedia entry, given its title and Markdown > content. If an existing entry with the same title already exists, > it is replaced. > """ > filename = f"entries/{title}.md" > if default_storage.exists(filename): > default_storage.delete(filename) > default_storage.save(filename, ContentFile(content)) in view def create(request): if request.method == "POST": form = NewEntryForm(request.POST) if form.is_valid(): title = form.cleaned_data["title"] content = form.cleaned_data["content"] util.save_entry(title,content) return HttpResponseRedirect(reverse("encyclopedia/create.html")) else: return render(request, "encyclopedia/create.html",{"form": form }) else: return render(request, "encyclopedia/create.html",{"form": NewEntryForm() }) and my form in HTML page <form action="{% url 'save_entry' %}" method="post"> {% csrf_token %} <input type="text" name="title" placeholder="Title"> <br><br> <textarea name="content" placeholder="Content"> </textarea><br> <input type="submit"> </form> -
Django Admin Imagefield with image display , image upload and image url edit functionality
I was working in django admin and some of the media files are there in my media directory but some url are not correct in database . I can't use upload feature because there are more then 10k images hence difficulty to find and upload. But the local folder image url is known. I need to add functionality where anyone in my team can edit image by changing url from django admin and upload functionality with image display feature -
filter objects in range of value like id - django
i want filter objects which are in range of value in django for example: array_id = [1,2,3,4] i want get objects which are in [1,2,3,4] in laravel i use this code : $orders = Order::where('user_id',1)->get(); $array_id = array(); $i = 0; foreach($order as $orders){ $array_id[$i] = $order->id; $i++; } payments = Payment::whereIn('order_id',$array_id)->get(); i use whereIn() method in laravel. how can i write this code in django ? -
having a small authorization issue, please help me out (django)
i have signup as a test user myself and my account got activated, you can see this in below image... but when i try to login it says that my account is not active even tough it is active Here is my views.py file for signin function-> def signin(request): if request.user.is_authenticated: return redirect('index') else: if request.method == 'POST': username = request.POST.get('username') password = request.POST.get('password') user = authenticate(username=username, password=password) if user is not None and user.is_active: login(request, user) return HttpResponseRedirect(reverse('index')) else: return HttpResponse('Account is not active') else: return render(request, 'signin.html', {}) when i clicks submit and try to login it returns me HttpResponse('Account is not active'). please help me as i don't know where the issue is coming -
django create relation between 2 database entries
Apologies if the title is not accurate but I am fairly new in Django and I am still trying to understand the basics. I have create a model where I can create a server name. I have a second model where I create one or more interfaces to associated to each server. What I want is to connect one interface of one server to another interface of another server. I have a feeling it has something to do with ForeignKey but I would not know how to implement that. class Interface(models.Model): interface = models.CharField(max_length=20) hostname = models.ForeignKey(to='NetworkDevice', on_delete=models.CASCADE) def __str__(self): return self.interface class Meta(): ordering = ('hostname',) class NetworkDevice(models.Model): hostname = models.CharField(max_length=50, unique=True) class Meta(): ordering = ('hostname',) def __str__(self): -
Django - How to make anchors change HTML list
I have the following snippet of HTML: On my django webpage, i get a list that looks as follows: Each "Part" anchor corresponds with a Part object in Python. Now, I'd like to make it so that when the user clicks on "Part_2", the datapoints of that Part are shown just below it. On the image, the datapoints of the first part are shown within the nested list. I hard coded this. I looked into calling a python function with an argument from the template, but that is not possible. What would be an easy way to make this happen? -
Timestamp YYYY-MM-DDThh:mmTZD python
How can i get datetime in ISO 8601 date format (YYYY-MM-DDThh:mmTZD). Example 2019-02-26T09:30:46+03:00 I tried using from datetime import datetime d = datetime.now() d.isoformat() But the output is now correct '2020-07-29T15:47:46.974744' -
Django how to make a pivot table?
I'm having trouble making a pivot table of my data. The data I'm taking from the user is : Driver name, Date, The commission, The branch, and some others but those are the ones that i want to Make an pivot table of. so Here's the model that's gonna take the important fields. models.py class InvoiceRegistering(models.Model): driver_name = models.ForeignKey(Drivers, on_delete=models.SET(""), verbose_name="السائق") pub_date = models.DateField('التاريخ') # default=timezone.now the_car = models.ForeignKey(Cars, on_delete=models.SET(""), verbose_name="السيارة") city = models.ForeignKey(Cities, on_delete=models.SET(""), verbose_name="المدينة") branch = models.ForeignKey(Branches, on_delete=models.SET(""), verbose_name=" الفرع") the_representer = models.ForeignKey(Representers, on_delete=models.SET(""), verbose_name="المندوب") location = models.ForeignKey(Locations, on_delete=models.SET(""), verbose_name="اختر الموقع") # blank = True == required = False sort_ofBox = models.ForeignKey(SortOfBoxes, on_delete=models.SET(""), verbose_name="اختر الصنف") number_of_boxes = models.IntegerField(verbose_name="عدد الطبالي", default="") sar_4box = models.IntegerField(verbose_name="ريال \ طبلية", default="") receipt_num = models.IntegerField(verbose_name="رقم الايصال", default="") def commision(self): myvalue = ''.join(str(self.number_of_boxes * self.sar_4box)) return str(myvalue) commision.short_description = "العمولة" admin.py class InvoiceAdmin(ImportExportModelAdmin): def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None): response = super(InvoiceAdmin, self).render_change_form(request, context, add, change, form_url, obj) response.context_data['title'] = "تعديل" if response.context_data['object_id'] else "إضافة رد جديد" return response list_display = ( 'id', 'driver_name', 'pub_date', 'the_car', 'the_representer', 'branch', 'location', 'number_of_boxes', 'sar_4box', 'commision', 'sort_ofBox', 'receipt_num') list_filter = ('id', 'pub_date', 'driver_name', 'branch', 'the_car') search_fields = ( 'id', 'driver_name', 'pub_date', 'the_car', 'the_representer', 'branch', 'location', 'number_of_boxes', 'sar_4box', … -
How django gets values of serializer fields?
I can't figure out how and where Django gets the value of the field which value is another serializer. I need to get a place where something like FirstSerializer(data) happens for the following example: class FirstSerializer(ModelSerializer): ... class SecondSerializer(ModelSerializer): first = FirstSerializer() ... class ThirdSerializer(ModelSerializer): second = SecondSerializer() ... class TripleView(APIView): serializer_class = ThirdSerializer ... Any thoughts? -
Best way to store oauth2 access token globally in django app?
I'm using django as a backend for my project that integrates with an oauth2-app. I have been able to get the access token, but I'm kind of confused by how I should store it. I want it to be secret, but it should be accessible by the backend when the administrator or other users are making requests from the frontend => then to the backend (load external app access token) => then to the external app. I've tried storing it in the admin user-model, but then only the admin can access it (unless I get the admin user-model with every request? Seems kind of clunky) I've also tried storing it with os.environ, but as far as I can understand, these get cleared out when the server restarts. What would be the best way of implementing this? -
How to display emoji characters in PDF generated using xhtml2pdf in django?
I'm trying to convert HTML to PDF using xhtml2pdf but not able to properly render the emoji characters in the HTML they appear as black boxes. I have tried with different fonts but still the same issue. # -*- coding: utf-8 -*- import time import os from io import BytesIO from xhtml2pdf import pisa source = """<html> <head> <title>Doc title</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta charset="UTF-8"> </head> <style> @media print { @font-face { font-family: Helvetica; src: url("/absolute/path/to/Helvetica.ttf"); } } </style> <body> <p>🤓</p> </body> </html>""" def convert_html_to_pdf(source): pdf = BytesIO() pisaStatus = pisa.CreatePDF(BytesIO(source), pdf, encoding='utf-8') return pdf if __name__ == "__main__": pdf = convertHtmlToPdf(source) fd = open(os.path.join('test-%s.pdf' % time.time()), "w+b") fd.write(pdf.getvalue()) fd.close() -
Is there a way to concatenate a django object qeury from a template?
I have the following code: <table id="MyTable" class="highlight responsive-table" > <thead> <tr> {% with columns as columns %} {% for columns in columns %} <th class="th-sm">{{ columns }}</th> {% endfor %} {% endwith %} </tr> </thead> <tbody> {% for trans in transactions %} <tr> <td> {{ trans.transactionsequencenumber }}</td> <td> {{ trans.posid }}</td> <td> {{ trans.transactionnumber }}</td> </tr> {% endfor %} </table> which works for display static table data, but the idea is that the columns being iterated are being set via a user preferences model, so the table columns can change depending on the user, theres a possible 90+ columns to choose from, and here is where my issue lays. i can pseudo code below to help illustrate my goal: <table id="MyTable" class="highlight responsive-table" > <thead> <tr> {% with columns as columns %} {% for columns in columns %} <th class="th-sm">{{ columns }}</th> {% endfor %} {% endwith %} </tr> </thead> <tbody> {% for trans in transactions %} <tr> <td> {{ trans.{{columns}} }}</td> </tr> {% endfor %} I've tried simple string concatenation so far, but that simple prints the string to the table and not the object data, any help and/or guidance would be greatly apprecieted. be kind, this is … -
Django admin page raises the "Please correct the errors below” error without pointing to the field that causes it
I was able to successfully extended the user model. I can store the date into the database using forms. However, when I try to modify and save the field values from Django's admin page it show the "Please correct the errors below” error. But it doesn't shows where the error is. I have tried some of the solutions suggested here but I couldn't resolve the problem. BTW, I am using Mongodb and Djongo as my database. models.py class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) phone_no = PhoneNumberField(blank=True, null=True) country = CountryField(blank=True, null=True) admin.py from django.contrib import admin from django.contrib.auth.admin import UserAdmin as BaseUserAdmin from django.contrib.auth.models import User from register.models import Profile # to show the user profile in the django admin page class UserProfileInline(admin.StackedInline): model = Profile can_delete = False verbose_name_plural = "details" class UserAdmin(BaseUserAdmin): inlines = (UserProfileInline,) # to re-register UserAdmin admin.site.unregister(User) admin.site.register(User, UserAdmin) forms.py class UserForm(UserCreationForm): email = forms.EmailField() class Meta: model = User fields = ["username", "email", "password1", "password2"] class ProfileForm(forms.ModelForm): # gender = GenderField() country = CountryField(blank_label='(select country)').formfield() phone_no = PhoneNumberField(required=False) class Meta: model = Profile fields = ["phone_no", "country"] views.py def register(request): if request.method == "POST": user_form = UserForm(request.POST) profile_form = ProfileForm(request.POST) if user_form.is_valid() and profile_form.is_valid(): … -
Okta: error 400 in OIDC (application-initiated sign-in flow), no detail
My case is simple: I follow this Build a Single Sign-On (SSO) integration guide. I have set up a Web Application: Application type: Web Allowed grant types: Authorization Code, Implicit (Hybrid), Allow ID Token with implicit grant type Login initiated by: App only Login redirect URIs: http://192.168.31.198.xip.io:8000/advanced/accounts/proprietary/login/callback Initiate login URI: http://192.168.31.198.xip.io:8000/advanced/accounts/proprietary/login/?next=%2Fadvanced%2F After setting app Okta Web app and my Django application (using django-allauth package) I entered the "Initiate login URI" link into my browser (Chrome) and was redirected to https://dev-NNNNNN.okta.com/oauth2/v1/authorize?client_id=0xxxxxxxxxxx6&redirect_uri=http%3A%2F%2F192.168.31.198.xip.io%3A8000%2Fadvanced%2Faccounts%2Fproprietary%2Flogin%2Fcallback&scope=profile+email&response_type=code&state=ZkS3VVrjFlZq&nonce=a51729f8-af5 and got: 400 BAD REQUEST without any error detail information. I also constructed my /authorize URL like https://dev-NNNNNN.okta.com/oauth2/v1/authorize ?client_id=0xxxxxxxxxxxxxx6&redirect_uri=http%3A%2F%2F192.168.31.198.xip.io%3A8000%2Fadvanced%2Faccounts%2Fproprietary%2Flogin%2Fcallback&scope=openid&response_type=code&state=HHKCZq30druj&nonce=g5ly497e8ps I've also tried several different "scope" and "responce_type" arguments. Result was always the same. As suggested in the manual, I checked logs: system log on https://dev-NNNNN-admin.okta.com/dev/console application log under "View logs" link. I tried log queries like debugContext.debugData.requestId eq "XyFiqzKBJiHtjaP74xet@wAAANQ" (request Id that I got from the response header). I couldn't fiund any of the numerous bad requests I produced. My question is: how can I finally make this Okta Sign On page work? Or where I can find the source for the error 400? -
Embedded Field: must be instance of Model: <class 'django.db.models.base.Model'>
I tried to do a dummy seeder for the Entry model (extended from djongo model) with the object manager but I got an error while saving. Error: must be instance of Model: <class 'django.db.models.base.Model'>` Python script from djongo import models from django.core.management.base import BaseCommand, CommandError class Blog(models.Model): name = models.CharField(max_length=100) tagline = models.TextField() class Meta: abstract = True class Entry(models.Model): _id = models.ObjectIdField() blog = models.EmbeddedField( model_container=Blog ) headline = models.CharField(max_length=255) objects = models.DjongoManager() def build_dummy_entry(): e = Entry.objects.create( headline='h1', blog={ 'name': 'b1', 'tagline': 't1' }) g = Entry.objects.get(headline='h1') assert e == g e = Entry() e.blog = { 'name': 'b2', 'tagline': 't2' } e.headline = 'h2' e.save() class Command(BaseCommand): help='Create a preset dummy entry' def handle(self, *args, **options): try: build_dummy_entry() self.stdout.write(self.style.SUCCESS(f'Successfully created dummy blog')) except Exception as e: raise CommandError(f'{e}') Traceback CommandError: Value: {'name': 'b1', 'tagline': 't1'} must be instance of Model: <class 'django.db.models.base.Model'> -
Comparing fields from two models using foreign key.(for displaying correct product under correct category) using django
I have two models Category and Product. Here is models.py class Category(models.Model): type=models.CharField(max_length=30) def __str__(self): return self.type class Product(models.Model): category = models.ForeignKey(Category, on_delete = models.CASCADE) productid=models.CharField(max_length=30) name=models.CharField(max_length=30) disimage=models.ImageField(upload_to='pics') def __str__(self): return self.productid In my template I have two for loops the outer one that iterates category model and the other that iterates through products and i want to display the product only if the category.type is equal to the product category (for example if there is a type=Shirt in category then I want display a product under it only if it has type=Shirt ) Here is my HTML {% for i in types %} <div class="container"> <div class="row product-btn d-flex justify-content-end align-items-end"> <!-- Section Tittle --> <div class="col-xl-4 col-lg-5 col-md-5"> <div class="section-tittle mb-30" id="{{i.type}}"> <h2>{{i.type}}</h2> </div> </div> </div> <div class="tab-content" id="nav-tabContent"> <!-- card one --> <div class="tab-pane fade show active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab"> <div class="row"> {% for product in prods %} {% if i.type == product.category %} <div class="col-xl-4 col-lg-4 col-md-6"> <div class="single-product mb-60"> <div class="product-img"> <img src="{{product.disimage.url}}" alt=""> </div> <div class="product-caption"> <h4><a href="#" id="{{product.productid}}">{{product.name}}</a></h4> <div class="price"> <ul> <li>RS {{product.currentprice}}</li> <li class="discount">RS {{product.originalprice}}</li> <div> <a href="/category/singleproduct/{{product.productid}}" class="btn header-btn btn-outline-info">View</a> <a href="#" class="btn header-btn btn-outline-info">Add to Cart</a> </div> </ul> </div> </div> … -
Not printing nested serialiser in Django Rest framework?
models.py class PolicyPortalUser2020(User): created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) fname=models.TextField() lname=models.TextField() mobile_no=models.TextField() class Mentor2020(models.Model): pUser = models.ForeignKey(PolicyPortalUser2020, related_name='user', on_delete=models.CASCADE,null=True,blank=True) city = models.CharField(max_length = 40, null = True, blank = True) state = models.TextField() def __str__(self): return self.pUser.fname + ' ' + self.pUser.lname def full_name(self): return self.pUser.fname + ' ' + self.pUser.lname serializers.py class PolicyPortalUser2020Serializer(serializers.ModelSerializer): class Meta: model = PolicyPortalUser2020 fields = ['id', 'fname', 'lname'] class Mentor2020Serializer(serializers.ModelSerializer): user = PolicyPortalUser2020Serializer(many=True, read_only=True) class Meta: model = Mentor2020 fields = ['id', 'state', 'user'] output [ { "id": 27, "state": "asdasdas" }, { "id": 28, "state": "12121" }, { "id": 29, "state": "12121" }, { "id": 30, "state": "12121" }, { "id": 26, "state": "asdasdas" } ] Basically I am using nested serialiser in one of my project but I don't know why it is not giving me the desired output, There is no nested field I get as an output. Please help me to tackle this problem -
Invalid password or unknown hashing algorithm in Django-rest-framework
I created a custom user model making use of just the email and password field. I created the API serializer for the custom user model using the djangorestframework. It seems to send all the data (email and password) but doesn't hash the password. I tried out different solutions here but none seems to work. models.py from django.db import models from django.contrib.auth.models import (BaseUserManager, AbstractBaseUser) class UserManager(BaseUserManager): def create_user(self, email, password=None): # Creates and saves a User with the given email and password if not email: raise ValueError('User must have an email address') user = self.model(email=self.normalize_email(email),) user.set_password(password) user.save(using=self._db) return user def create_staffuser(self, email, password): # Creates and saves a staff User with the given email and password user = self.create_user(email, password=password) user.staff = True user.save(using=self._db) return user def create_superuser(self, email, password): # Creates and saves a superuser with the given email and password user = self.create_user(email, password=password) user.staff = True user.admin = True user.save(using=self._db) return user class User(AbstractBaseUser): email = models.EmailField( verbose_name='email address', max_length=255, unique=True) active = models.BooleanField(default=True) staff = models.BooleanField(default=False) admin = models.BooleanField(default=False) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] # Email and password are required by default def get_full_name(self): # The user is identified by their email address return self.email … -
(django) can't make changes to database other than creating new objects
I created a todo app following Dennis Ivy's tutorial his code works fine but mine does not.. whenever i update task it creates new object. Not even able to delete object by delete button that i added .. I think its not able to make changes to database other than creating new objects..help please def index(request): task = Task.objects.all().order_by('- created_on') form= TaskForm() if request.method=='POST': form= TaskForm(request.POST) if form.is_valid(): form.save() return redirect ('/') return render(request('task/list.html',{'task':task,'form':form}) def update_task(request,pk): task =Task.objects.get(id=pk) form= TaskForm(instance= task) if request.method=='POST': form= TaskForm(request.POST,instance=task) if form.is_valid(): form.save() return redirect('/') return render(request,'task/update_task.html', {'form': form}) -
rendering a template using ajax in django-oscar
I am trying to customize how the default implementation of Oscar's add review functionality works on a product's detail page, so that instead of django reloading the detail template with the form(default implementation),i use ajax to render the template(with the add review form). Any better way of implementing this to achieve that effect will be appreciated. The default implementation is triggered using a link on the detail page/template like so: {% block content %} ...... <a href="{% url 'catalogue:reviews-add' product_slug=product.slug product_pk=product.id %}#addreview"> </a> ...... {% iffeature 'reviews' %} {% block product_review %} {% endblock product_review %} {% endiffeature %} {% endblock content %} In my implementation I just changed the anchor tag implementation in the detail page/template like so: {% block content %} ...... <a class='xx' product_slug="{{product.slug}}" product_pk="{{ product.id }}" href="#addreview"> </a> ...... {% iffeature 'reviews' %} {% block product_review %} {% endblock product_review %} {% endiffeature %} {% endblock content %} In the default implementation, the product_review form template extends the detail template like so: {% extends "oscar/catalogue/detail.html" %} <div id="addreview" class="review_add" > <form id="add_review_form" method="post" action="#addreview"> ................... </form> </div> The default URLs config for reviews(which lives in the catalogue app as a package) is appended to the catalogue's …