Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to set new value for a key in Django Session_data
What I have in my encoded session_data is: 'workspaceKey':'8d7f4b3106c740c1a54970a8b67d156d', '_auth_user_hash': '7e024dd67ccb0e2aaab9ac1a92887109f7f020e4', '_auth_user_id': '1', '_auth_user_backend': 'django.contrib.auth.backends.ModelBackend' What I have tried is (1st approach): request.session['workspaceKey'] = "123f4b3106c740c1a54970a8b67d111d" but it is not updating workspaceKey is my existing session_data Another approach what I tried is: sessionid = Session.objects.get(session_key=session_key) sessionid.get_decoded()['workspaceKey'] = "8d7f4b3106c740c1a54970a8b67d111d" Again it is not updating workspaceKey is my existing session_data. I have also tried below combinations with respect to above approach request.session.modified = True SESSION_SAVE_EVERY_REQUEST=False What I expect in my output as (new workspace key should be updated) 'workspaceKey':'123f4b3106c740c1a54970a8b67d111d', '_auth_user_hash': '7e024dd67ccb0e2aaab9ac1a92887109f7f020e4', '_auth_user_id': '1', '_auth_user_backend': 'django.contrib.auth.backends.ModelBackend' -
django admin add view Readonly Dropdown
class CaseAdmin(admin.ModelAdmin): list_display = ['id', 'Status','Title','CaseCategory','Group'] list_filter=['Status'] date_hierarchy = 'CreatedDate' raw_id_fields = ('Customer',) fields= ['Customer', 'Title', 'Priority', 'Status', 'CaseCategory', 'Detail', 'Group', 'User'] here its my admin.py. The User field coming from Users table to the dropdownlist but this dropdown must be just readonly. here its my screenshot screenshot here. -
If statement in my Django template...Is there a better way?
In my Django template: I'm trying to add an extra div around my for loop only if the length of the data being passed to the template is 3. This is what I'm trying right now but it seems like there could be better way than doing two if statements to check for the length: {% if items|length == 3 %} <div class='three-item-wrap'> {% endif %} {% for item in items %} ....... {% endfor %} {% if items|length == 3 %} </div> //close .three-item-wrap {% endif %} -
Loosing timezone on data retrieval over objects
I have a model which has a DateTimeField for a start date. When I'm creating new objects of the model and store them in the postgre database the given timezone is 'Europe/Berlin'. I confirmed it just before calling save() and the entries have the correct offsets in the database. The timezone of the database also matches with the timezone of the objects. But when I retrieve objects of the model over .filter() the timezone is set to 'UTC', so I'm loosing the timezone. Of course it should be 'Europe/Berlin' as well. Inside settings.py is also the correct timezone TIME_ZONE = 'Europe/Berlin' Can anybody help me? -
AttributeError at /blog/index/ 'tuple' object has no attribute 'get'
I'm a beginner in python.I get an error and I have been struggling with for hours. AttributeError at /blog/index/ 'tuple' object has no attribute 'get' Request Method: GET Request URL: http://localhost:8000/blog/index/ Django Version: 1.10.2 Exception Type: AttributeError Exception Value: 'tuple' object has no attribute 'get' Exception Location: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/middleware/clickjacking.py in process_response, line 32 Python Executable:/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python Python Version: 2.7.13 And this is traceback: File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner 39. response = get_response(request) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/deprecation.py" in __call__ 135. response = self.process_response(request, response) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/middleware/clickjacking.py" in process_response 32. if response.get('X-Frame-Options') is not None: Exception Type: AttributeError at /blog/index/ Exception Value: 'tuple' object has no attribute 'get' This is a simple project ,I built a new app named blog ,and new directory named templates in blog ,then I built index.html in templates . The index.html : <h1>Hello blog</h1> The blog.views : from django.shortcuts import render from django.http import HttpResponse def index(request): return render(request,'index.html'), The settings: BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) DEBUG = True ALLOWED_HOSTS = [] INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blog'] enter image description here -
Webpage that imports data, process data with a script and exports data visualisation as pdf or docx
I'm currently working on a webpage where I want to have an application that can through an import button import a csv-file. Then behind the scenes I want to process the data, e.g. using a Python script, and through that get some data visualizations. These data visualizations should be displayed on the webpage combined with a text field, where the user can enter the interpretation of the data visualizations. Finally, the user should be able to export the data visualizations combined with his/her interpretation in a report as a pdf- og docx-file. Currently, I'm using the Python web framework, Django, since it is based on Python and might co-operate better with Python scripts. However, I'm still a bit unsure if this framework is able to do what I want. Does any of you have any experience with importing csv-files, generating data visualizations and exporting pdf's or docx's in Django or would you recommend another framework maybe based on another language? Looking forward to get some feedback plus validation or invalidation of my first steps towards my goal! -
Django admin inline with custom queryset
I've got two models: class Parent: ... class Child: parent = models.ForeignKey(Parent) In the model admin of the Parent I want to show an inline of the Child with a custom queryset, not only the ones related to the parent through the fk field. I've tried: class ChildInline(admin.TabularInline): model = Child def get_queryset(self, request): return Child.objects.filter(<my custom filter>) class ParentAdmin(admin.ModelAdmin): inlines = [ChildInline] But still the only children shown in the inline are the ones related through the fk field. Is it possible to do this? -
Why dispatch method is taking long time to call target method in Django Rest Framework?
I have this method class RunningQuizAuthenticationView(APIView): def dispatch(self, *args, **kwargs): print(time.time()) return super(RunningQuizAuthenticationView, self).dispatch(*args, **kwargs) def get(self, request: Request, key: str) -> Response: print(time.time()) ..... ...... Now, once I get both the time, I take the difference of this time, the difference time is about 30 ms, can you explain to me why this is taking so much time, for the login request it takes about 0 ms but for other requests it takes a long time to reach target method from dispatch method, please help me, Thank you -
Static files not loading on Heroku : Django
I am deploying my Django application on Heroku. It has been deployed successfully. But static files are not loading. I followed this link, but when Whitenoise is included, the command python manage.py collectstatic --noinput fails. my Procfile: python manage.py collectstatic --noinput web:python manage.py runserver web: gunicorn MovieTracker.wsgi --log-file - heroku ps:scale web=1 I have also tried with : heroku config:set DISABLE_COLLECTSTATIC=1 and also : heroku config:set DISABLE_COLLECTSTATIC=0 The settings.py file is: BASE_DIR = os.path.dirname(os.path.dirname(__file__)) PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'tracker', ) MIDDLEWARE_CLASSES = ( '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', # 'whitenoise.middleware.WhiteNoiseMiddleware', ) STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, "/tracker/static") # STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' how can I get my static files working in heroku deployment? -
Django how to link a button to http response
I want to create a simple page which requires a login and has a button which on clicking would download a csv file. Below works good, but this directly downloads the file. @login_required(login_url='/admin/login/') def index(request): response = HttpResponse(content_type='text/csv') response['Content-Disposition'] = 'attachment; filename="data.csv"' writer = csv.writer(response) writer.writerow(['First row', 'Foo', 'Bar', 'Baz']) writer.writerow(['Second row', 'A', 'B', 'C', '"Testing"', "Here's a quote"]) return response I can create a button and link view to it's template, but how to I return the above response from it. <form action="#" method="get"> <input type="submit" value="Click" name="mybtn"> </form> -
Create react app + Django deployment Uncaught SyntaxError: Unexpected token <
I've been trying to deploy an app to pythonanywhere but the page is just blank, because main.6f259c1b.js file throws error` Uncaught SyntaxError: Unexpected token < ` I've been following the instuctions on this article https://www.fusionbox.com/blog/detail/create-react-app-and-django/624/ and this https://www.techiediaries.com/create-react-app-django/ both articles suggest to create a view with following content class FrontendAppView(View): """ Serves the compiled frontend entry point (only works if you have run `yarn run build`). """ def get(self, request): try: with open(os.path.join(settings.REACT_APP_DIR, 'build', 'index.html')) as f: return HttpResponse(f.read()) except FileNotFoundError: logging.exception('Production build of app not found') return HttpResponse( """ This URL is only used when you have built the production version of the app. Visit http://localhost:3000/ instead, or run `yarn run build` to test the production version. """, status=501, ) and in app/urls.py urlpatterns = [ url(r'^', FrontendAppView.as_view()) ] Those instructions don't work for me. It's something that related to pushState routing, react-routing, I don't know. My app works ok in development server in localhost:3000, it only seen in pythonanywhere and local apache server with mod_wsgi. This is my config of local apache(from Django documentation): WSGIScriptAlias / /home/user/projects/myproject/myproject/wsgi.py WSGIPythonHome /home/user/.virtualenvs/myproject WSGIPythonPath home/user/projects/myproject/ <Directory /home/user/projects/myproject/myproject> <Files wsgi.py> Require all granted </Files> </Directory> This is root DocumentRoot "/srv/http" Part of my … -
ImportError : no module named 'models'
Hye . im basically very new in python and django . i keep getting this error ImportError : no module named 'models' and i dont know why . please do help me . i try to customize my own registration form in django. the error is in line : from models import CustomUser in forms.py forms.py : from django.contrib.auth.forms import UserCreationForm, UserChangeForm from models import CustomUser class CustomUserCreationForm(UserCreationForm): def __init__(self, *args, **kargs): super(CustomUserCreationForm, self).__init__( *args, **kargs) del self.fields['username'] class Meta: model = CustomUser fields = ["email",] class CustomUserChangeForm(UserChangeForm): def __init__(self, *args, **kargs): super(CustomUserChangeForm, self).__init__(*args, **kargs) del self.fields['username'] class Meta: model = CustomUser register.html : {% extends "account/base.html" %} {% load crispy_forms_tags %} {% load i18n %} {% block head_title %}{% trans "Signup" %}{% endblock %} {% block content %} <div class= 'col-md-4 col-md-offset-4'> <h1>{% trans "Register" %}</h1> <p>{% blocktrans %}Already have an account? Then please <a href="{{ login_url }}">sign in</a>.{% endblocktrans %}</p> <form acction="account/register/" method="post"> {% csrf_token %} {{ form|crispy }} <input type="submit" value="Register" /> <button type="submit" class= 'btn btn-default'>{% trans "Sign Up" %} &raquo;</button> </form> </div> {% endblock %} views.py: from django.contrib.auth.decorators import login_required from django.shortcuts import render, redirect from custom_user.forms import CustomUserCreationForm #Create your views here def home(request): … -
run scrapy from bash and implement it in django
I have a bash script to run a scrapy crawler and that crawler it passes some raw_inputs it asks me the url and the domain and i type them in the command line. now i want to implement that bash script and crawler in a django template. I want that template to collect the url and the domain and send it to the crawler. How can i do it? this is part of my bash script #!/bin/bash cd /.../seo/ PATH=$PATH:/usr/local/bin:/home/omega/.local/bin/ export PATH scrapy crawl test -
Django messages not showing after redirect
I have this piece of code in my view: if _user.objects.user_exists(_email): auth.logout(request) messages.success(request, 'You already hold a verified account with us. Please login.') return redirect('accounts:login') and this in my template: {% if messages %} {% for message in messages %} <div>{{ message }}</div> {% endfor %} {% endif %} This sadly wouldn't work. But if I change return redirect('accounts:login') to return render(request, 'accounts/login.html'), the message would display. So what is it that's preventing the messages from showing up during a redirect? And for the message storage, I am using: MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage' Thanks for the help. -
Task IndexError('string index out of range',) in celery
I have created an asynchronous email sending to the job poster when job seeker applies for the job using celery and rabbitmq. I have used smtp(gmail) for email service.However I am getting an error which I could not figure out where exactly is the error coming from and how do i resolve it. The error is something like this Task job.tasks.send_resume_to_job_poster[a1d2f76e-5e38-4560-8576-0c43accff696] raised unexpected: IndexError('string index out of range',) Here is my code In a nutshell what I am doing is, I am generating the pdf from the html template and sending an email to the job poster but for testing I am using seeker email @shared_task def send_resume_to_job_poster(poster, seeker): resume = User.objects.get(email=seeker).resume html = render_to_string('resume/resume.html', {'resume': resume}) out = BytesIO() response = HttpResponse(content_type='application/pdf') response[ 'Content-Disposition'] = 'filename="resume_{}.pdf"'.format(resume.id) weasyprint.HTML(string=html).write_pdf(response, stylesheets=[ weasyprint.CSS(settings.STATIC_ROOT + '/css/pdf.css')]) # create resume email subject = "{} has applied for the job".format(resume.name) from_email = settings.EMAIL_HOST_USER to_email = [seeker] job_message = "if you don't want to recieve such message please we can't do anything for you." email = EmailMessage( subject, job_message, from_email, [to_email] ) email.attach("resume_{}.pdf".format(resume.id), out.getvalue(), 'application/pdf') return email.send() Error log in detail [2017-09-27 11:48:23,301: WARNING/ForkPoolWorker-1] html [2017-09-27 11:48:23,302: WARNING/ForkPoolWorker-1] <html> <head> <title>Tushant Khatiwada</title> </head> <body> <h1>Tushant Khatiwada</h1> <h3>Django … -
Use list(map(model_to_dict, queryset_list)) do not map the createtime and updatetime fields
I have a Test04 Model, and I give ctime and uptime fields. class Test04(models.Model): testTime = models.DateTimeField(null=True) ctime = models.DateTimeField(auto_now_add=True) uptime = models.DateTimeField(auto_now=True) But when I use the list(map(model_to_dict, queryset_list)) method to convert the queryset to dictionary, I find the ctime and uptime do not convert: from django.forms.models import model_to_dict print (models.Test04.objects.all()) all =models.Test04.objects.all() print (all[0].ctime) # 2017-09-26 07:49:02.012489+00:00 print (list(map(model_to_dict, all))) # [{u'id': 1, 'testTime': datetime.datetime(2017, 9, 26, 7, 49, 1, 973016, tzinfo=<UTC>)}, {u'id': 2, 'testTime': datetime.datetime(2017, 9, 26, 8, 3, 24, 665944, tzinfo=<UTC>)}, {u'id': 3, 'testTime': datetime.datetime(2017, 9, 26, 0, 12, 12, 683801, tzinfo=<UTC>)}, {u'id': 4, 'testTime': datetime.datetime(2017, 9, 26, 0, 12, 43, 2169, tzinfo=<UTC>)}, {u'id': 5, 'testTime': datetime.datetime(2017, 9, 26, 8, 13, 16, 164395, tzinfo=<UTC>)}, {u'id': 6, 'testTime': datetime.datetime(2017, 9, 26, 0, 14, 8, 812063, tzinfo=<UTC>)}, {u'id': 7, 'testTime': datetime.datetime(2017, 9, 26, 0, 15, 32, 945493, tzinfo=<UTC>)}] In the last line's output, you see there is no ctime and uptime in every dictionary. -
Django save base64 string to filesystem using models.ImageField
I am trying to upload image to file system using python django. I dont have any idea on how to proceed further. in my model.py: Class Test(object): mission = models.TextField(blank=True) image = models.ImageField(upload_to='documents/images/',blank=True) account = models.OneToOneField(Account, related_name='account') in my view.py def add_image(request, account): req = get_request_json(request) data = Test.objects.add_image(account, req) in my manager.py Class TestManager(models.Manager): def add_image(self, account, input): acc = self.get(account=account) acc.save() return acc; But I am not sure how to proceed from here. I would like to know how to save the base64 image string to the specified location and store the path/file name in database? I have worked with python where I write the files to a directory and get the path and store in db. Here I want to use the django options. I have to repeat the same process with other file formats too. -
Timestamp TruncHour aggregation in Django
I have a data with peoplecount and timestamp which I want to show aggregated in an hour wise format.The model for peoplecount object is like below: class PeopleCount(models.Model): """ A webapp model classs to store People Count Details. """ timestamp = models.DateTimeField(auto_now=True) people_count_entry = models.IntegerField(blank=True, null=True) people_count_exit = models.IntegerField(blank=True, null=True) store = models.ForeignKey(Store, blank=True, null=True) profile = models.ForeignKey(Profile) camera = models.ForeignKey(Camera) recorded_time = models.DateTimeField(null=True, blank=True) def str(self): return "People Count {}".format(self.timestamp) class Meta: verbose_name = "People Count" verbose_name_plural = "People Count" ordering = ['-timestamp'] and I am using below query to get data on hour basis: queryset = PeopleCount.objects.filter( **json.loads( self.request.query_params['filter'])['object_params'] ).annotate( time_series=TruncHour('recorded_time')).values( 'time_series').annotate( people_count_entry=Sum('people_count_entry')).values( 'time_series', 'people_count_entry').annotate( people_count_exit=Sum('people_count_exit')).values( 'time_series', 'people_count_entry', 'people_count_exit') The problem with above query is that it actually doesn't aggregate on hour basis and instead keep individual values for each timestamp which I have to manipulate at client side. The approach on client side works but it takes a lot of time for larger queryset. Hope my problem statement is clear. Thanks. -
Not able to create a plan using dj-stripe from django admin
I am using dj-stripe==1.0.0.post1. I have followed the installation steps as mentioned here. When I go to the django admin and try to create a plan, I get this error KeyError at /admin/djstripe/plan/add/ 'stripe_id' here is the full stack trace: ERROR 2017-09-27 11:07:57,600 django.request Internal Server Error: /admin/djstripe/plan/add/ Traceback (most recent call last): File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site- packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site- packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site- packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site- packages/django/contrib/admin/options.py", line 551, in wrapper return self.admin_site.admin_view(view)(*args, **kwargs) File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site- packages/django/utils/decorators.py", line 149, in _wrapped_view response = view_func(request, *args, **kwargs) File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site- packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site- packages/django/contrib/admin/sites.py", line 224, in inner return view(request, *args, **kwargs) File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site- packages/django/contrib/admin/options.py", line 1508, in add_view return self.changeform_view(request, None, form_url, extra_context) File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site- packages/django/utils/decorators.py", line 67, in _wrapper return bound_func(*args, **kwargs) File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site- packages/django/utils/decorators.py", line 149, in _wrapped_view response = view_func(request, *args, **kwargs) File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site- packages/django/utils/decorators.py", line 63, in bound_func return func.__get__(self, type(self))(*args2, **kwargs2) File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site- packages/django/contrib/admin/options.py", line 1408, in changeform_view return self._changeform_view(request, object_id, form_url, extra_context) File "/Users/swapnil/Work/li-django/venv/lib/python3.6/site- packages/django/contrib/admin/options.py", line 1448, in _changeform_view self.save_model(request, new_object, form, not add) … -
Dynamic table and model generate in django
I want to create some database tables and models.Model on api call in django. I created on demand Model model = type(str(project_slug + "_tbl_name"), (models.Model,), attrs) and I want to create table like this db.create_table(table_name, fields) create_table was from south but south is not available in Django 1.11 what I am using How can I generate Model and database tables programmatically? -
django removing user table
I'm new to Django and creating my first app. I created a user model not understanding that there was one inbuilt. I have removed the user table. # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models from django.contrib.auth.models import User # Create your models here. # class User(models.Model): # firstname = models.CharField(max_length=250) # lastname = models.CharField(max_length=250) # email = models.CharField(max_length=250) # password = models.CharField(max_length=250) # newsletter = models.BooleanField(default=0) # accountlevel = models.BigIntegerField(default=1) # reportsCreated = models.BigIntegerField(default=0) # # def __str__(self): # return self.firstname +" "+ self.lastname +" - "+self.email class Account(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) reports = models.IntegerField(default=3) accounttype = models.CharField(default='Free') monthlycost = models.FloatField(default=0.0) def __str__(self): return self.user.username + " - " + self.accounttype I now need to like the ForeignKey from Account and report tables to the inbuilt user model. when I run: python manage.py makemigrations I get the following error django.contrib.admin.sites.AlreadyRegistered: The model User is already registered -
Django django-autocomplete-light search not complete
I am using django-autocomplete-light plugin in my project. Plugin works just fine, but if the company name is made from more than one word it doesn't search by the second or third word, e.g. Bayerische Motoren Werke(BMW) if I search for Baye... it fill find it, but searching Mo... or Wer... it won't. I know it's an autocomplete plugin, but I am wondering if there is a workaround. views.py class CompanyAutoComplete(autocomplete.Select2QuerySetView): def get_queryset(self): qs = Company.objects.all() if self.q: qs = qs.filter(name__istartswith=self.q) | qs.filter(comNumber__istartswith=self.q) return qs urls.py urlpatterns += [ url( r'^autocomplete/$', views.CompanyAutoComplete.as_view(model=Company), name='company-autocomplete', ), ] models.py class Company(models.Model): name = models.CharField(max_length=255) comNumber = models.CharField(max_length=255) law = models.CharField(max_length=255) country = models.CharField(max_length=255, null=True, blank=True) city = models.CharField(max_length=255, null=True, blank=True) street = models.CharField(max_length=255, null=True, blank=True) house_number = models.CharField(max_length=255, null=True, blank=True) email = models.CharField(max_length=255, null=True, blank=True) def __str__(self): return self.name.encode("utf-8") def get_absolute_url(self): return reverse('company-detail', args=[str(self.id)]) def __unicode__(self): return '%s' % (self.name,) -
Is there a way to update a ListView in Django, without refreshing the HTML page?
I need to update a ListView in Django, based on a certain time. I tried to do with JavaScript but as a newbie in Django, I could not figure out how to do it. -
Django rest framework how to serialize a list of strings?
I want to give a list of strings in postman, for example: ['string1', 'string2', 'string3', 'string4', 'string5'] But when it reaches serializer.is_valid() it gives me: "non_field_errors": [ "Invalid data. Expected a dictionary, but got str." ] How can I make the serializer to except a list of strings? -
How can I map the integer to corresponding text?
In the templates, there is a data.grade which is integer. If the data.grade == 1, I want to the place shows VIP, if equals to 2, I want to shows Normal {{ data.grade }} # there only shows 1 or 2, but I want to shows VIP or Normal