Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Celery is killed after running gunicorn
I have implemented all of Celery, Redis, Nginx and Django configurations. First, I am running Redis, then after I am running Celery. I can see that celery is working but when I run gunicorn, celery is being killed. I wonder what is the problem here, I have to start gunicorn so that to access Django application. -
How to get the logged in user ip and compare it with the previous ip, if the ip address is different, a message is issued (Django)
I'm quite new to the world of python and django programming, I'm developing my first app which is basically a very simple blog. I would like to know how to do what I have described in the title. I haven't created a user model but i have used settings.AUTH_USER_MODEL, a form.py for the Login and a view.py. Form.py class UserLoginForm(forms.Form): username = forms.CharField() password = forms.CharField(widget=forms.PasswordInput) def clean(self, *args, **kwargs): username = self.cleaned_data.get('username') password = self.cleaned_data.get('password') if username and password: user = authenticate(username=username, password=password,) if not user: raise forms.ValidationError('Account does not exist') if not user.check_password(password): raise forms.ValidationError('Wrong password') if not user.is_active: raise forms.ValidationError('User disabled') return super(UserLoginForm,self).clean(*args, **kwargs) View.py def login_view(request): next = request.GET.get('login') title = 'Login' form = UserLoginForm(request.POST or None) if form.is_valid(): username = form.cleaned_data.get('username') password = form.cleaned_data.get('password') user = authenticate(username=username, password=password) login(request, user) if next: return redirect(next) return render(request,'bloggo/homepage.html', {}) return render(request, 'bloggo/account_form.html', {'form': form, 'title': title}) Thank u all!! -
How to use the add tag in django admin templates
in django admin change_list_results.html there is a part which is responsible for the items that get registered for a model in the screen {% for item in result %} {{ item }} {% endfor %} Now I wanted to add something to the first of every item, I know if it was in pagination, I could do add:paginator.page.start_index but in this case, there is no start_index key for item, or result : {{ forloop.counter|add:item.start_index }} or {{ forloop.counter|add:result.start_index }} returns Failed lookup for key [start_index] in '<td class="action-checkbox"><input type="checkbox" name="_selected_action" value="705" class="action-select"></td>' So what should I do to add something to the listview of an item in django admin? -
How to merge two Querysets and create new queryset in django
class IndoorInventory(models.Model): client = models.ForeignKey(Client, on_delete=models.CASCADE) product = models.CharField(max_length=50) indoor_brand = models.CharField(max_length=100, null=True, blank=True) indoor_model_no = models.CharField(max_length=100, null=True, blank=True) indoor_sr_no = models.CharField(max_length=100, null=True, blank=True) outdoor_model_no = models.CharField(max_length=100, null=True, blank=True) class OutdoorInventory(models.Model): client = models.ForeignKey(Client, on_delete=models.CASCADE) product = models.CharField(max_length=50) outdoor_brand = models.CharField(max_length=100, null=True, blank=True) outdoor_model_no= models.CharField(max_length=100, null=True, blank=True) outdoor_sr_no = models.CharField(max_length=100, null=True, blank=True) indoor_model_no= models.CharField(max_length=100, null=True, blank=True) I have two models for two parts of AC, that is IndoorInventory for the indoor unit which shows all indoor unit information, and OutdoorInventory for showing outdoor unit information. I am passing a queryset of IndoorInventory to my Django template and fetching all the data there. enter image description here Now I want to get the outdoor_sr_no from OutdoorInventory models and pass it to the IndoorInventory queryset so that outdoor_sr_no value also get fetched on the table -
How to make Tags and Categories Separate in django wagtail
How to make Tags and Categories Separate... I have a tag for SCRC and a Tag for Libraries, but How can i make it so when I create a blog, and choose each different tag, the posts show up? -
Should the api return the UUID or the actual record?
I'm receiving data objects from the backend with UUIDs. example: { name: "evcs", website: "", created_by: "6c7b3ca1-8c32-4787-8286-0c0635d67444" } the UUID can be from any microservice, so from the front-end, I have to make a request to that microservice to get the name of the user who created the record. so my question is: If a data object has 7 to 8 fields with UUIDs. Should we make requests to those microservices from the front-end? or the backend should send the actual data instead of sending the UUIDs my UI is a bit slow due to making requests from the front end. users have to wait until the front end finishes with all requests. what is the right way to handle this? -
Is it possible to add to a model field from the frontend without having to invoke a url and template?
I have a Recipe models as follows: class Recipe(models.Model): category = models.ForeignKey(Category, on_delete=models.CASCADE) profile = models.ForeignKey(Profile, on_delete=models.CASCADE,related_name='recipe') title = models.CharField(max_length=255) subtitle = models.TextField(max_length=500) slug = models.SlugField(max_length=255) ingredients = models.TextField(blank=True, null=True) description = models.TextField(null=True, blank=True) image = models.ImageField(upload_to='uploads/', blank=True,null=True) thumbnail = models.ImageField(upload_to='uploads/', blank=True,null=True) date_added = models.DateTimeField(auto_now_add=True) I create instances of this model via a custom form which includes all the fields. I display all my recipe models in a page called my_account by doing the following in the html page. {% for recipe in recipes %} <tr> <td><a href="{% url 'recipe_details' recipe.category.slug recipe.slug %}" class='field'>{{recipe.title}}</a></td> <td><a href="{% url 'update_recipe' recipe.slug %}" class='button is-dark'>Update</a></td> <td><a href="{% url 'delete_recipe' recipe.slug %}" class='button is-light'>Remove</a></td> My question us basically, can i achieve the following in my_accounts page, where in when the user clicks on add ingredient button, whatever the user has typed in gets added to the recipe.ingredients field for that particular recipe. Example: if the user types in '1 tbsp sugar' into the input field and clicks Add ingredient, for Black Tea, then '1 tbsp sugar' should get added to ingredients fields for my Black Tea Recipe model instance. -
How can i auto fill those bootstrap_form fields when i enter certain id then those id related data is auto filled in django
this is my model and when i enter some data it goes to database and i want to retrive that data in a form field automatically i am using bootstrap_form when i enter there id like when i enter id then name:something,address:something like this data is autofilled in form fields.Please help i am new to django. # Create your models here. user_sex = (('Male','male'),('Female','female')) This is my Student Registration model class StudentRegistration(models.Model): Id = models.ForeignKey(unique=True) StudentName = models.CharField(max_length=150) Std_Address = models.CharField(max_length=250) std_phone = models.CharField(null = False , blank = False, unique = True,max_length=150) Email = models.EmailField() faculty = models.CharField(max_length=150) parents_name = models.CharField(max_length=250) parents_phone = models.CharField(null = False , blank = False, unique = True,max_length=150) join_Date = models.DateTimeField(auto_now_add=True) Registration_No = models.IntegerField(unique = True) sex = models.CharField(default='Male',choices=user_sex,max_length=150) def __str__(self): return self.StudentName,self.Registration_No def get_absolute_url(self): return reverse('registration:stdlist') def save(self,*args,**Kwargs): return super().save(*args,**Kwargs) This is my Staff registration Detail class StaffRegistration(models.Model): Id = models.ForeignKey(unique=True) Name = models.CharField(max_length=250) Address = models.CharField(max_length=250) Email = models.EmailField() phone = models.CharField(null = False,blank = False,unique = True,max_length=150) Join_Date = models.DateTimeField(auto_now_add=True) sex = models.CharField(default='Male',choices=user_sex,max_length=150) def __str__(self): return self.Name,self.Address def get_absolute_url(self): return reverse("registration:stafflist") def save(self,*args,**Kwargs): self.slug = slugify(self.Name) return super().save(*args,**Kwargs) -
Issue when I want to send a request to an url with middleware applied even when I'm logged in, in Django
I have a Django project include rest API. since i have added middleware in my project i cant access my api through requests modules although i am logged in. but it is possible to access while i type the address in url. middlewares.py from django.http import HttpResponseRedirect from django.contrib import messages LOGIN_EXEMPT_URLS = [ '/api/', ] class LoginMiddleWare: def __init__(self, get_response): self.get_response = get_response def __call__(self, request): if not request.user.is_authenticated and request.path not in LOGIN_EXEMPT_URLS: messages.error(request, 'You should login first!', 'warning') return HttpResponseRedirect('/api/') response = self.get_response(request) return response settings.py MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'djangoProject_app.middlewares.LoginMiddleWare', ] -
get data from request when creating object in django rest framework
I'm trying to verify email by sending a code, that's how i'm approaching the problem: I created a model named Email_for_Verification with two fields (email , code) the code is generated randomly, i create an instance of this model when the user enters his email, i send the generated code on email, in the second step, the user enters the received code, and i'm proceeding to the validation with a View named : Verify_code. but i'm encountring an error. i'm facing this error when trying to send email to the user when creating the Email_for_Verification instance 'Request' object has no attribute 'email' Here is my code Views.py class Verify_code(APIView): def post(self, request): data = request.data code = data.get('code') email = data.get('email') email_for_verification = models.Email_for_Verification.objects.get(email=email) if code == email_for_verification.code: return Response({"valid" : "Valid code", "email": email}, status=status.HTTP_200_OK) else : return Response({"invalid" : "Invalid code", "email": email}, status=status.HTTP_404_NOT_FOUND) class EmailForVerificationView(CreateAPIView): queryset = models.Email_for_Verification.objects.all() serializer_class = EmailForVerificationSerializer def create(self, request): created = models.Email_for_Verification.objects.create(email = request.email).save() if created: data = request.data email = data['email'] code = data['code'] send_mail( 'He is the code of verification', code, 'ivan@yandex.ru', [email], fail_silently=True, ) Models.py def generate_activation_code(): return int(''.join([str(random.randint(0,10)) for _ in range(6)])) class Email_for_Verification(models.Model): email = models.EmailField( max_length=100, … -
unable to get the docker interpreter in pycharm (running in windows 10)
Currently running docker desktop 2.5.0.1 in windows 10 ,I am trying to configure docker interpreter for my Django project in Pycharm , but I couldn't find any docker interpreter in the left hand side of the window. I have already added the Django plugins required for pycharm -
How to define a default value for a get parameters with Django?
I do not understand why I cannot define a default value for a get parameter even after reading the document about QueryDict. This is what I have: selected_zipcode = request.GET.get('zipcode', 75000) I can get my parameter if set in my url but if I do not define a zipcode parameter or if zipcode is not set, i do not get 75000 as value. -
i really cant find my problem.. but my problem is that i have something duplicated in my tuple
the error is : ERRORS: <class 'registerapp.admin.UserAdminConfig'>: (admin.E012) There are duplicate field(s) in 'fieldsets[1][1]'. <class 'registerapp.admin.UserAdminConfig'>: (admin.E012) There are duplicate field(s) in 'fieldsets[2][1]'. btw I have to inform that I have used mobileNumber as unique=True in my model from django.contrib import admin from registerapp.models import Members from django.contrib.auth.admin import UserAdmin class UserAdminConfig(UserAdmin): search_fields = ('email', 'name', 'mobileNumber',) list_filter = ('email', 'name', 'mobileNumber', 'nationalCode',) ordering = ('email',) list_display = ('email', 'familyName', 'mobileNumber', 'nationalCode', 'is_active', 'is_staff') fieldsets = ( (None, {'fields': ('name', 'familyName')}), ('User information', {'fields': ('email', 'name', 'familyName', 'mobileNumber', 'password', 'nationalCode')}), ('Permissions', {'fields': ('is_staff', 'is_active', 'is_superuser', 'groups')}), ) add_fieldsets = (None, { 'classes': ('wide',), 'fields': ('email', 'name', 'familyName', 'mobileNumber', 'password', 'nationalCode') }) admin.site.register(Members, UserAdminConfig) my model class customMemberManager(BaseUserManager): def create_user(self, email, mobileNumber, name, familyName, password, nationalCode, **other_fields): if not email: raise ValueError('YOU MUST ENTER VALID EMAIL') email = self.normalize_email(email) user = self.model(email=email, mobileNumber=mobileNumber, name=name, familyName=familyName, password=password, nationalCode=nationalCode, **other_fields) user.set_password(password) user.save() return user def create_superuser(self, email, mobileNumber, name, familyName, password, nationalCode, **other_fields): other_fields.setdefault('is_staff', True) other_fields.setdefault('is_superuser', True) other_fields.setdefault('is_active', True) if other_fields.get('is_staff') is not True: raise ValueError('superuser must be is_staff set to True') if other_fields.get('is_superuser') is not True: raise ValueError('superuser must be is_superuser set to True') return self.create_user(email, mobileNumber, name, familyName, password, nationalCode, **other_fields) … -
Django forms cleaned_data
I want to create a sort_by functionality in my django app and for that I tried the following way. First step: forms.py class SortForm(forms.Form): CHOICES = [ ('latest', 'Latest Notes'), ('oldest', 'Oldest Notes'), ('alpha_descend', 'Alpahabetically (a to z)'), ('alpha_ascend', 'Alpahabetically (z to a)'), ] ordering = forms.ChoiceField(widget=forms.RadioSelect, choices=CHOICES) Then views.py: def index(request): ################### Default, when form is not filled ################# notes = Note.objects.all().order_by('-last_edited') form = SortForm() if request.method == 'POST': form = SortForm(request.POST) if form.is_valid(): sort_by = form.cleaned_data['ordering'] if sort_by == 'latest': notes = Note.objects.all().order_by('-last_edited') elif sort_by == 'oldest': notes = Note.objects.all().order_by('last_edited') elif sort_by == 'alpha_descend': notes = Note.objects.all().order_by('title') elif sort_by == 'alpha_ascend': notes = Note.objects.all().order_by('-title') return redirect('index') context = { 'notes' : notes, 'form' : form, } return render(request, 'notes/index.html', context) models.py just in case: class Note(models.Model): title = models.CharField(max_length=100) body = models.TextField() last_edited = models.DateTimeField(auto_now=True) def __str__(self): return self.title It doesn't do anything when the form submit button is pressed and refreshes the index page with the default lookup defined above. -
To look if the date is within 7 days in Django
class Order(models.Model): date_ordered = models.DateTimeField(auto_now_add = True) I have date_ordered field inside order model. And now i want to check if the date_ordered and today's date is within 7 days or not inside views.py . For today's date i have used : current_day = datetime.datetime.now() ( if i need to use another, please suggest) Can anyone please help me. -
Django Custom BaseUserManager: overwritten create_user is not getting used, overwritten create_superuser is working flawless. How?
I am working on a Django project, where I have a custom AbstractBaseUser and a custom BaseUserManager. Logically I created those pretty early and since they were doing what they are supposed to, I went on in the project. Now I am at a point, where I want to add the atribute userTag to the custom User and I want to call the function generate_userTag, when an user is created (same for superuser). So I added the fuction to the create_user I already had "working"; at least I thought it would. Turns out, no changes I make in the create_user function are getting applyed or have any impact on the project. Its like the fuction never gets called. I added an ValueError that should raise erytime the function is getting called, but when I register a new user from the testsite, there is no error and the user gets created without the userTag. Now the weird part: I tested to create a superuser and to my surprise it was working flawlessly. The superuser gets created, with the userTag. Everything fine. So my question: What could cause Django to not call the custom create_user, when creating a user, but call the … -
Adding Django Groups Programatically
I have set up a very basic Django website and I am looking to create a moderator group. I am unsure how to go about creating this programatically. Mainly, I am worried about which file I would need to put it in, and whether or not when I create it, will it show up on my admin site as a group. Otherwise, how else can I confirm it is made? Can I create groups from any app? For example, I have an app called 'users' which doesn't contain any models. Can I simply create my moderator group with example code for a generic group below in views.py or will that not work? from django.contrib.auth.models import Group, Permission from django.contrib.contenttypes.models import ContentType from api.models import Project new_group, created = Group.objects.get_or_create(name='new_group') ct = ContentType.objects.get_for_model(Project) permission = Permission.objects.create(codename='can_add_project', name='Can add project', content_type=ct) new_group.permissions.add(permission) Thanks for any help in advance! -
djongo.exceptions.SQLDecodeError
I am working on a Django project with MongoDB. for that I am using Djongo package. whenever I am running the command for migrate it will give me SQLDecoderError. This error from all auth migration file, my functionality is users can sign in with Twitter so that's why I am working on Django-allauth. Error in shell: Operations to perform: Apply all migrations: account, admin, auth, common, contenttypes, sessions, sites, socialaccount, users Running migrations: Applying account.0003_auto_20210915_1059... Traceback (most recent call last): File "/home/nividata/projects/venv_latino/lib/python3.8/site-packages/djongo/cursor.py", line 51, in execute self.result = Query( File "/home/nividata/projects/venv_latino/lib/python3.8/site-packages/djongo/sql2mongo/query.py", line 786, in __init__ self._query = self.parse() File "/home/nividata/projects/venv_latino/lib/python3.8/site-packages/djongo/sql2mongo/query.py", line 878, in parse raise e File "/home/nividata/projects/venv_latino/lib/python3.8/site-packages/djongo/sql2mongo/query.py", line 859, in parse return handler(self, statement) File "/home/nividata/projects/venv_latino/lib/python3.8/site-packages/djongo/sql2mongo/query.py", line 891, in _alter query = AlterQuery(self.db, self.connection_properties, sm, self._params) File "/home/nividata/projects/venv_latino/lib/python3.8/site-packages/djongo/sql2mongo/query.py", line 425, in __init__ super().__init__(*args) File "/home/nividata/projects/venv_latino/lib/python3.8/site-packages/djongo/sql2mongo/query.py", line 84, in __init__ super().__init__(*args) File "/home/nividata/projects/venv_latino/lib/python3.8/site-packages/djongo/sql2mongo/query.py", line 62, in __init__ self.parse() File "/home/nividata/projects/venv_latino/lib/python3.8/site-packages/djongo/sql2mongo/query.py", line 441, in parse self._alter(statement) File "/home/nividata/projects/venv_latino/lib/python3.8/site-packages/djongo/sql2mongo/query.py", line 502, in _alter raise SQLDecodeError(f'Unknown token: {tok}') djongo.exceptions.SQLDecodeError: Keyword: Unknown token: TYPE Sub SQL: None FAILED SQL: ('ALTER TABLE "account_emailaddress" ALTER COLUMN "id" TYPE long',) Params: ([],) Version: 1.3.6 The above exception was the direct cause of the following exception: Traceback (most … -
How does 'likedit' in django_comments_xtd work from source code perspective?
In django comments extended framework, When user clicks on "likedit" for one comment, template file user_feedback.html will be rendered. {% if show_feedback and item.likedit_users %} <a class="badge badge-primary text-white cfb-counter" data-toggle="tooltip" title="{{ item.likedit_users|join:'<br/>' }}"> {{ item.likedit_users|length }}</a> {% endif %} <a href="{% url 'comments-xtd-like' item.comment.pk %}" class="{% if not item.likedit %}mutedlink{% endif %}"> <span class="fas fa-thumbs-up"></span></a> Based on above source codes, I can not figure out, How is the 'likedit' implemented, in other words, how is a HTTP request with POST method invoked ? I did not even find any thumb-up icon is included in above source code. -
Django Html get dictionary value from index
How can I get the value from my dictionary using the forloop counter? The current way that I'm doing it doesn't show anything. Extension.py @register.filter def get_item(dictionary, key): return dictionary.get(key) Views.py {% for project in projectList %} <tr> <td><h5>{{ project.id }}</h5></td> <td><h5>${{ project.allBudgets|get_item:forloop.counter0 }}</h5></td> </tr> {% endfor %} -
Query for favorites of user in Django
I want to query for the favorites a user has in Django. Every user has a profile (userprofile) and the favorites are stored in this userprofile Model. I want to be able to query for the favorites (they are userprofiles) only using the id of the user. This is what I have but does not work (it returns an empty query even though the user has 3 favorites): favorites = UserProfile.objects.filter(favorites__user__id=user_id) My User Model: class User(AbstractUser): usertype = models.PositiveSmallIntegerField(choices=constants.USER_TYPE_CHOICES ) profile = models.OneToOneField(UserProfile, on_delete=models.CASCADE, primary_key=False) token = models.CharField(max_length=10, default='') My UserProfile Model: class UserProfile(models.Model): birth_date = models.DateField(default=datetime.date(1900, 1, 1)) favorites = models.ManyToManyField('self', symmetrical=False) How should I do this? Thank you a lot! -
Get Multiple fields in from an Annotate with Max in Django
I would like to get multiple fields from an 'annotate' in Django, with a Max and a Filter. So, I have this Query: w=Wherever.objects.prefetch_related('wherever2').filter(...).values(...).annotate(max_wherever2_field1=Max('wherever2__field1', filter=Q(wherever2__field2=False))) So, considering the highest value in field1, and the filter in Field2, I want to get the rest of fields of the same register in wherever2 table. How can I do it? -
Wagtail root page does not render body content
I created a wagtail site which is supposed to be in Spanish. The problem is that I cannot see the root page in 127.0.0.1:8000. However I can see it when I click on preview: Page when in preview When I click "View live", I do not see the content of the page. Also, I noticed that the wagtail user bar has only the option "Go to Wagtail Admin": Here is the page in live And finally, here is my page in admin panel: Page in admin panel At first, I thought I might have messed up with the languages. So I changed LANGUAGE_CODE to 'es' and LANGUAGES variable in settings and I also changed the locale from 'en' to 'es' in the Admin panel. But I do not know what else to try. Thanks for your time. -
how to change faster methods to optimize in django
how to change faster methods to optimize in django , Actually u used loop but its take more time to get output.. Anyone please help me to solve this problem MY looping result = dict() balace_amount =0 total_quantity =0 for item in sales_by_customer: invoice_date = item['order__created_on'] invoice_date = invoice_date.strftime('%m/%d/%Y') entity_name = Entities.objects.values_list('name',flat=True).filter(id=item['order__entity_id']).first() group_by_str = f"{item['order__entity_id']}" total_quantity +=item['order_quantity'] unit_price = item['price'] if percentage_amt: if float(percentage_amt) > 0: unit_price = float(unit_price) + (float(percentage_amt)*float(unit_price))/100 else: percentage_amt = float(percentage_amt) percentage_amt = abs(percentage_amt); unit_price = float(unit_price) - (float(percentage_amt)*float(unit_price))/100 unit_price_with_qty = unit_price * item['order_quantity'] balace_amount += unit_price_with_qty nyb_code = ProductCodes.objects.values_list('nyb_code',flat=True).filter(product_id=item['product_id']).filter(flavour_id=item['flavour_id']).filter(quantity_id=item['quantity_id']).first() if group_by_str in result: result[group_by_str]['invoice'].append({"entity_name": entity_name,"invoice_no": item['order__order_id'],"invoice_date": invoice_date,"product_title": item['product__title'],"flavour_title": item['flavour__title'],"quantity_title": item['quantity__title'],"nyb_code": nyb_code,'unit_price': unit_price,"entity_id": entity_name,"qty": item['order_quantity'],"sub_total": unit_price_with_qty,"balace_amount": balace_amount}) result[group_by_str]['total_amount'] = balace_amount result[group_by_str]['total_quantity'] = total_quantity else: result[group_by_str] = {'order__brand_id': item['order__brand_id'],'total_quantity': item['order_quantity'],'total_amount': item['total_price'],"entity_name": entity_name, 'invoice': [{"entity_name": entity_name,"invoice_no": item['order__order_id'],"invoice_date": invoice_date,"product_title": item['product__title'],"flavour_title": item['flavour__title'],"quantity_title": item['quantity__title'],"nyb_code": nyb_code,'unit_price': unit_price,"entity_id": entity_name,"qty": item['order_quantity'],"sub_total": unit_price_with_qty,"balace_amount": item['total_price']}]} sales_by_customer = list(result.values()) -
how to completely remove the recent action panel from Django admin UI
how to completely remove the recent action panel from Django admin UI I have done a lot of searching and all leads to how to clear the data in the panel from the database .. but what am looking to do is completely remove the panel from my admin Userinteraface .. any help on how to do this? what I've tried : tried to override the base_site.html for the admin and it worked for override colors and styles and other blocks but not working with the sidebar block {% extends "admin/base.html" %} {% load i18n static %} {% block title %}{{ title }} | {% trans "G-Attend" %}{% endblock %} {% block extrastyle %} <link rel="stylesheet" type="text/css" href="{% static 'custom_admin_styles/admin_override.css' %}"> {% endblock %} {% block branding %} <h1 id="site-name"> <b style="color: #1f76bc;size: 80;"> G </b> Attend </h1> {% endblock %} {% block sidebar %} <div id="content-related"> </div> {% endblock %} {% block nav-global %}{% endblock %}