What do you want to save?
Add Code snippet
New code examples
-
Python 2022-03-02 20:05:31
q is not defined pylance django
from django.db.models import Q Add solution -
Other 2022-03-01 16:45:21
how to write manual querry in drf
from django.db import connection def my_custom_sql(self): with connection.cursor() as cursor: cursor.execute("UPDATE bar SET foo = 1 WHERE baz = %s", [self.baz]) cursor.execute("SELECT foo FROM bar WHERE baz = %s",... Add solution -
Other 2022-02-28 18:55:05
django forms views.py
from django.http import HttpResponseRedirect from django.shortcuts import render from .forms import NameForm def get_name(request): # if this is a POST request we need to process the form data if request.method == 'POST': # create a form... Add solution -
Python 2022-02-24 09:20:08
how to delete all instances of a model in django
from django.shortcuts import render from .models import Car def showthis(request): #deletes all objects from Car database table Car.objects.all().delete() context= {} return render(request, 'Blog/home.html', context) Add solution -
Python 2022-02-16 15:20:05
django telephone field
from django.core.validators import RegexValidator class PhoneModel(models.Model): ... phone_regex = RegexValidator(regex=r'^\+?1?\d{9,15}$', message="Phone number must be entered in the format: '+999999999'. Up to 15 digits allowed.") ... Add solution -
Python 2022-02-13 19:00:02
adding content search bar in blog django
# cities/urls.py from django.urls import path from .views import HomePageView, SearchResultsView urlpatterns = [ path('search/', SearchResultsView.as_view(), name='search_results'), path('', HomePageView.as_view(), name='home'), ] Add solution