Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to pass a variable from a template to a view in Django
I am not able to GET a variable from a template into another view. I have a table with some records. Each row has a button which I would like to click and retrieve more details about the record in another page. I have been looking online but I cannot figure out how I should implement this. Everything I have tried either crashed or gave back None. list.html {% for trainee in trainees_list %} <tr> <td>{{ trainee.last_name }}</td> <td>{{ trainee.first_name }}</td> <td><a class="btn btn-primary" href="{% url 'traineedetails'%}" value="{{ trainee.pk }}" >View</a></td> </tr> {% endfor %} view.py def traineedetails(request): if request.method == 'GET': trainee_details = request.POST.get('trainee.pk') print(trainee_details) return render(request, 'trainee_details.html') def listoftrainees(request): trainees_list = UserTraining.objects.all() return render_to_response('list.html', {'trainees_list': trainees_list}) url.py urlpatterns = [ path('traineedetails', views.traineedetails, name='traineedetails'), path('listoftrainees', views.listoftrainees, name='listoftrainees'), ] form.py class UserTrainingForm(forms.ModelForm): scope_requirements = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=microscopes.MICROSCOPES) class Meta: model = UserTraining fields = ( 'first_name', 'last_name', ) model.py class UserTraining(models.Model): first_name = models.CharField('first name', max_length = 100) last_name = models.CharField('last name', max_length = 100) I would like to be able to click on the button in the row of the table and retrive more information about the record. -
How to traverse through JSON data for specific items in djano
I am attempting to convert locations to geocode to be stored for listings. I am using a 3rd party API that returns JSON after a location such as a city/state or zip code is used. I would like to: Filter responses that are only in the United States (country is returned in JSON) Get the lat/long data, city and state from the response and save those into the listing model services.py import requests def get_location(location): url = 'https://api.opencagedata.com/geocode/v1/json' params = {'q': location, 'key': '***', 'language': 'en', 'pretty': 1} r = requests.get(url, params=params) locations = r.json() return locations this gets me a response such as: { "documentation": "https://opencagedata.com/api", ... "results": [ { ... "components": { ... "_type": "city", "city": "Miami", ... "country": "USA", "country_code": "us", "state": "Florida", "state_code": "FL" }, ... "formatted": "Miami, FL, United States of America", "geometry": { "lat": 25.7742658, "lng": -80.1936589 } }, ... } I'm not sure if this is still JSON or if it is now python data at this point, and I am not sure how to properly traverse this data and store it into variables that I can save into the model, can anyone help with guidance / documentation? I think I will be … -
How to Return Hours or Minutes from Django Annotation and F Expression
I have a model as give below: class LeaveViewSet(viewsets.Model): def get_queryset(self): Leave.objects.annotate(duration=ExpressionWrapper( F('end_date') - F('start_date') + timedelta(days=1) )) class Leave(models.Model): start_date = models.DateField() end_date = models.DateField() But when I query on Leave and try to access the annotated field duration I get the timedelta object for example: leave = Leave.objects.all().first() leave.duration.days # this gives duration in days leave.duration # this is how I want to get the value I then added a property in the model as below: class LeaveViewSet(viewsets.Model): def get_queryset(self): Leave.objects.annotate(leave_duration=ExpressionWrapper( F('end_date') - F('start_date') + timedelta(days=1) )) class Leave(models.Model): start_date = models.DateField() end_date = models.DateField() @propery def duratioin(self): return self.leave_duration.days this way the serializer also work correctly and I can access leave.duration but want to know if I can get int type days instead of timedelta object in annotated field? -
celery beat using celery-django not working
i am new to celery-django library and i try to config and use it with rabbitmq, all configurations is right but i still have a problem in celery beat, when i run it i got this messeges in the log [2019-05-14 15:20:56,288: INFO/Beat] beat: Starting... [2019-05-14 15:20:56,292: INFO/Beat] Writing entries... [2019-05-14 15:20:56,921: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672// [2019-05-14 15:20:56,965: INFO/MainProcess] mingle: searching for neighbors [2019-05-14 15:20:58,041: INFO/MainProcess] mingle: all alone [2019-05-14 15:20:58,086: WARNING/MainProcess] celery@ubuntu-s-1vcpu-3gb-sgp1-01 ready. [2019-05-14 15:21:01,407: INFO/Beat] Writing entries... [2019-05-14 15:24:06,332: INFO/Beat] Writing entries... what could be the problem ? -
Cannot deploy django app to heroku because it cannot parse Procfile for some reason
I've looked at multiple different answers to my question and none of which answer my question correctly. The error I get is 'Push failed: cannot Parse Procfile'. I have my requirements configured correctly as well I believe, but just incase here is my requirements.txt: Babel==2.6.0 dj-database-url==0.5.0 Django==2.1.1 django-bootstrap4==0.0.8 django-fontawesome==1.0 django-heroku==0.3.1 django-phonenumber-field==2.4.0 django-phonenumbers==1.0.1 gunicorn==19.9.0 phonenumbers==8.10.11 pipenv==2018.11.26 psycopg2==2.7.7 pytz==2018.5 PyYAML==5.1 urllib3==1.25.2 whitenoise==4.1.2 Is there something in my settings.py that needs to be configured before deployment, other than turning debug to false? What kind of stuff needs to be configured in the django app before deployment? My Procfile just has 'web: gunicorn appname.wsgi' in it with appname replaced with my actual app name. Please help I've been going at this for about 6 hours now! I've only tried changing web: gunicorn appname.wsgi to web: gunicorn appname.wsgi --log-file -, but again that doesn't work either. Maybe theres more parameters to add -
How to update the user 'id' and user 'profile' as superuser in custom ADMIN page in DJANGO
How can I update a user profile from a custom admin page. I have created a custom admin dashboard in a specific page, when i click on user 'full name', i am redirected to a detail update page with the pk of the person i clicked on. Unfortunately, using the code below, I receive the information of the the superuser logged in instead of the user from the ID clicked on. How can I retrieve the information of the user clicked on and as the superuser update? def employees_directory_profile(request, employee_pk): """ Access profile of employee from Employee ListView in dashboard. """ employee = get_object_or_404(Profile, pk=employee_pk) if request.method == 'POST': form = EditProfileForm(request.POST, instance=request.user) extended_profile_form = ProfileForm(request.POST, # Populate image data if POST request.FILES, instance=request.user.profile) if form.is_valid() and extended_profile_form.is_valid(): form.save() extended_profile_form.save() return redirect('accounts:profile') else: form = EditProfileForm(instance=request.user) extended_profile_form = ProfileForm(instance=request.user.profile) context = { 'form':form, 'extended_profile_form':extended_profile_form, 'employee':employee } return render(request, 'accounts/dashboard-employee-active-profile.html', context) Any help would be much appreciated. -
Can a django templatetag invoke a view function directly? i want to use "include tag" with form data from another app
all, can a django templatetag invoke a view function directly? i want to use "include html" tags with form data from another app. My project structure like below: ProjectRoot ├── manage.py ├── MyProject │ ├── __init__.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py ├── templates │ ├── 404.html │ ├── contact-us.html │ ├── index.html │ ├── tags_form.html │ ├── tags_index.html ├── app_1 │ ├── admin.py │ ├── apps.py │ ├── forms.py │ ├── __init__.py │ ├── models.py │ ├── templatetags │ │ ├── __init__.py.bak │ │ └── app1_tags.py.bak │ ├── tests.py │ ├── urls.py │ └── views.py ├── app_2 │ ├── admin.py │ ├── apps.py │ ├── forms.py │ ├── __init__.py │ ├── models.py │ ├── templatetags │ │ ├── __init__.py.bak │ │ └── app2_tags.py.bak │ ├── tests.py │ ├── urls.py │ └── views.py i want to use "{% include app2.html%}" in app_1.html to access the app_2.html content which belongs to app_2, and the app_2.html contained form data belongs app_2/views(forms). at the same, the "included" app_2.html which would be shown in app_1.html has a 'submit' POST operation, i need to retrieve the posted data as well. the code in app_2/ folder like below: app_2/urls.py: from django.conf.urls import url, … -
Using django channels for notificaitons
I am working on a django project that allows two users chat together. Once you receive a new message, you get notification. To do both tasks, I am using django channels and opening a websocket. With my chat app working as intended, I moved on to work on the notifications part. However, that is where I face some problems. I have a signals.py where whenever a notification gets created, I send it to the room for the user. signals.py @receiver(post_save, sender=Notification) def newNotification(sender, instance, created, **kwargs): if created: channel_layer = get_channel_layer() room_name = "notif_room_for_user_"+str(instance.targetUser.id) async_to_sync( channel_layer.group_send)( room_name, {"type": "user.gossip", "event": instance.objectName, "targetUser": instance.targetUser} ) consumers.py class NoseyConsumer(AsyncJsonWebsocketConsumer): async def connect(self): self.user = self.scope["user"] self.user_room_name = "notif_room_for_user_"+str(self.user.id) await self.channel_layer.group_add( self.user_room_name, self.channel_name ) await self.accept() async def disconnect(self, close_code): await self.channel_layer.group_discard( self.user_room_name, self.channel_name ) async def user_gossip(self, event): await self.send_json(event) When I open the webpage, the websocket connects normally. The problem is when I send a message, and a new notification gets created, I get the following error "You cannot use AsyncToSync in the same thread as an async event loop - " You cannot use AsyncToSync in the same thread as an async event loop - just await the async function … -
Indexing a ListView object
I have ListView query set with with the nicknames of people called persons. I want to display the first nicknames and then loop over the rest. I am unable to find a way to index the query set, is there another way? <h1>{{ persons.1.nickname }}</h1> <h1>{{ persons.2.nickname }}</h1> <h1>{{ persons.2.nickname }}</h1> {{% for person in persons[3:] %}} <h5>{{ person.nickname }}</5> {{% endfor %}} -
How to fix 'Deadlock found when trying to get lock; try restarting transaction' Django/MySQL application
I have a django application using MySQL and I'm currently having an issue debugging a deadlock (i am relatively new to SQL) that is happening sporadically (it wont happen for an hour or two and then all the sudden I will get 10 deadlocks in a row). My application is streaming in realtime equity information on approx. 600 securities and then for each security updating about 50 various calculations. This appears to be the chunk of code that is causing the issue: cursor.execute('UPDATE position_mgmt_securities ' 'INNER JOIN position_mgmt_issuers ON position_mgmt_securities.issuer_id = position_mgmt_issuers.id ' 'INNER JOIN position_mgmt_positions ON position_mgmt_securities.id = position_mgmt_positions.security_id ' 'SET moneyness_pct = CONVERT(underlying_price / strike_price - 1, DECIMAL(12,5)) ' 'WHERE (position_mgmt_securities.issuer_id IN ' '(SELECT id ' 'FROM (SELECT * FROM position_mgmt_issuers) AS x ' 'WHERE x.ticker = "{0}") AND position_mgmt_positions.close_date IS NULL AND position_mgmt_securities.security_type_id = "ECO")'.format(ticker.replace(' EQUITY', ''))) When running SHOW ENGINE INNODB STATUS i get the following deadlock information. *** (1) TRANSACTION: TRANSACTION 168976, ACTIVE 0 sec fetching rows mysql tables in use 4, locked 4 LOCK WAIT 12 lock struct(s), heap size 1136, 265 row lock(s), undo log entries 2 MySQL thread id 58, OS thread handle 11068, query id 721547 localhost ::1 root Sending data … -
ERROR: repetitive record violates the singular constraint "user_otherinfo_user_id_key"
ERROR: repetitive record violates the singular constraint "user_otherinfo_user_id_key" DETAIL: The key "(user_id) = (52)" already exists. After the user has added the update process, I get such an error during the registration. views.py def register(request): form = RegisterForm(request.POST or None,request.FILES or None ) if form.is_valid(): user = form.save(commit=False) first_name = form.cleaned_data.get('first_name') last_name = form.cleaned_data.get('last_name') username = form.cleaned_data.get("username") email = form.cleaned_data.get('email') password = form.cleaned_data.get('password1') phone = form.cleaned_data.get('phone_number') location = form.cleaned_data.get('location') profile_image = form.cleaned_data.get('profile_image') user.set_password(password) user.save() new_user = authenticate(username=user.username, first_name=first_name, last_name=last_name, email=email, password=password) OtherInfo.objects.create(user=new_user,phone=phone,location=location, profile_image=profile_image) login(request,new_user) messages.info(request,"Successfully Register...") return redirect("/") context = { "form" : form } return render(request,"user/register.html",context) models.py class OtherInfo(models.Model): user = models.OneToOneField(User,on_delete=models.CASCADE) phone = models.CharField(max_length=11,verbose_name="Phone Number") location = models.CharField(max_length=50,verbose_name="Location") profile_image = models.FileField(blank = True,null = True,verbose_name="Image") forms.py class RegisterForm(forms.ModelForm): email = forms.EmailField() password1 = forms.CharField(max_length=100, label='Parola',widget=forms.PasswordInput()) password2 = forms.CharField(max_length=100, label='Parola Again', widget=forms.PasswordInput()) phone_number = forms.CharField(required=False, max_length=11, label='Phone Number') location = forms.CharField(required=False, max_length=50, label='Location') profile_image = forms.FileField(required=False, label="Image") class Meta: model = User fields = [ 'first_name', 'last_name', 'email', 'username', 'password1', 'password2', 'phone_number', 'location', 'profile_image', ] In Django, the user can register before updating the profile. When I add the profile update code, now the user is failing to register. How can I solve the problem? -
How to render a model in table form, and select some of them using checkbox using django?
I have a model called ItemBatch # item upload class ItemBatch(models.Model): ttypes =(('Open','Open'),('Container','Container'),('Trailer','Trailer'),('All','All')) uploaded_by = models.ForeignKey(User, on_delete=models.CASCADE, related_name='uploaded_by') name = models.CharField(max_length=30) pid = models.IntegerField(blank=True) quantity = models.IntegerField(blank=True) length = models.FloatField(blank=True) width = models.FloatField(blank=True) height = models.FloatField(blank=True) volume = models.FloatField(blank=True) weight = models.FloatField(blank=True) truck_type = models.CharField(max_length=255,default=0, choices=ttypes) origin = models.CharField(max_length=100, blank=True) destination = models.CharField(max_length=100, blank=True) time = models.DateTimeField(max_length=100, blank=True,default=now) rtd = models.BooleanField(default=False) #ready to dispatch checkbox def __str__ (self): return self.name And I am using this views function to render it: @method_decorator([login_required, teacher_required], name='dispatch') class UploadedItems(ListView): model = ItemBatch ordering = ('name',) context_object_name = 'items' template_name = 'classroom/teachers/item_list.html' def get_queryset (self): return ItemBatch.objects.filter(uploaded_by=self.request.user) I am rendering this table in a template and getting this: This is the code in the template: {% for quiz in last %} <tr> <form method="post" novalidate> {% csrf_token %} <td class="align-middle"><input type="checkbox" value="{{ quiz.pid }}"></td> <td class="align-middle">{{ quiz.name }}</td> <td class="align-middle">{{ quiz.pid }}</td> <td class="align-middle">{{ quiz.quantity }}</td> <td class="align-middle">{{ quiz.length }}x{{ quiz.width }}x{{ quiz.height }}</td> <td class="align-middle">{{ quiz.volume }}/{{ quiz.weight }}</td> <td class="align-middle">{{ quiz.origin }}</td> <td class="align-middle">{{ quiz.destination }}</td> <td class="align-middle">{{ quiz.time|naturaltime }}</td> </form> </tr> {% empty %} What I tried As you can see, I have created a form inside the table and also included … -
Paginate results in Django using a paginated API?
I am using the search functionality of the OMDB API. For each search, at most 10 results are returned at a time with an optional page parameter. I have a Django search form to get the search results from the OMDB API. What would be the best way to paginate results from the API? I would like to have a button that when pressed will essentially append &page= to the current URL and submit the form again. Is there a Django-y way of accomplishing this? I thought of using another form to pass in the page as a parameter but using multiple forms for a single search seems excessive. I also thought of using another field in the search form, page, to request the next page but I'm not sure how to use this as a button. -
How to mix Pug/Jade with Django conditionals and html element attributes?
I want to write Django conditionals for html attributes, like <a {% if item.link %} href="{{ item.link }}", target="_blank", rel="noopener", aria-label="{{ item }}" {% endif %}> --- Content --- </a> I am using pug/jade, so I can't put jade/pug syntax inside "Content" block, the compiler breaks. I would like to know if I can handle that in any way to no repeat the "Content" block. I tried also, withouth success: a({% if item.link %} href="{{ item.link }}", target="_blank", rel="noopener", aria-label="{{ item }}" {% endif %}) ----Content--- -
How change buffer-size in gunicorn(django) + nginx + docker
My problem is that in some requests that application recive body size large(xml) and return xml large, the request returns 502. This occurs randomly. I think that it's running buffer overflow. My application running in docker with guinicorn like wsgi. And i want change value of buffer-size to 64k. how do I do that? my gunicorn deploy command python manage.py migrate && gunicorn backend.wsgi:application -b 0.0.0.0:8000 --workers 3 --log-level=info I can be mistaken, my base in: Nginx uwsgi (104: Connection reset by peer) while reading response header from upstream -
How to return all combinations of two teams in Django?
I'm working on a Tournament Manager and I'm starting to work on the match system. My question is how can I return all combinations of two teams and then I'll be able to create matches with those combinations ? Let me explain a bit. One team belongs to only one pool. In the "Team" model, I have a foreign key field that references the pool to which the team belongs. In my algorith, I'd like to create matches played by two teams that belongs to the same pool. For exemple I have team A, B, C, D, I want to create match A vs B, match A vs C, match A vs D, and so on I looked a bit here : https://docs.python.org/3/library/itertools.html, and I found "combinations" function but nothing more. models.py scoreTeam1 = models.IntegerField() scoreTeam2 = models.IntegerField() phase = models.ForeignKey(Phase, default=None, on_delete=models.CASCADE) teams = models.ManyToManyField(Team, default=None, blank=True) class Pool(models.Model): name = models.CharField(max_length=16) nbTeam = models.IntegerField(validators=[ MaxValueValidator(4), MinValueValidator(3) ]) phase = models.ForeignKey(Phase, default=None, on_delete=models.CASCADE) field = models.ForeignKey(Field, default=None, on_delete=models.CASCADE) class Team(models.Model): name = models.CharField(max_length=16) totalpoints = models.IntegerField(default=0) position = models.IntegerField(default=0) category = models.ForeignKey(Category, default=None, on_delete=models.CASCADE) pool = models.ForeignKey(Pool, default=None, blank=True, null=True, on_delete=models.SET_NULL) views.py def matches_phase_view(request, id, id_phase, *args, **kwargs): tournaments … -
Django model set lookup very slow
I'm getting a very slow lookup in my Django models. I have two tables: class Scan(models.Model): scan_name = models.CharField(max_length=32, unique=True, validators=[alphanumeric_plus_validator]) class ScanProcessingInfo(models.Model): scan_name = models.CharField(max_length=32) processing_name = models.CharField(max_length=64) in_progress = models.BooleanField(default=False) When I perform the following operation to get a list of all Scan objects which have a ScanProcessingInfo for a specific processing_name: scans = models.Scan.objects.all() scan_set = [] for scan in scans: if self.set_type_definition.test_scan(scan, self.arg1, self.arg2): scan_set.append(scan) (test_scan routes to) def get_proc_info_been_done(scan, spd_name): try: proc_info = models.ScanProcessingInfo.objects.get(scan_name = scan.scan_name) except models.ScanProcessingInfo.DoesNotExist: proc_info = None if proc_info == None: return False return not proc_info.in_progress the request takes about 10 seconds. There are 300 Scans in total and 10 ScanProcessingInfos. The db backend is an RDS MySQL db. I also expect someone will tell me off for using strings for the cross-table identifiers, but I doubt that's the cause here. I'm sure I'm doing something obvious wrong, but would appreciate a pointer, thank you. -
How implement order_by and group_by on the same mysql queryset in Django
I have one Image model and Resized_Image model where I will resize my original image into different sizes and store them in the Resized_Image model. When I am trying to filter the data it is giving duplicate results. Here is my Model: class Image(models.Model): name=models.CharField(max_length=40,unique=True,help_text="name of the image") status = StatusField() class Resized_image(models.Model): img = models.ForeignKey(Image, related_name='images', on_delete=models.CASCADE,) image=models.ImageField(upload_to=date_format,width_field='width', height_field='height',) width=models.PositiveIntegerField() height=models.PositiveIntegerField() My serializer: class imagesSerializer(QueryFieldsMixin,serializers.ModelSerializer): images =resized_imagesSerializer(many=True,required=False,read_only=True) image = Base64ImageField(write_only=True,) class Meta: model = Image fields = ('id','name','image','tags','profiles','status','images') required = ['image'] class resized_imagesSerializer(serializers.ModelSerializer): class Meta: model = Resized_image fields = ('image','width','height') My view: class ImageListView(mixins.CreateModelMixin,generics.ListAPIView): queryset = Image.objects.all() serializer_class = imagesSerializer def get_queryset(self): param = self.request.query_params.get("width", None) queryset = Image.objects.order_by(*param).group_by('id') return queryset My result without any filtering: { "id": 1, "name": "abc", "status": 0, "images": [ { "id": 1, "image": "/images/photos/2019/04/29/14b77119-5d7.png", "width": 720, "height": 200 }, { "id": 2, "image": "/images/photos/2019/04/29/Movies/medium/14b77119-5d7.png", "width": 720, "height": 1280 } ] } Here when I have multiple images with different resized images, If I try to do order by based on width I am getting duplicate results(image with id 1 is repeating twice) How to do group_by on the ordered queryset using Django. I have used annotate but that is also giving the … -
Running my work webapp locally but cant access the correct site
So recently I have been trying to get my works webapp to be able to run locally so that I can develop. What I have done was set my debug = True and basically carried my settings.py file over from my test server. I finally got my python manage.py runserver [::]:8000 to run smoothly without errors. The problem that I am now having is that I cant access the correct idea. Sorry for any incorrect terms but lets say my webapp is at three links www.webapp.com, www.buying.webapp.com and www.selling.webapp.com where the SITE_ID are 1,2,3. I have learned to use localhost:8000 to access webapps before but that was with my simpler webapps. Any help would be appreciated! Thank you. -
Django-autocomplete-light showing empty dropdown instead of autocomplete widget
I am trying to implement django-autocomplete-light in my projects but cannot figure out why it does not show me the autocomplete widget, but keeps showing an emppty dropdown. I followed the tutorial: https://django-autocomplete-light.readthedocs.io/en/3.1.3/tutorial.html. I found that this problem has accored in other stackoverflow questions, but none of those answers have helped me so far. I have the following model: class Vilt(models.Model): vilt_title = models.CharField(max_length=200, unique=True) I created this autocomplete view: class ViltAutocomplete(autocomplete.Select2QuerySetView): def get_queryset(self): # Don't forget to filter out results depending on the visitor ! # if not self.request.user.is_authenticated(): # return Vilt.objects.none() qs = Vilt.objects.all().order_by('vilt_title') if self.q: qs = qs.filter(vilt_title__istartswith=self.q) return qs I use this ModelForm where I specify the widget. from .models import Vilt from dal import autocomplete class ViltSearchForm(forms.ModelForm): vilt_title = forms.ModelChoiceField( queryset = Vilt.objects.all(), widget = autocomplete.ModelSelect2(url='vilt-autocomplete') ) class Meta: model = Vilt fields = ('vilt_title',) from .views import (ViltAutocomplete, ) urlpatterns = [ #other paths path('vilt/autocomplete/', ViltAutocomplete.as_view(), name='vilt-autocomplete'), #other paths ] {% extends "bierviltje/base.html" %} {% load static %} {% load crispy_forms_tags %} {% block content %} <div class="container"> #other forms <div> <form action="" method="post"> {% csrf_token %} {{ vilt_search_form|crispy }} <input type="submit" /> </form> </div> #other forms </div> {% endblock content %} {% block … -
Access django project version to display it with angular
i'm trying to do a /about on a project, using Angular and Django. I need to put the version of the project in it but i got no idea on how to access the dotenv/__ version__ with angular to display it, any idea ? -
How to fix django two-factory authentication setup?
I have installed and configured this package https://github.com/Bouke/django-two-factor-auth for my Django app, to Admin site. Next step was to create a user and to setup this 2FA, but when i try to login for the first time, i'm always being redirected to /account/login/?next=/admin/ and i can't setup two-factor authentication. Has anyone faced with this problem? -
How to Replace Entire default Djnago Admin with custom Admin
I want to replace the default Django Admin templates with a completely revamped bootstrap version. The data in the Dashboard should be populated from the DB. How do I work with templated files ? Which files should be overriden ? In which template tag does HTML code go ? -
Sentry SDK - How to make raven test call with new client?
In the now deprecated package raven there was a django management command to test the setup: manage.py raven test. The new SentrySDK does not show how to do it in the django docs nor does it have any management commands. Any ideas about that topic? -
show google ads in for loop in django template?
How to show the ads in between for loop ? is this possible? is this good way to show ads? below my code is not working inside for loop {% for branch_obj in branch_list %} <div>cards</div> {% if forloop.counter == 2 %} <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- squre for blog --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-xxxxxxx" data-ad-slot="xxxxxxx" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> {% endif %} {% endfor %}