Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Is there a way to make inlines that obtains the foreignkey from a different field in the caller?
class Organization(admin.ModelAdmin): ... class Configuration(admin.ModelAdmin): organization = model.ForeignKey(Organization) team = model.ManyToManyField(Team) ... class Team(admin.ModelAdmin): organization = model.ForeignKey ... Is it possible to have an inline in Team to Configuration in a way that the organization field is already filled? As in with the inline in Team, the organization field is read-only since the Team object already has it in place (obviously this would only work with editing objects since adding a new team would not have the organization selected). I've tried using requests to modify the URL and prefill some fields in the configuration pop-up when it was just a foreignkey in Team, but that didn't work exactly like this scenario. Using an inline with this scenario just produced an error saying configuration has no foreignkey to Team. -
npm run dev " 'webpack' is not recognized as an internal or external command"
taking my first stab at using react frontend with a django backend. npm run dev works and renders the frontend on my mac but fails to on my windows pc I am running the same version of node & npm on both machines Have tried npm cache clean --force and reinstall npm, has previously when facing the white page issue on my mac. error code; > webpack --mode development --watch ./marketmaker/frontend/src/index.js --output ./marketmaker/frontend/static/frontend/main.js 'webpack' is not recognized as an internal or external command, operable program or batch file. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! fullstack-calc@1.0.0 dev: `webpack --mode development --watch ./marketmaker/frontend/src/index.js --output ./marketmaker/frontend/static/frontend/main.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the fullstack-calc@1.0.0 dev script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. -
Insert data from a modal form to DB
I'm trying to add some data to the DB from a modal form in django. After filling all the fields and click on submit it doesn't save on the DB. Here are the models, views and forms and the template. I think the problem it's on the views.py models.py class Buyer(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=255) phone_numbers = ArrayField(PhoneNumberField()) industry = models.IntegerField(null=True) credit_limit = MoneyField(max_digits=20, decimal_places=2, default_currency='MMK', null=True) is_active = models.BooleanField(default=True) datetime_created = models.DateTimeField(auto_now_add=True) datetime_updated = models.DateTimeField(auto_now=True) views.py class BuyerCreateView(AtomicMixin, View): template_name = 'add_buyer_modal.html' def get(self, request): form = BuyerForm() return render(request, self.template_name, {'form': form}) def post(self, request): form = BuyerForm(request.POST) if form.is_valid(): form.save() messages.success(request, 'Buyer created!', extra_tags='alert alert-success') return HttpResponseRedirect(self.request.META.get('HTTP_REFERER')) messages.error(request, 'Unable create buyer. {}'.format(form.errors), extra_tags='alert alert-danger') return HttpResponseRedirect(self.request.META.get('HTTP_REFERER')) forms.py class BuyerForm(forms.ModelForm): class Meta: model = Buyer fields = ['name', 'phone_numbers', 'industry', 'credit_limit'] template <div class="modal fade" id="add-buyer-modal" tabindex="-1" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">New Buyer</h5> <button type="button" data-dismiss="modal" aria-label="Close" class="close"> <span aria-hidden="true">&times;</span> </button> </div> <div class="col-md-12 modal-body"> <form id="buyer-form" method="post" class="submit-form" action="{% url 'buyers:add_buyer' %}"> {% csrf_token %} <div class="col-md-12"> <div class="form-group label-floating"> <label class="control-label">Name</label> <input autocomplete="false" type="text" name="name" class="form-control" required> </div> </div> <div class="col-md-12"> <div class="form-group label-floating"> <label class="control-label">Industry</label> <div class="input-group"> … -
Custom post view with form in Django Rest
I want to do the following: create a view that accepts only post, but that generates a form when I access something like "/ api / check_email /". So the only field will be email, and from that. I will check if there is a user with this email, and return the status as 200 or 404 depending on whether the user exists or not. I'm a bit lost on how to do this. currently my view looks like this: class CheckEmail(APIView): def post(self, request): email = "???" user = get_object_or_404(User, email=email) return Response({email: user.email}, status=200) -
Unable to get repr for queryset when call from Viewset
I am trying to call a queryset for a model to add to my serializer using objects.all() but the debug said Unable to set repr for <class 'django.db.models.query.Queryset'> Here is my viewset class TransactionReceiptViewSet(viewsets.GenericViewSet, viewsets.mixins.RetrieveModelMixin, viewsets.mixins.ListModelMixin): authentication_classes = (TokenAuthentication,) permission_classes = (IsAuthenticated,) serializer_class = base_serializers.TransactionReceiptSerializer queryset = models.TransactionReceipt.objects.all() def get_queryset(self): user = self.request.user return models.TransactionReceipt.objects.filter(user_profile=user) def retrieve(self, request, *args, **kwargs): response = super(TransactionReceiptViewSet, self).retrieve(request, *args, **kwargs) receipt = self.get_object() serializer = self.get_serializer(receipt) product_qs = models.ProductReceipt.objects.all() products_data = base_serializers.ProductReceiptSerializer( product_qs, many=True) serializer.data['products'] = products_data return Response(serializer.data) and here is the model i tried to call for class ProductReceipt(models.Model): id = models.AutoField(primary_key=True) amount = models.IntegerField(default=1) product = models.ForeignKey(Product, on_delete=models.DO_NOTHING, default=None) created_date = models.DateTimeField('Date of purchase', auto_now=True) transaction_receipt = models.ForeignKey(TransactionReceipt, on_delete=models.CASCADE) price = models.IntegerField(default=0) def __str__(self): return "object created" def __init__(self): super().__init__() self.product = Product() self.transaction_receipt = TransactionReceipt() def save(self, **kwargs): self.amount = 1 self.created_date = datetime.now() self.price = self.product.price_tag.price when i debug the api, it said that Unable to set repr for <class 'django.db.models.query.Queryset'> in product_qs and nothing is returned enter image description here -
please i need help, django.db.migrations.exceptions.NodeNotFoundError
Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/home/hola/.local/lib/python3.6/site-packages/django/core/management/init.py", line 371, in execute_from_command_line utility.execute() File "/home/hola/.local/lib/python3.6/site-packages/django/core/management/init.py", line 365, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/hola/.local/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv self.execute(*args, **cmd_options) File "/home/hola/.local/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute output = self.handle(*args, **options) File "/home/hola/.local/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 79, in handle executor = MigrationExecutor(connection, self.migration_progress_callback) File "/home/hola/.local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in init self.loader = MigrationLoader(self.connection) File "/home/hola/.local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in init self.build_graph() File "/home/hola/.local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 267, in build_graph raise exc File "/home/hola/.local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 241, in build_graph self.graph.validate_consistency() File "/home/hola/.local/lib/python3.6/site-packages/django/db/migrations/graph.py", line 243, in validate_consistency [n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)] File "/home/hola/.local/lib/python3.6/site-packages/django/db/migrations/graph.py", line 243, in [n.raise_error() for n in self.node_map.values() if isinstance(n, DummyNode)] File "/home/hola/.local/lib/python3.6/site-packages/django/db/migrations/graph.py", line 96, in raise_error raise NodeNotFoundError(self.error_message, self.key, origin=self.origin) django.db.migrations.exceptions.NodeNotFoundError: Migration admin.0004_auto_20190716_2110 dependencies reference nonexistent parent node ('admin', '0003_logentry_add_action_flag_choices') -
How should I track the last active time of an user using graphql JWT?
I am logging user login information including OS, browser, ip, and device. And I want to delete it after 30 days of no activity period. The thing is my users use smartphones and they hardly re-login once they logged in. I overrided graphql_jwt.JSONWebTokenMutation like this: class ObtainJSONWebToken(graphql_jwt.JSONWebTokenMutation): class Arguments: push_token = graphene.String() user = graphene.Field(UserType) @classmethod def resolve(cls, root, info, push_token=None, **kwargs): ip, is_routable = get_client_ip(info.context, ['HTTP_X_FORWARDED_FOR', 'X_FORWARDED_FOR', 'REMOTE_ADDR']) ua_string = info.context.META['HTTP_USER_AGENT'] user_agent = parse(ua_string) if user_agent.is_pc is True: device = 'Desktop' else: device = user_agent.device.family OS = user_agent.os.family + ' ' + user_agent.os.version_string browser = user_agent.browser.family + ' ' + user_agent.browser.version_string try: login_info = models.UserLoginInfo.objects.get(user=info.context.user, ip=ip, device=device, push_token=push_token, OS=OS, browser=browser) login_info.save() except models.UserLoginInfo.DoesNotExist: if push_token is not None: try: duplicated_push_token_info = models.UserLoginInfo.objects.get(push_token=push_token) duplicated_push_token_info.push_token = None duplicated_push_token_info.save() except models.UserLoginInfo.DoesNotExist: pass print(ip, device, OS, browser) login_info = models.UserLoginInfo(user=info.context.user, ip=ip, device=device, push_token=push_token, OS=OS, browser=browser) login_info.save() info.context.user.last_login = login_info.last_login info.context.user.save() return cls(user=info.context.user) But I soon found a problem. The last login time only gets updated when users login, as I mentioned above. So I cannot delete UserLoginInfo past 30 days. So how should I update last active time of an user using graphql jwt? I include a JWT token in Authorization header for … -
my django website doesn't load when i add huge sitemap
I've created a website using django with about 2 million pages. When i run it using gunicorn without sitemap, it works correctly, but when i add sitemap to the project, it doesn't work anymore. this is my sitemap generator: from django.contrib.sitemaps import Sitemap from django.contrib.sites.models import Site from .models import Message import math def build_sitemaps(): sitemaps = {} msg_count = Message.objects.count() msg_count = int(math.ceil(msg_count/(5*10**4))) for i in range(msg_count): message_sitemap = MessageSitemap(sitemap_number=i) sitemaps[str(i)] = message_sitemap return sitemaps class MessageSitemap(Sitemap): changefreq = 'daily' priority = 0.5 limit = 50000 protocol = 'https' def get_urls(self, page=1, site=None, protocol=None): fake_site = Site.objects.get(domain='example.com') return super(MessageSitemap, self).get_urls(page, site=fake_site, protocol=protocol) def __init__(self, sitemap_number): self.sitemap_number = sitemap_number super(MessageSitemap, self).__init__() def items(self): return Message.objects.all().order_by('id') this is my urls: from django.conf.urls.static import static from django.contrib import admin from django.urls import path, include from django.contrib.sitemaps import views from telegram_channels.sitemaps import build_sitemaps from telesearch import settings urlpatterns = [ path('admin/', admin.site.urls), path('sitemap.xml', views.index, {'sitemaps': build_sitemaps()}), path('sitemap-<section>.xml', views.sitemap, {'sitemaps': build_sitemaps()}, name='django.contrib.sitemaps.views.sitemap'), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) I use gunicorn by this command: gunicorn --certfile=/etc/letsencrypt/live/example.com/fullchain.pem --keyfile=/etc/letsencrypt/live/example.com/privkey.pem -k gevent -b :8000 telesearch.wsgi sometimes i got this error: [2019-07-17 16:48:01 +0200] [8970] [INFO] Listening at: https://0.0.0.0:8000 (8970) [2019-07-17 16:48:01 +0200] [8970] [INFO] Using … -
Django accessing Model with property decorator
How do I access the data in the method with the property decorator. I can access it in the shell, and it is what I need, but it comes up blank in my site. Models.py: class Project(models.Model): date_published = models.DateTimeField(auto_now_add=True) user = models.ForeignKey(User, null=True, on_delete=models.SET_NULL) area = models.ForeignKey(Area, on_delete=models.PROTECT) title = models.CharField(max_length=128, unique=True) summary = models.CharField(max_length=256) others = models.CharField(max_length=128, blank=True) deadline = models.DateField(null=True, blank=True) priority = models.ForeignKey(Priority, on_delete=models.PROTECT) closed = models.DateTimeField(null=True, blank=True) @property def updates(self): updates = [] categories = set(self.update_set.all().values_list( 'category__id', flat=True)) for cat_id in categories: updates.append(Update.objects.filter( project=self, category__id=cat_id).order_by('added').last()) return updates def __str__(self): return self.title Views.py: class ProjectView(ListView): template_name = 'project_portal/home.html' queryset = Project.objects.all().values() And I am trying to use the following in my template: <div class="box5"> {% for item in project %} <table> <tr> <td>{{ item.updates }}</td> </tr> </table> {% endfor %} </div> So far the box is blank. However, I have managed to get this data in the Django shell with the following: p = Project.objects.all()[0] p.updates This returns the correct data in the right order for the first project. What do I need to do to get it to appear in the site? -
How to add a field to default Promote panel's Multifield
I am trying to to add a field to the "Promote" panel's already existing MultiField. In my Page subclass I set up this: slug_en = models.SlugField( verbose_name='slug (EN)', allow_unicode=True, max_length=255, help_text="The name of the page as it will appear in URLs e.g http://example.com/blog/[my-slug]/" ) ... Page.promote_panels[0].children.insert(1, FieldPanel('slug_en')) I attempted at using the default "title" field instead of this custom one and indeed it works. The server returns the error: django.core.exceptions.FieldError: Unknown field(s) (slug_en) specified for Page The problem should be that the field is not initialized yet, at that moment, for some reason. How can I add the field to the Page.promote_panel successfully? -
How to render and bind choiceFile manually in Django
Am new to Django am trying to implement a simple select tag, the values are rendered with no problem but the value is not bound to the form during submission and I keep getting the message that the value is required Form class UploadFileForm(forms.Form): job_type = forms.ChoiceField(widget=forms.Select, choices=JOB_TYPES) HTML <div class="form-group"> <select class="browser-default custom-select"> {% for type in form.job_type %} {{ type }} {% endfor %} </select> </div> VIEW def simple_upload(request): if request.method == 'POST': form = UploadFileForm(request.POST, request.FILES) return render(request, 'upload/upload.html', {'form': form}) else: form = UploadFileForm() return render(request, 'upload/upload.html', {'form': form}) I also tried to do {{ form.job_type }} and this one works fine but then I can't use the required css, But I want to freely change css and style in the HTML file without refering to the form field in forms.py -
Fill field with data from DB for validation on django-admin
I'm working with django and it's powerful administrator. It's simple. I have a field that needs to be filled with the contents of database for validation. Example: The field is Name. I want the field to make itself a deployable list with all the names contained in the DB. If the field is Name, the user should see a deployable list with "John", "Edward", "Joshua"... Because those have been stored in the db. -
django-storages giving issues with SuspiciousOperation Error from settings
I am attempting to load static files in my project through django-storages using Digital Ocean S3. I am getting this error when I attempt to load the homepage of the site and I can't seem to figure out what the issue is. SuspiciousOperation at / Attempted access to '/images/logo_white.png' denied. Here is are the settings from settings.py that are important STATIC_LOCATION = 'static' STATIC_URL = 'https://exactestate.sfo2.digitaloceanspaces.com/static/' # the issue is here STATICFILES_STORAGE = 'storage_backends.StaticStorage' Here is the StaticStorage Class, all of the settings are correct when I run collectstatic it just doesn't allow me to load the images in the template. class StaticStorage(S3Boto3Storage, ABC): bucket_name = 'exactestate' location = 'static' default_acl = 'public-read' -
How to annotate a queryset with a new field of information from a related model?
I have a model where a Vehicle fields has more Wheels fields. I am trying to display in a single field the information of the vehicle and of the first wheel in the related Wheels field. I have seen that the F function might be useful but I cannot find the correct configuration for it to work. class VehicleListView(ListView): template_name = 'vehicle.html' queryset = Vehicle.objects.all() queryset = queryset.annotate(wheel1_name = F('Wheels__wheel_name')) def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) return context I would like the line queryset = queryset.annotate(wheel1_name = F('Wheels__wheel_name')) to return a list of the first wheel name for each vehicle so I can iterate through it and show it in a table. -
I improve the admin panel with the help of django-admin-tools but I get an error
I want to add dashboard to my admin panel but I get this error. I want to do statistics of visits in the admin panel image INSTALLED_APPS = [ 'admin_tools', 'admin_tools.theming', 'admin_tools.menu', 'admin_tools.dashboard', 'django.contrib.postgres', 'django.contrib.sites', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] -
How do i redirect to the same page after an action in django
Hello i have this function add_to_cart once a product is added to cart it should redirect to the same page I have done it to redirect to the product list any suggestion def add_to_cart(request, **kwargs): ------------------------ ------------------------ messages.info(request, "item added to cart") return redirect(reverse('products:product-list')) -
Is there a way to use value from one dictionary to search on another?
Im setting up a Django view where im generating some card based on how many there are on a given dictionary. Each of those cards will contain different information depending on who they are, that info is static and stored locally. The way i have the main dictionary setup allows me to loops thru all the cards but i cant figure out how to then get the card's individual data. Maybe foolishly tried to use a value from a dictionary to traverse another one. possibly my dictionary structure is my blocker but i cant come up with any other way. views.py location --> URL variable cards --> data pulled from database vlans --> data pulled from local json file def home_view(request, location): cards = Site.objects.get(sites=location.upper()).site_cards.all().values('cards') cards_dict = {c: c for c in [d['cards'] for d in list(cards)]} vlans = json.load(open('allvendors/static/json/vlans.json')) selected_site_vlans = vlans[location] home = { "site": location, "cards": cards_dict, "vlans": selected_site_vlans } return render(request, 'allvendors/home.html', {"home": home}) home.html home.vlans.card.vlan --> Foolish attempt at using key from one dict on another. See data structure being passed to the template below. {% for card in home.cards %} <div class="card mb-4 box-shadow shadow"> <div class="card-header"> <h4 id="whatfor" class="my-0 font-weight-normal">{{ card|title }}</h4> </div> … -
How to use Python dictionary data with Morris to make a line graph?
I am trying to make a line graph displaying the number of people checked in every day for a fiscal year. When I create the graph with dummy data, it works. But I am having trouble getting the graph to work when I use the actual data. I am trying to use data from the Counts dictionary as it holds the dates and corresponding counts of who checked in. I've tried using a for statement to grab an item in counts but the graph ends up blank. I've also tried a for statement to grab each day in count.dates to iterate over the different days and grab the data for that particular day but that also resulted in a blank graph. index_graph.html {% extends "admin/base_site.html" %} {% load static %} {% load i18n %} {% load in_group %} {% block extrastyle %} <link type='text/css' rel='stylesheet' href="{% static 'index.css' %}"> {% endblock %} {% block content %} <div class="row-fluid"> <div class="span12 text-center" id="pdfRenderer" style="width: 80%; align: left;"> <script src="{% static 'js/raphael-min.js' %}"></script> <script src="{% static 'js/morris-0.4.3.min.js' %}"></script> <link rel="stylesheet" href="{% static 'css/morris-0.4.3.min.css' %}"> <h5>Swipe Data from {{fiscal_start_date}} to {{fiscal_end_date}}</h5> <div id="line-graph"> <script> var count = {{counts}} new Morris.Line({ element: 'line-graph', data: … -
How to get the posts of a user (who is currently logged in) in django?
When a user logged in and went to his/her account they must see there old posts, what they have uploaded in past. If tried if statement in template by comparing current logged in user (request.user) and the users available in database. If, if condition is true than all the posts which are related to that user must be visible in my account page. But this if condition is not working. When i remove this condition it shows all of the posts whether these posts are related or uploaded by the user or not. And when i apply this condition it shows nothing, no error, it shows my navbar only which means rest of the code is fine the problem is with if statement. Template : {% for i in userstweet %} {% if request.user==i.user %} Username : {{i.user}} <br /> {{i.datetime}} <br /> <img src="{{i.image.url}}" width=400 height=400 /> <br /> <br /> {{i.tweet}} {% endif %} {% endfor %} View : def myaccount(request): return render(request,'tweets/myaccount.html',{'userstweet':Tweets.objects.all}) url : path('myaccount',views.myaccount,name='account') i expect the posts uploaded by the current logged in user will be shown on my account page but it gives nothing. -
How to change Django admin panel login-form requirement
I want to set up multiple Admin panels for different groups. Like user from "Management" group can only login into Management-Panel not to administration panel or any other.. -
Why not the page is displayed after migration?
OperationalError at /admin/newapp/effectivenessfield/ no such table: newapp_effectivenessfield On admin page is displayed, but not inside the class models.py from __future__ import unicode_literals from django.db import models from django.contrib.auth.models import User from completeness.models import Project class ConclusionName(models.Model): user = models.ForeignKey(User) conclusion_name = models.CharField(max_length=250) def __unicode__(self): return self.name class RetrospectiveField(models.Model): user = models.ForeignKey(User) baseText = models.TextField(max_length=255) comments = models.TextField(max_length=255) project = models.ForeignKey(Project) class ValidityField(models.Model): user = models.ForeignKey(User) baseText = models.TextField(max_length=255) comments = models.TextField(max_length=255) project = models.ForeignKey(Project) class EffectivenessField(models.Model): user = models.ForeignKey(User) baseText = models.TextField(max_length=255) comments = models.TextField(max_length=255) project = models.ForeignKey(Project) admin.py from django.contrib import admin from .models import ConclusionName, RetrospectiveField, ValidityField, EffectivenessField admin.site.register(ConclusionName) admin.site.register(RetrospectiveField) admin.site.register(ValidityField) admin.site.register(EffectivenessField) -
When a am trying to use 'git push heroku master' it returns me 'error: src refspec master does not match any'
I am a beginner in web dewelopment and Django. I apologize in advance for my english, but hope you will understand me. I am reading 'Django for beginners: build websites with python and django' and do all just like in the book. I will describe everything that i did. Everything is working in local server and i want to deploy it into production with Heroku. I signed up and went to git cmd and entered to my folder. Order of actions: 1. $ pipenv shell 2. $ pipenv lock 3. $ touch Procfile 4. write 'web: gunicorn pages_project.wsgi --log-file -' in Procfile 5. $ pipenv install gunicorn==19.9.0 6. in settings.py update ALLOWED_HOSTS=[] to ALLOWED_HOSTS['*'] 7. $ heroku create 8. $ heroku git:remote -a NAME #example: heroku git:remote -a morning-brook-95121 $ heroku config:set DISABLE_COLLECTSTATIC=1 To this place all was pretty good. Without errors. But next command is: $ git push heroku master error: src refspec master does not match any error: failed to push some refs to 'https://git.heroku.com/morning-brook-95121.git' I can't explain what i am doing and if it's not enough to you: https://www.pdfdrive.com/django-for-beginners-build-websites-with-python-and-django-updated-for-version-21-e176333886.html Page 57. I very need your help, i can't do anything. Don't forget: the good is returns, today … -
Django - how to define a MySQL CHAR data type in models?
I use MySQL as the db backend in django, I want to define a MySQL CHAR data type. When i use CharField, it will be a VARCHAR data type. c0 = models.CharField(max_length=1) How to define a MySQL CHAR data type in django models. -
Django How to redirect AJAX Loaded form to previous state on unsuccessful submission
I have got a template A.html which contains a link that processes an AJAX request, goes to a view, loads a form in B.html that is returned in AJAX success to a div specified in A.html. Now I have a view that on form submission goes to forms.py and gets that form cleaned and a validation error is raised. Where should I redirect my view if I want the previous state of A.html to be preserved? -
Django Form is rendered continuously
I have created a model from in django.After rendering the form. the output is continuously displayed. how can i make it in proper way.Like after every field is bellow previous field. <!DOCTYPE html> {% load static %} <html lang="en"> <head> <meta charset="UTF-8"> <title>User Form Page</title> </head> <body> <h1>USER REGISTRATION FORM</h1> <Form action=" " method="post"> {{Templateform}} {% csrf_token %} <input type="submit" name="" value="submit"> <input type="reset" name="" value="Reset"> </Form> <script type="text/javascript" src="{% static "ckeditor/ckeditor-init.js" %}"></script> <script type="text/javascript" src="{% static "ckeditor/ckeditor/ckeditor.js" %}"></script> </body> </html>