Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How do i implement my ClassView to my template html for a search behavior?
I'm super new to django. I am trying to create a clone of pastebin.com which has only one model (Post) with name , content and generated_url. I am having problem with the searchbar . I dont know how to implement the SearchView into search.html that generate here's my model from django.db import models from django.urls import reverse # Create your models here. class Post(models.Model): name = models.CharField(db_index=True, max_length=300, blank=False) content = models.TextField() generated_url = models.CharField(db_index=True, max_length=10, blank=False) def __str__(self): return self.name def get_absolute_url(self): return reverse("pastebin_app:detail",kwargs={'pk':self.pk}) here's my root.html for the searchbar <form action="{% url 'pastebin_app:search' %}" method="get" accept-charset="utf-8"> <input name="q" type="text" placeholder="Search"> <input type="submit" value="Search"/> </form> and here's the views.py for searchview class SearchView(ListView): template_name = 'pastebin_app/search.html' model = models.Post def get(self, request, *args, **kwargs): q = request.GET.get('q', '') self.results = models.Post.objects.filter(name__icontains=q) return super().get(request, *args, **kwargs) def get_context_data(self, **kwargs): return super().get_context_data(results=self.results, **kwargs) Can someone please help me creating the show.html template that produce the search result from the SearchView? -
Posting data to a django view using ajax is not working
I have a view and i want to post data using ajax method but it is not entering the view to print content. My javascript code: $("#id").click(aa); var aa= function() { var id= $("#id"); $.ajax({ url: "ajax/id", method: "POST", data: { user: id, csrfmiddlewaretoken: csrftoken }, context: document.body }).done(function(data) { alert("Success"); }).fail(function(returnedText) { console.log(returnedText.responseText); }); }; My Django view: def id(request): print("aa"); users = request.POST['user'] My url: path('/ajax/id', views.id, name='id') -
Django cron job failing to connect to database on Elastic Beanstalk
I've a django app running on Elastic Beanstalk with a Postgre database. The app works fine and has no problem talking to the data base. This is my database settings, if 'RDS_DB_NAME' in os.environ: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': os.environ['RDS_DB_NAME'], 'USER': os.environ['RDS_USERNAME'], 'PASSWORD': os.environ['RDS_PASSWORD'], 'HOST': os.environ['RDS_HOSTNAME'], 'PORT': os.environ['RDS_PORT'], } } else: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } However I've a cron job which runs as a custom command and also needs to write an object into the database, here's the custom command, class Command(BaseCommand): def handle(self, *args, **options): sources = Source.objects.all() // write some data This is the configuration file, 04_setup_cron: command: "cat .ebextensions/crontab.txt > /etc/cron.d/crontab && chmod 644 /etc/cron.d/crontab" leader_only: true And this is how I set the permissions on crontab.txt */15 * * * * source /opt/python/run/venv/bin/activate && cd /opt/python/current/app/ && source /opt/python/current/env && python manage.py parse >> /var/log/cron.log 2>&1 This cronjob fails, When I log into one of the EC2 instances and try to run this I get the following error, conn = Database.connect(**conn_params) django.db.utils.OperationalError: unable to open database file This works fine locally, how do I make it work on the EC2 instance? Any help appreciated. -
graphe orienté sur django
bonjour, je cherche un module qui va me permettre d'integrer les graphe orienté sur django -
Django form __init__ doesn't work in userprofileform
I'm stuck with the initialization of my userprofileform in the post method of a CBV and the instance receive a None object from the call to super()... the model is quite standard : a user and his profile; the uerprofile model has an user attribute (onetoone) models.py [...] class User(AbstractUser): """User model.""" username = None email = models.EmailField(_('email address'), unique=True) first_name = models.CharField(_('first name'), unique=False, max_length=100) last_name = models.CharField(_('last name'), unique=False, max_length=100) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) phone = models.CharField(max_length=15,null=True) website = models.URLField(blank=True, null=True) upload_to=PathAndRename("avatars/")) photo = models.ForeignKey(Photo, null=True, on_delete=models.PROTECT) organization = models.CharField(_('organization'), null=True,unique=False, max_length=100) city = models.CharField(_('city'), unique=False, max_length=100, null=True) country = CountryField(blank_label=_('select country'), null=True) subscribe_newsletter = models.BooleanField(default=False) language = models.CharField(max_length=10, choices=settings.LANGUAGES, default=settings.LANGUAGE_CODE) User.profile = property(lambda u: UserProfile.objects.get_or_create(user=u)[0]) @receiver(post_save, sender=User) def create_user_profile(sender, instance, created, **kwargs): if created: UserProfile.objects.create(user=instance) def save(self, *args,**kwargs): #import ipdb; ipdb.set_trace() self.city=(self.city or '').lower() self.organization=(self.organization or '').lower() self.website=(self.website or '').lower() super(UserProfile, self).save(*args,**kwargs) self.user.save() [...] forms.py [...] class UserProfileForm(forms.ModelForm): class Meta: model = UserProfile fields = ('first_name', 'last_name', 'phone', 'website','city','country','organization','subscribe_newsletter') def __init__(self, *args, **kwargs): user = kwargs.pop('user',None) super(UserProfileForm, self).__init__(*args, **kwargs) try: self.instance.user=user except: pass try: self.fields['first_name'].initial = self.instance.user.first_name self.fields['last_name'].initial = self.instance.user.last_name except User.DoesNotExist: pass [...] views.py class ProfileView(LoginRequiredMixin, View): def … -
Conditionally return in def __str__(self)
I am very new on Django and Python, this is actually my first app I am trying to start. Step by step I get things working, however I get stuck here when things go beyond the defaults I find in tutorials.. Here my problem: I have to deal with a model for time periods and those periods are different per country and for which some periods are BC and some are AD. So I added a model Period with a name and a start and end as integer fields. As dates won't do for 14000BC I figured I define negative years as BC and the positive as AD. Fields start and end can be empty as the first period (name='First period',start=null, end=-14000) would read something like: "First period (before 14000 BC)" and the last period (name="Last period", start=1989, end=null) would read: "Last period (1989 - present)" With my limited knowledge I tried in def str(self): of my model, first attempting to get the negative years being converted to positive years and adding the BC in the name. The second issue I have is that without the conditional trials, the None fields are shown as None even I have this in … -
Running a Window function on a set of Max'd values
So, I have an object Trainer which has reverse relations to many Survey objects. Each Survey object has a load of Integer fields and represents stats at a certain point in time. Not every Survey object will have every field filled in so I'm using django.db.models.Max() to get the latest values (values can never go down). I am then trying to compare those values to everybody else in the all the other Trainer objects in the database with django.db.models.functions.windows.PercentRank() to get their percentile. This is what I have and it runs fine up until Window Expression - Calculate Percentile after which I get an error! from django.db.models import Max, Window, F from django.db.models.functions.window import PercentRank from survey.models import Survey, Trainer fp_default_fields = ['badge_travel_km', 'badge_capture_total', 'badge_evolved_total', 'badge_hatched_total', 'badge_pokestops_visited', 'badge_big_magikarp', 'badge_battle_attack_won', 'badge_small_rattata', 'badge_pikachu', 'badge_legendary_battle_won', 'badge_berries_fed', 'badge_hours_defended', 'badge_raid_battle_won', 'gymbadges_gold', 'badge_challenge_quests', 'badge_max_level_friends', 'badge_trading', 'badge_trading_distance'] def calculate_foo_points(survey: Survey, fields: str=fp_default_fields, top_x: int=10): ''' Calculates a Trainer's Foo Points at the time of Surveying ''' # Base Query - All Trainers valid BEFORE the date of calculation query = Trainer.objects.filter(survey__update_time__lte=survey.update_time) # Modify Query - Exclude Spoofers query = query.exclude(account_falsify_location_spawns=True,account_falsify_location_gyms=True,account_falsify_location_raids=True,account_falsify_location_level_up=True) # Extend Query - Get Max'd Values query = query.annotate(**{x:Max(f'survey__{x}') for x in fields}) # Window Expression … -
how can I get the data of a contenteditable table in html with django?
I have a contenteditable table in django and I want to get the data in a POST to save it in a database. how can I get the data of a contenteditable table in html with django? -
Receive an '[Errno 13] Permission denied' error when trying to invoke an API made with Django Rest Framework
I created an API using Django REST Framework and host it on a Droplet instance. I deploy the API using Nginx and gunicorn. The API will receive a zip file that is base 64 encoded containing images, which will further be processed, and it will output a string in the form of a json format. Inside the API, there is a directory name images, in which the images will be save first from the zip file in order to be processed. I try to make a post request using python's requests library. I've configured the API so that it only accepts certain request with a token in its headers. I try to make a post request using python's requests library. However, i a permission error b'PermissionError at /api/beta/directory/\n[Errno 13] Permission denied: \'/home/gilang/django-project/directory/images/33540591_10215238550344340_2305337942534520832_n.jpg\'\n\nRequest Method: POST\nRequest URL: http://IP_address/api/beta/directory/\nDjango I'm not really sure what happened. I know for sure that this errors was due to the fact that the file has some kind of permission that doesn't allow other people other than the local user. So i tried to use os.chmod('path', '0o744') to each image. However, that did not work. Them i try to use subprocess to do the same used os.chmod. But … -
how to set authentication and permission only on PUT requests in django REST in viewsets?
I have a viewset subclassing modelviewset, on adding authication_classes = [SessionAuthentication,BasicAuthentication] and permission_classes = [IsAuthenticated] , I am getting message "detail": "Authentication credentials were not provided." on list , detail/retrieve and put requests. What should i change to only give this message when I update the data ?? -
get_deleted_objects() missing 2 required positional arguments: 'admin_site' and 'using'
When I delete data by xadmin, I got the error that get_deleted_objects() missing 2 required positional arguments: 'admin_site' and 'using', Who can help me, thanks a lot -
How to get solve NoReverseMatch Django 2.0
I'm a novice to Python and Django. I am learning it from a tutorial but stuck in between. Already tried with some other StackOverflow solution but no luck. The following error I'm getting Error: NoReverseMatch at /catalog/ Someone, please help me with the mistake that I have made. url.py urlpatterns += [ path('book/<uuid:pk>/renew/', views.renew_book_librarian, name='renew-book-librarian'), ] view.py @permission_required('catalog.view_all_books') def renew_book_librarian(request, pk): """View function for renewing a specific BookInstance by librarian.""" book_instance = get_object_or_404(BookInstance, pk=pk) # If this is a POST request then process the Form data if request.method == 'POST': # Create a form instance and populate it with data from the request (binding): book_renewal_form = RenewBookForm(request.POST) # Check if the form is valid: if book_renewal_form.is_valid(): # process the data in form.cleaned_data as required (here we just write it to the model due_back field) book_instance.due_back = book_renewal_form.cleaned_data['renewal_date'] book_instance.save() # redirect to a new URL: return HttpResponseRedirect(reverse('all-borrowed')) # If this is a GET (or any other method) create the default form. else: proposed_renewal_date = datetime.date.today() + datetime.timedelta(weeks=3) book_renewal_form = RenewBookForm(initial={'renewal_date': proposed_renewal_date}) context = { 'form': book_renewal_form, 'book_instance': book_instance, } return render(request, 'catalog/book_renew_librarian.html', context) model.py class BookInstance(models.Model): """ Model representing a specific copy of a book (i.e. that can be borrowed from … -
Django complex annotation
Pre-requisites: Queryset must return Articles Queryset must return unique objects my models: class Report(BaseModel): ios_report = JSONField() android_report = JSONField() class Article(BaseModel): internal_id = models.IntegerField(unique=True) title = models.CharField(max_length=500) short_title = models.CharField(max_length=500) picture_url = models.URLField() published_date = models.DateField() clip_link = models.URLField() reports = models.ManyToManyField( "Report", through="ArticleInReport", related_name="articles" ) class ArticleInReport(BaseModel): article = models.ForeignKey("core.Article", on_delete=models.CASCADE, related_name='articleinreports') report = models.ForeignKey("core.Report", on_delete=models.CASCADE, related_name='articleinreports') ios_views = models.IntegerField() android_views = models.IntegerField() @property def total_views(self): return self.ios_views + self.android_views Everything starts with a Report object that is created at set intervals. This report contains data about articles and their respective views. A Report will have a relationship with an Article through ArticleInReport, which holds the total number of users in Article at the time the report was imported. In my view, I need to display the following information: All articles that received views in the last 30 minutes. With each article annotated with the following information: If present, the number of views the Article object had in the last Report. If not present, 0. my views.py file: reports_in_time_range = Report.objects.filter(created_date__range=[starting_range, right_now]).order_by('created_date') xhours_ago_reports = Report.objects.filter(created_date__range=[xhours,right_now]) last_report = reports_in_time_range.prefetch_related('articles').last() unique_articles = Article.objects.filter(articleinreports__report__in=reports_in_time_range).distinct('id') articles = Article.objects.filter(id__in=unique_articles).distinct('id').annotate( total_views=Case( When(id__in=last_report.articles.distinct().values_list('id', flat=True), then=F('articleinreports__ios_views') + F('articleinreports__android_views')), default=0, output_field=IntegerField(), )) Some explanation for my thought … -
How to push and pop tasks of the queue in celery
I want to save large amount of images to the image server. I need to queue all requests of images information for saving them using Celery.I use Django framework. I read the document of Celery and configured it in Django and,I also created a queue under the name "images", but I don't know how to put information of images to the queue and send message for saving and remove them from the queue after saving. I couldn't find any command for push and pop tasks in queue in the document of Celery. Here is the code of how I configured the celery: from kombu import Exchange, Queue from celery import Celery import os class CeleryQueue: def celery_queue(self): os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'DataScience.settings') app = Celery('images', broker='amqp://localhost') app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks() image_exchange = Exchange('media', type='direct') app.conf.task_default_queue = 'images' app.conf.task_default_exchange_type = 'direct' app.conf.task_default_routing_key = 'media.image' app.conf.task_queues = (Queue('images', image_exchange,routing_key=app.conf.task_default_routing_key)) Thank you for any help -
Fields of the model in different apps for Django
I am facing a trouble in accessing one variable from an app in different app. I have two apps, "Inventory" and "Order". In Inventory app, I created different models with some variables. In Order App, I need to access the variable Field (QUANTITY) from Inventory app. Code from Inventory app (in models.py) --- - - -- - - - - class Items(models.Model): name=models.CharField(max_length=200) Quantity=models.IntegerField() ---------- Code From Order App (in models.py) ------ class NewOrder(models.Model): OrderName=models.CharField(max_length=200) Inventory = models.ForeignKey(Items,on_delete=models.CASCADE) Total=models.ForeignKey(Items.Quantity,on_delete=models.CASCADE) # This is not working . ------ -
How to achieve nested URL for OneToOne Relationship?
I'm a little bit stuck with the following situation. I want to build a REST API for a shopping cart app using the Django Rest Framework, however, due to legacy requirements I need to work with nested URLs. In general, I have two resources AppUsers and Carts. Both of the resources are available at the default /appUsers/ and /carts/ endpoints. I then tried using nested routers to get the cart detail view for a specific user to be addressable as /appUsers/app_user_pk/cart/ instead of /carts/pk/ since every AppUser can only have one cart anyway. Here's my setup: models.py class AppUser(models.Model): _id = models.AutoField(primary_key=True) class Meta: default_related_name = 'app_users' class Cart(models.Model): app_user = models.OneToOneField( 'AppUser', on_delete=models.CASCADE, related_query_name='cart', ) class Meta: default_related_name = 'carts' def __str__(self): return "{user} cart".format(user=self.app_user._id) serializers.py class AppUserSerializer(serializers.HyperlinkedModelSerializer): cart = serializers.HyperlinkedIdentityField(view_name='cart-detail') class Meta: model = AppUser fields = '__all__' class CartSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Cart fields = '__all__' views.py class AppUserViewSet(viewsets.ModelViewSet): """ Model viewset for AppUser model """ queryset = AppUser.objects.all() serializer_class = AppUserSerializer class CartViewSet(viewsets.ModelViewSet): """ List all carts, or create new / edit existing product. """ queryset = Cart.objects.all() serializer_class = CartSerializer def get_queryset(self): if 'app_user_pk' in self.kwargs: return Cart.objects.filter(app_user=self.kwargs['app_user_pk']) return Cart.objects.all() urls.py router = DefaultRouter() … -
What language should I make a search based web app?
I recently had an idea to make a web app where you can search for a relevant topic and get articles on a topic, divided by political viewpoints. I was wondering what language would be useful to create such a web app. I had considered Django but I still would like guidance on how to approach it. Thanks -Nicholas -
Copying django model instances with self relating foreign keys
Been trying to get this working for ages with no luck. I have 3 models class Project(models.Model): number = models.CharField(max_length=30, unique=True) title = models.CharField(max_length=300) client = models.CharField(max_length=300) category = models.CharField(max_length=300, null=True) . . etc class ProjectGroup(models.Model): description = models.CharField(max_length=300) project = models.ForeignKey(Project, on_delete=models.CASCADE) group = models.ForeignKey('self', on_delete=models.CASCADE, null=True) . . etc class ProjectPart(models.Model): number = models.CharField(max_length=30) description = models.CharField(max_length=300) project = models.ForeignKey(Project, on_delete=models.CASCADE) group = models.ForeignKey(ProjectGroup, null=True, blank=True, on_delete=models.CASCADE) . . etc A project contains a number of groups which in turn contain the project parts. The groups can contain other groups similar to a folder structure. I am trying to copy an instance of project which will copy all related instances of groups and parts and keep the folder type structure. so far I have.. def copyprojectview(request, project_id): form = CopyProjectForm(request.POST) if form.is_valid(): #get details for new project and create number = form.cleaned_data['number'] title = form.cleaned_data['title'] client = form.cleaned_data['client'] category = form.cleaned_data['category'] project = Project.objects.create(number=number, title=title, client=client, category=category) # get list of groups and parts to be copied to new project parts = ProjectPart.objects.filter(project_id=project_id) groups = ProjectGroup.objects.filter(project_id=project_id) Then this is the bit I'm getting stuck on. Copying over and trying to keep the correct relationships. I can copy all … -
How do i add a searchbar through class based view
I am new to django and I am trying to create a simple clone version of [pastebin.com][1] that has only one model with name and content. I have created the searchbar in my root template. But what is the actual Class View to filter only the name and show a list of name and content? ` Patebin Assesment Project <input class="searchfield" id="searchbox" name="q" type="text" placeholder="Search"/> <input class="searchbutton" type="submit" value="Search"/> </form>` As I have already said I am very new with django. Here's My model from django.db import models from django.urls import reverse # Create your models here. class Post(models.Model): name = models.CharField(db_index=True, max_length=300, blank=False) content = models.TextField() generated_url = models.CharField(db_index=True, max_length=10, blank=False) def __str__(self): return self.name def get_absolute_url(self): return reverse("pastebin_app:detail",kwargs={'pk':self.pk}) -
how to select values from two models having a foreign key relation in django
I have two models one called person and the other called permission , the person have a foreign key called p_perm that relates permission model to a perm_id field , i want to filter in the person table by id and select the relative permission values of this person from permission table My model: class Person(models.Model): p_id = models.AutoField(primary_key=True) p_fname = models.CharField(max_length=20) p_perm = models.ForeignKey(Permission, on_delete=models.DO_NOTHING, to_field="perm_id") class Permission(models.Model): perm_id = models.CharField( max_length=1, unique=True, primary_key=True) perm_label = models.CharField( max_length=30) I have done this in my view: x = Person.objects.get(p_id=user) print(x.p_perm) y = Permission.objects.get(perm_id= x.p_perm) print(y.perm_id) -
getting error changing database from sqlite to postgreSQL in Django
I have been trying to dump and load data from sqlite to PostgreSQL referring to this page. However, I got following error when I tried to load data which is dumped by following code. python manage.py dumpdata --natural-foreign --natural-primary -e contenttypes -e auth.Permission > database.json I tried to dump data removing natural argument as below. But got same error. python manage.py dumpdata -e contenttypes -e auth.Permission > database.json Could anyone tell me what should I do to solve this problem? (webEP) C:\Users\obakatsu\Documents\Python_scripts\Django\DjangoEP>python manage.py loaddata database.json Traceback (most recent call last): File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\backends\utils.py", line 65, in execute return self.cursor.execute(sql, params) psycopg2.ProgrammingError: リレーション"auth_user"は存在しません LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user... ^ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\core\serializers\json.py", line 81, in Deserializer for obj in PythonDeserializer(objects, **options): File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\core\serializers\python.py", line 183, in Deserializer obj = base.build_instance(Model, data, db) File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\core\serializers\base.py", line 227, in build_instance obj.pk = Model._default_manager.db_manager(db).get_by_natural_key(*natural_key).pk File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\contrib\auth\base_user.py", line 48, in get_by_natural_key return self.get(**{self.model.USERNAME_FIELD: username}) File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\models\manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\models\query.py", line 373, in get num = len(clone) File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\models\query.py", line 232, in __len__ self._fetch_all() File "C:\Users\obakatsu\Anaconda3\envs\webEP\lib\site-packages\django\db\models\query.py", line 1102, in _fetch_all self._result_cache = list(self._iterable_class(self)) File … -
Django how to run external module as Daemon
Is there a correct way to start an infinite task from Django Framework? I need to run a MQTT Client (based on Paho) and a Python PID implementation. I want to use Django as "Orhestrator" because I want to start daemons only if django it's running. I use django becasue of it's simplicity for creating Rest API and ORM layer. The only way I've found (here on github) it's to modify the __init__.py including here my external module --> How to use paho mqtt client in django?. This it's not suitable for me beacause it start the daemons on every django manage task. Has anyone already solved this problem? Thank you in advance. -
Success_url from created object url in FormView
I have a form class view which creates an object (a product in a catalog) when the user fills the form. The object is created inside the form_valid method of the view. I want that the view redirects to the created object url (the product url) through the "success_url" atribute of the FormView. The problem is that I do not know how to specify that url in the success_url method, since the object is still not created when the class itself is defined. I have tried with reverse_lazy, or the get_absolute_url() method of the object, but the same problem persists. class ImageUpload(FormView): [...] success_url = reverse_lazy('images:product', kwargs={'id': product.id }) [...] def form_valid(self, form): [...] self.product = Product.objects.create( user=self.request.user, title=title) -
How to convert pafy audio files to mp3 on fly in Django App
I am making a Youtube to mp3 downloader app Using Django and pafy, I am Stuck on two problems from a long while, Pafy by default give webm and mp4a I want to convert them into mp3 files without downloading them to my servers, is it possible? And Can I change the thumbnail of the mp3 file? The link which pafy gives are not download links they start playing in the browser. How to convert them into downloadable links, I tried some combinations but always got error. Here are my files Views.py class download(generic.View): template_name = 'download_mp3.html' def get(self, request, *args, **kwargs): return render(request, self.template_name) def post(self, request, *args, **kwargs): url = request.POST['url'] url = url_corrector(url) # Converting the urls in a format that is supported by pafy. video = pafy.new(url) # creates a pafy object for a given youtube url. stream_audio = video.audiostreams # only audio audio_streams = list() # list of all the dash audio formats(only audio) for a in stream_audio: audio_streams.append( [a.bitrate, a.extension, filesizeformat(a.get_filesize()), a.url + "&title=" + video.title]) return render(request, self.template_name, {'url': request.POST['url'], 'title': video.title, 'thumb': video.bigthumbhd, 'duration': video.duration, 'views': video.viewcount, 'stream_audio': audio_streams}) urls.py urlpatterns = [ path('', views.download.as_view(), name='youtube_to_mp3') ] download.html <table class="table table-hover text-center"> … -
adding a new button with functionality of "save and continue" admin django
In the add_view of admin panel i want to add custom button but with same functionality of "save and continue editing" button How can I do it? I am trying to hide that submit row and use my own button