Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to add a variable which pick up certain value dependent on other variable present in view.py in django
I want to make form2 variable in which we have to add condition that pick institute name from register table where institute code is equal to institute code present in form 1 variable and pass form2 in context so that it can be printed in template file. I have added code in view.py def view_eligibility_admin(request): form1 = Eligibility_Check.objects.all() form2 = {} # Initialize an empty dictionary to store institute names for item in form1: institute_code = item.Centre_code try: register_entry = Register.objects.get(institute_code=institute_code) institute_name = register_entry.institute_name form2[institute_code] = institute_name except Register.DoesNotExist: # Handle the case where the institute code doesn't exist in the Register model form2[institute_code] = "N/A" context = {'form1': form1, 'form2': form2} return render(request, 'view_eligibiity_admin.html', context) In my template.py I have used it like this. <tr> <td>{{ forloop.counter }}</td> <td>{{ i.Centre_code }} / {{ i.Serial_number }}</td> <td>{{ i.Date_of_survey }}</td> <td>{{ i.District }}</td> <td>{{ i.Voter_id }}</td> <td>{{ i.Ec }}</td> <td>{{ form2.item.institute_code }}</td> <td class="text-center"> <a class="btn btn-primary" href="{% url 'view_eligibility_pid' i.pk %}"><i class="fa fa-eye" aria-hidden="true"></i> </a> </td> </tr> {% endfor %}``` But i am getting blank value in place of institute name. -
Is it possible to get the all values of foreign key instead of id?
Is it possible to get all the values of foreign key instead of id? class WishlistSerializer(serializers.ModelSerializer): def to_representation(self, instance): rep = super(WishlistSerializer, self).to_representation(instance) rep['product'] = instance.product.name return rep -
Where can I host a Django website for free?
Guy's Is there any free hosting services available for python django application. I think AWS, Google Cloud and Azure are not completely free. Thanks in advance 😃 I had been using heroku for years but now heroku is changed their policy. -
Tastypie Django full hydrate returns an error when joining the protected Resource
I created here a small example to explain my problem for which I haven't find a solution on the web. I am using Django and Tastypie to implement a REST API. I have "MyUserResource" which is a descendant of Django's User model and this resource is protected with StaffAuthorization. Then I have "CommentsResource" which should be opened for Anonymous users as well. Now, my problem lies in the fact that during running Tastypie's full_hydrate operation within obj_create, Tastypie is trying to make a join on user table. That means that in case anonymous users are trying to fetch comments, the API returns Unauthorized error. For now I implement it to "open" MyUserResource" by using Authorization and checking within obj_create, obj_update and obj_delete if the user is staff or a superuser. But I wouldn't want that everyone is able to retrieve the list of users as well. Is it possible to protect User resource and still allow joins during hydration process? I still haven't tried to implement "my" obj_get function and there check if users are staff or superusers and for other types of user I might remove sensitive data? Here is the sample code, first Django models and then Tastypie … -
How to setup CSRF Trusted Origina domain on same server as Django docker app in plesk?
I currently have a django app installed on a Docker in Plesk. Id like to keep everything to basically localhost for any domain that I have hosted on the same server. The only thing that works is adding the actual domain https://subdomain.domain.com. Its not ideal to do this as Id like to use the Django app on multiple domains/subdomains that I have hosted on my plesk server. I tried the '*' option and it does not work either. Been breaking my head all day testing this and I cant seem to get it to work. :/ The error I receive is this in docker: django.security.csrf log Forbidden (Origin checking failed - https://subdomain.domain.com does not match any trusted origins.) Any help with experienced docker folks out there? I've tried https://localhost, https://127.0.0.1, the docker ip https://172.17.0.3 and a bunch of other options and nothing works. -
Updating celery workers code in production without distrupting currently running tasks?
I have a program that runs some tasks in the background, which can run for hours. I will have many tasks running at many different times. I cannot really kill the tasks, because the user is aspecting these tasks to finish. The basic gist of it is I have a frontend which sends a request to the backend to start a task. This task will scrape some data, and do some other stuff with that data. It could take many hours and they are important to keep running. I have thought of maybe shutting down the tasks and keeping track of where they left of from and just continueing. This could work, but I couldn't figure out how to do this and I would rather not kill the tasks at all as it may be half way through scraping the data. My current thought has been to have two queues. One with the old tasks and one with the new ones. But I don't know how I would redirect all the future tasks to the new queue. I would like to have a way to do this that is easy and I can do many times. Does anyone know any … -
GET /static/css/style.css?after HTTP/1.1 404 1820
During python web development using django, the contents of static are not applied.. Is there a way? Below is the code BASE_DIR = Path(__file__).resolve().parent.parent STATICFILES_DIR = [ BASE_DIR / 'static', os.path.join(BASE_DIR, 'static'), os.path.join(BASE_DIR, 'static/css'), os.path.join(BASE_DIR, 'static/image'), os.path.join(BASE_DIR, 'static/javascript'), ] TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] STATIC_URL = '/static/' STATIC_URL = 'static/' results are the same, and at the same time <link rel="stylesheet" href="{% static '/css/style.css' %}?after" /> and other than ?after output the same error this is errors my tree It is a situation where the codes of css were applied temporarily using the style tag of html. -
Trying to develop a spatial dashboard [closed]
I have been assigned the responsibility of developing a spatial data catalog that dynamically displays the count of available datasets within specified geographical boundaries. The datasets, comprising both vector and raster data, will be hosted and served through GeoServer. As new data is uploaded, the dataset count displayed on the catalog will automatically update to reflect the current total. I am keen to explore if anyone has undertaken a similar project and would be open to sharing insights or ideas to guide the successful execution of this initiative. I'm still research based on user-friendly, responsive, and interactive experience to users -
Django - Heroku postgres connection opens with each page refresh and does not close ever
I am using Django, heroku, websocket, AJAX, celery, postgres, consumer, asgi (uvicorn; tried Daphne also). My problem is that after just a page refresh, new postgres connection would be created, and it doesn't go away even after long inactivity. Soon with just refreshes my connections go over the top (20/20 on heroku). On local environment, no problem - connection does not add up no matter what I do. This happens only on heroku using heroku postgres (I'm using the default version). What I've tried: I've checked pg_stat_activity. The connections are related to the corresponding view code that queries certain data. for post in posts: temp_dict = defaultdict(list) recommendations_ordered = post.recommendations.all().order_by('created_at') ...and so on, including request.user. If I have 15 connections, most of them are from this -- same query. One from request.user. All idle. These don't exist when I run pg_stat_activity on local postgres. I've set my database settings as: if ENVIRONMENT == 'development': DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'redacted', 'USER': 'redacted', 'PASSWORD': 'redacted', 'HOST': 'localhost', 'PORT': '5432', } } else: DATABASES = { 'default': dj_database_url.config(default=os.environ.get('DATABASE_URL')) } DATABASES['default']['CONN_MAX_AGE'] = 0 DATABASES['default']['ATOMIC_REQUESTS'] = True I've added close.connection to the aforementioned view as well as tasks. Here's my procfile. … -
Django-Python = No data available in table [closed]
Why data is not showing up on my webpage/datatable?! The data is loading correctly in django-admin, but it´s not loading on the webpgage. Why data is not showing up on my webpage/datatable?! The data is loading correctly in django-admin, but it´s not loading on the webpgage. **ADMIN** from django.contrib import admin from App.models import Employee class EmployeeAdmin(admin.ModelAdmin): list_display = ['name', 'matricula', 'cargo', 'empresa'] list_filter = ['cargo', 'empresa'] list_display_links = ['name', 'matricula'] search_fields = ['name', 'empresa'] list_per_page = 50 admin.site.register(Employee, EmployeeAdmin) **MODELS** from django.db import models class Employee(models.Model): id = models.IntegerField(primary_key=True) name = models.CharField(max_length=100) matricula = models.CharField(max_length=15, blank=True) cargo = models.CharField(max_length=40) empresa = models.CharField(max_length=50) contrato = models.CharField(max_length=15) prefixo = models.CharField(max_length=10) dependencia = models.CharField(max_length=40) andar = models.CharField(max_length=5) bloco = models.CharField(max_length=5) edificio = models.CharField(max_length=30) cracha = models.CharField(max_length=10) def __str__(self): return self.name **VIEWS** from django.shortcuts import render from .models import Employee from django.http import HttpResponseRedirect from django.contrib import messages def home(request): employee_list = Employee.objects.all() return render(request, 'home.html', {"employees":employee_list}) def add_employee(request): if request.method=="POST": if request.POST.get('name') \ and request.POST.get('matricula') \ and request.POST.get('cargo') \ and request.POST.get('empresa') \ and request.POST.get('contrato') \ and request.POST.get('prefixo') \ and request.POST.get('dependencia') \ and request.POST.get('andar') \ and request.POST.get('bloco') \ and request.POST.get('edificio') \ or request.POST.get('cracha'): employee = Employee() employee.name = request.POST.get('name') employee.matricula = request.POST.get('matricula') employee.cargo … -
How to update context in Django-CMS
I am trying add my apps' queryset of my ListView in context of my apphook, but i could not get the queryset. I have created two models my ServicePLuginModel and Service model. class ServicePluginModel(CMSPlugin): title = models.CharField(_('title'), blank=True, help_text='Service Widget', max_length=64, ) class Service(CMSPlugin): # Attributes - Mandatory title = models.CharField(_('title'), max_length=200, blank=False) I have formed a ListView: class ServiceListView(ListView): model = Service queryset = Service.objects.all() def get_context_data(self, **kwargs): context = super(ServiceListView).get_context_data(**kwargs) queryset = Service.objects.all() context["now"] = timezone.now() context.update({'object_list': queryset}) context.update(kwargs) return super().get_context_data(**context) def render_to_response(self, context, **response_kwargs): # Shim to affect the CMS Toolbar only if self.request.toolbar and self.request.toolbar.edit_mode: menu = self.request.toolbar.get_or_create_menu('service-list-menu', 'Services') menu.add_break() return super(ServiceListView, self).render_to_response(context, **response_kwargs) urls.py app_name = 'services' urlpatterns = [ re_path('/', ServiceListView.as_view(), name='service-list'), re_path(r'^(?P<slug>[\w-]+)/?$', ServiceDetailView.as_view(), name='service_detail'), ] my cms_plugins.py @plugin_pool.register_plugin # register the plugin class ServicePluginPublisher(CMSPluginBase): model = ServicePluginModel # model where plugin data are saved module = _("Services") name = _("Service Plugin") # name of the plugin in the interface cache = False render_template = "services/service_list.html" def render(self, context, instance, placeholder): context.update({'instance': instance }) return context cms_apps.py: @apphook_pool.register # register the application class Servicesapphook(CMSApp): app_name = "services" name = "Services Application" def get_urls(self, page=None, language=None, **kwargs): return ["eldemmedya.apps.services.urls"] and my service_list.html: {% for service … -
Sending Mails from Django
So, I am trying to send email from Django. And I am getting errors. I have exhausted ChatGPT, Google. And finally I am here for help. I have followed so many tutorials but no matter what I do I get this error. [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond I have checked all my account details, password, other details 100's of time and all them should be what it is supposed to be. Here is my settings.py EMAIL_BACKEND= 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST= 'smtp.gmail.com' EMAIL_USE_TLS= True EMAIL_PORT= 587 EMAIL_HOST_USER= 'email@gmail.com' EMAIL_HOST_PASSWORD= 'app password generated by google' Here is the views.py from django.core.mail import send_mail from django.http import HttpResponse def simple_mail(request): send_mail( subject = 'test email 1', message = 'this is a test email', from_email = 'email@gmail.com', recipient_list = ['abc@gmail.com'], fail_silently=False, ) return HttpResponse('OK') The quota of free mails is not ended, well because I did not send any. Also, I am testing with localhost and internet is working. -
How to display the sum of all expenses in a chart
So I have a project of building a web app that tracks expenses and I am at a point where I have incorporated a chart but I also want to display the total sum of all expenses (which is dynamic) along side the chart but I am having a hard time figuring out how I should do it because I am kind of a beginner at this. Here is my js file for the chart: const renderChart = (data, labels) => { var ctx = document.getElementById('myChart').getContext('2d'); var myChart = new Chart(ctx, { type: 'doughnut', data: { labels: labels, datasets: [{ label: 'Monthly Expenses', data: data, }], }, options: { borderWidth: 10, borderRadius: 2, hoverBorderWidth: 0, plugins: { legend: { display: false }, }, }, }); } const getChartData=() => { console.log("fetching") fetch('expense_category_summary') .then((res)=>res.json()) .then((results)=>{ console.log("results", results); const category_data = results.expense_category_data; const [labels, data] = [ Object.keys(category_data), Object.values(category_data), ]; renderChart(data, labels); }); }; document.onload = getChartData(); Please help, Thank you in advance. -
How can i make many-to-many selected fields clickable as links in django admin panel
I'm working on a Django project, and I have an admin panel where I manage projects. In this project admin, I have a matched_pros field, which is a ManyToManyField related to the "main.User" model. I would like to make the selected fields in the matched_pros widget clickable, so that when I click on a user, it takes me to the user change page in the admin panel. matched_pros = models.ManyToManyField( "main.User", blank=True, related_name="matched_projects" ) exemple: many to many widget like in the picture when i click on client alger- c51 block it will take me to admin/main/pro/51/change I've attempted to add JavaScript code to make the users clickable, but I'm encountering issues with the code not functioning as expected, and i don't wanna complicate it using javascript and adding another file to the codebase -
NoReverseMatch at /reset-password-confirm/
Im trying to implement Reset Password View by using View class. Actually I faced with an error that is annoying. I have 3 Views for implementing: UserResetPasswordView Here User enters email and a request sends to his/her email UserResetPasswordRequestSentView Here shows a message that email has sent UserResetPasswordConfirm after 2 views above, this view let's the user change password. after redirecting user to UserResetPasswordRequestSentView, an email will be send to the user's email to access the user to change his/her password. so user will be redirect to UserResetPasswordConfirm that contains inputs for setting new password. This is my urls.py script: urlpatterns = [ path( route='reset-password', view=views.UserResetPasswordView.as_view(), name='reset', ), path( route='reset-password-request-sent', view=views.UserResetPasswordRequestSentView.as_view(), name='reset_sent', ), path( route='reset-password-confirm/<uidb64>/<token>', view=views.UserResetPasswordConfirm.as_view(), name='reset_confirm', ), ] this is UserResetPasswordView view: class UserResetPasswordView(View): def get(self, request: HttpRequest) -> HttpResponse: reset_password_form: ResetPasswordForm = ResetPasswordForm() return render( request=request, template_name='reset/reset.html', context={ 'reset_password_form': reset_password_form, }, ) def post(self, request: HttpRequest) -> Union[HttpResponseRedirect, HttpResponsePermanentRedirect, HttpResponse]: reset_password_form: ResetPasswordForm = ResetPasswordForm(request.POST or None) if (reset_password_form.is_valid()): cd = reset_password_form.cleaned_data user = get_user_model().objects.filter(Q(email=cd['email'])).first() if (user): subject = 'درخواست بازنشانی رمز ورود' message = render_to_string( template_name='email/template_reset_password.html', context={ 'user': user, 'domain': get_current_site(request=request).domain, 'uid': urlsafe_base64_encode(force_bytes(user.pk)), 'token': account_activation_token.make_token(user), 'protocol': 'https' if request.is_secure() else 'http', } ) send_mail( subject, message, 'settings.EMAIL_HOST_USER', [cd['email']], … -
The current path, api/v1/users, didn’t match any of these
I am experiencing this problem following a tutorial and I can't identify the error in my "SignUpView.vue" page. Tried changing to re_path and did not work. Not Found: /api/v1/users [15/Oct/2023 22:30:42] "POST /api/v1/users HTTP/1.1" 404 7646 Code: URLS.PY from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('api/v1/', include('djoser.urls')), path('api/v1/', include('djoser.urls.authtoken')) ] ERROR images: enter image description here enter image description here SignUpView.vue: if everything goes right. I'm supposed to get forward on localhost:8080/log-in methods: { submitFrom(e) { const formData = { username: this.username, password: this.password } axios .post("/api/v1/users", formData) .then(response => { console.log(response) this.$router.push('log-in') }) Please help me to solve this problem. Thanks in Advance. (..) -
Login form, django and react send data with post method but I cant get it in the server
I'm currently working on a web application using Django and React. I'm specifically facing an issue with handling form data. I have created a login form in my React application, and when I submit the form, I'm sending the form data to the server. However, on the server side (using Django), I'm having trouble receiving and processing the form data correctly. After submitting the form, I'm expecting to receive the form data on the server and perform some authentication logic. But when I try to access the received data on the server, I'm getting an empty dictionary instead of the expected form data. I have checked my client-side code and ensured that the form data is being sent correctly from the React application. However, I'm not sure why the server is not able to receive and process the data properly. I would greatly appreciate it if anyone could provide guidance or suggestions on how to properly handle and receive form data on the server side using Django. If you have any experience with Django and React and have encountered a similar issue before, your insights would be invaluable. Thank you in advance for any help or advice you can provide!" … -
SystemCheckError: System check identified some issues
ERRORS: auth.User.groups: (fields.E304) Reverse accessor 'Group.user_set' for 'auth.User.groups' clashes with reverse accessor for 'user.User.groups'. HINT: Add or change a related_name argument to the definition for 'auth.User.groups' or 'user.User.groups'. auth.User.user_permissions: (fields.E304) Reverse accessor 'Permission.user_set' for 'auth.User.user_permissions' clashes with reverse accessor for 'user.User.user_permissions'. HINT: Add or change a related_name argument to the definition for 'auth.User.user_permissions' or 'user.User.user_permissions'. user.User.groups: (fields.E304) Reverse accessor 'Group.user_set' for 'user.User.groups' clashes with reverse accessor for 'auth.User.groups'. HINT: Add or change a related_name argument to the definition for 'user.User.groups' or 'auth.User.groups'. user.User.user_permissions: (fields.E304) Reverse accessor 'Permission.user_set' for 'user.User.user_permissions' clashes with reverse accessor for 'auth.User.user_permissions'. HINT: Add or change a related_name argument to the definition for 'user.User.user_permissions' or 'auth.User.user_permissions'. my models class User(AbstractUser): name = models.CharField(max_length=50, verbose_name=('name')) profile = models.ImageField(upload_to='images/profile/', verbose_name=('profile')) phone = models.CharField( _('Phone'), max_length=11, unique=True, ) USERNAME_FIELD = 'phone' REQUIRED_FIELDS = [] objects = UserManager() username = None class Meta: app_label = 'user' verbose_name = _("user") verbose_name_plural = _(" users") def __str__(self) -> str: return str(self.phone) -
Fetching Data from PostgreSQL DB and displaying in form of pie chart in Django App
I am trying to fetch the data from Progress Table(Model) that is in my PostgreSQL database.. but it shows nothing where I want to show that data in form of pie-chart. the only error it gives is something like data is being not fetched from database: **settings.py: # Django database configuration DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', # Database engine (PostgreSQL in this case) 'NAME': 'ProgressDB', # Name of the database 'USER': 'postgres', 'PASSWORD': 'postgres', 'HOST': 'localhost', 'PORT': '', # Leave empty to use the default PostgreSQL port (usually 5432) } } MODEL.py: class Progress(models.Model): name = models.CharField(max_length=30) PercentageDownload = models.PositiveIntegerField() VIEW.py: # function to fetch data from progress table and use in Progress picharts on epidemiological_data page def pie_chart(request): labels = [] data = [] print("This is executed."); queryset = Progress.objects.all() for obj in queryset: labels.append(obj.name) data.append(obj.percentagedownload) print("This is executed."); return render(request, 'django_blog/epidemiological_data.html', { 'labels': labels, 'data': data, }) **HTML page: ** <div class="progressCircles"> <div id="container" style="width: 100%;"> {% for label in labels %} <div class="chart-container"> <canvas class="chart" id="pie-chart-{{ forloop.counter }}" style="width: 100%;"></canvas> <p class="chartText">{{ label }}</p> <!-- Display label below the chart --> </div> {% endfor %} </div> </div> <script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.3/dist/Chart.min.js"></script> <script> // Get the data as … -
What are best practices for implementing an admin panel?
I'm implementing an admin panel for my Django (API) & SvelteKit (frontend only) web application. What are the best practices for implementing an admin panel, security wise? I'm torn between multiple options right now: Setting up a different django project that accesses the database of my main project (kinda having trouble finding out how to apply my main projects' models and migrations to the panel though) Just adding (additional) admin panel functionality to my main django project Adding an admin panel to my SvelteKit frontend My main concern with no. 2 and 3 is that I'm not sure if it could be a security risk giving users the option to access even just the login panel to the admin interface if the application and the admin panel are both running within the same context, accessible to the user. If I'd go for the first option I'd restrict access to the django admin panel project entirely and make it only accessibly from within the intranet. Am I overthinking too much here and making a whole fuzz about nothing? What would "best practice" to safely implement an admin panel in an environment like mine? -
I am not being able to import views from an app
I am completely new to Django and I am following this freecodecamp tutorial: https://www.youtube.com/watch?v=F5mRW0jo-U4 I am trying to import views from an existing app, but the app is not being recognised So far I have done: python manage.py startapp pages to create the app called pages. Its apps.py file looks like this: enter image description here Add pages to settings.py: enter image description here Create the view in views.py (pages): enter image description here I am now trying to import the app in urls.py: enter image description here This is an overview of my directory: enter image description here I do not seem to have this issue with my other app called "products". Am I missing something essential here? Thanks in advance! -
When inheriting from two classes, I have functionality from only one
When inheriting from two classes, in the admin panel I only have the functionality of the class that comes first. For example, it will only show entity shift (Django MPTT) or only the "Load data" button (DjangoObjectActions). Is there any way to have both functionalities? My code: from django.contrib import admin from mptt.admin import MPTTModelAdmin from .models import Category, Image from django_object_actions import DjangoObjectActions, action from scripts.load_csv_to_db import run class CategoryAdmin(MPTTModelAdmin, DjangoObjectActions): @action(label='Load data') def load_data(self, request, queryset): run() changelist_actions = ('load_data', ) admin.site.register(Category, CategoryAdmin) admin.site.register(Image) Thank you. -
Why are tables not created during migration?
Authorization tables were created normally. When I try to create and apply a migration, it says that everything was successful. But there are no new tables in the database settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'start_page' ] file 0001_initial.py in folder migrations # Generated by Django 4.2.5 on 2023-10-15 14:17 from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Person', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=20)), ('age', models.IntegerField()), ], ), ] in console (.venv) C:\django-on-docker\app>python manage.py makemigrations start_page Migrations for 'start_page': start_page\migrations\0001_initial.py - Create model Person (.venv) C:\django-on-docker\app>python manage.py migrate start_page Operations to perform: Apply all migrations: start_page Running migrations: Applying start_page.0001_initial... OK but there is no new table in the database, there are only tables created for authorization And there is no new entry in the table django_migrations -
Lets say I have index.html page with a button and a H2 tag element. I want to update the H2 tag with the button text using django python when clicked
I have a button with text "startups" and a H2 element with no text. I want to update the H2 element with button text when I click on it. Iam able to get the text of the button using Ajax with POST request into views.py in django project. Iam trying to render the page with "return render(request, 'index.html', {'text':text})". Value of text is that button text. Iam able to print that value in console after clicking on that button. But iam not able to see that text in the html page for H2 tag. I thought it's because of not reloading the page after update. Please suggest me what to do for this issue. If possible it would be very helpful if u can give me some examples on this. ThankYou. Hoping for the resolution.!! I just need to update the text in html page once clicked on that button on the html page using django views.py -
Get the value of 'button.url'
Where does Wagtail get the value of 'url' in 'button.url' in 'home_page.html'? models.py: class HomePage(Page): button = models.ForeignKey( 'wagtailcore.Page', blank=True, null=True, related_name='+', help_text='Select an optional page to link to', on_delete=models.SET_NULL, ) button_text = models.CharField( max_length=50, default='Read More', blank=False, help_text='Button text', ) home_page.html: href="{{ page.button.url }}"