Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
how to prevent a user from upvoting or downvoting twice
I am working on an application which as an upvote and downvote functionality. How can i prevent a user from upvoting or downvoting more than once. views.py @login_required def upvote(request, pk): supplier_vote = get_object_or_404(User, id=pk) supplier_vote.upvotes += 1 supplier_vote.save() return HttpResponseRedirect(reverse('view-supplier')) @login_required def downvote(request, pk): supplier_vote = get_object_or_404(User, id=pk) supplier_vote.downvotes -= 1 supplier_vote.save() return HttpResponseRedirect(reverse('view-supplier')) -
How to prevent a supplier from upvoting and downvoting himself
I am working on a Supplier Management System. I have a page where users could view all suppliers on the application. on the same page, users can upvote and downvote suppliers, is there a way that i could make the supplier not able to upvote or downvote his self. I am thinking if there is a way i can pass the supplier.user into the context which identifies the supplier, perhaps doing something like this but it doesn't seem to work. I could then pass this into the template {% if supplier.user == request.user %}content...{% endif %} Presently, supplier.user return nothing. views.py def Viewsupplier(request): title = "All Suppliers" suppliers = User.objects.filter(user_type__is_supplier=True) # Get the updated count: suppliers_votes_count = {} for supplier in suppliers: upvote_count = supplier.upvotes downvote_count = supplier.downvotes supplier_count = {supplier: {'upvote': upvote_count, 'downvote': downvote_count } } suppliers_votes_count.update(supplier_count) context = {"suppliers":suppliers, "title":title, "suppliers_votes_count": suppliers_votes_count} return render(request, 'core/view-suppliers.html', context) view-supplier.html <thead> <tr> <th>No</th> <th>Email</th> <th>Votes</th> </tr> </thead> <tbody> {% for supplier in suppliers %} <tr> <td>{{forloop.counter}}</td> <td>{{supplier.email}}</td> <td> <div class="table-data-feature"> {% if supplier.user == request.user %}<a href="{% url 'upvote' supplier.id %}">{% endif %} <button class="item" data-toggle="tooltip" data-placement="top" title="Like"> <i class="zmdi zmdi-thumb-up"></i></button> {% if supplier.user == request.user %}</a>{% endif %} &nbsp;<button>{{supplier.upvotes}}</button>&nbsp; {% … -
Ajax Query to fetch drop down items in django admin
I am trying to populate a subcategory which is a many to many field based on the category chosen in a course model. This is in continuation to my other question I have asked earlier.[https://stackoverflow.com/questions/66673747/selecting-many-to-many-fields-based-on-selected-foreign-key-drop-down-in-django][1] I have tried the below form,view, url and added a js function to filter subcategories and populate them in the form.But my js function is not working. Please let me know where I am going wring. #forms.py class CoursesForm(forms.ModelForm): subcategory = forms.ModelMultipleChoiceField(queryset=Subjectsubcategories.objects.none()) # subcategory = [(c.color, c.color) for c in Subjectsubcategories.objects.filter(category= self.category)] class Meta: model= Courses fields='__all__' def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['subcategory'].queryset = Subjectsubcategories.objects.none() if 'category' in self.data: try: category_id = int(self.data.get('category')) self.fields['subcategory'].queryset = Subjectsubcategories.objects.filter(category=category_id) except (ValueError, TypeError): pass elif self.instance.pk: self.fields['subcategory'].queryset = self.instance.category.subcategory_set.order_by('subcategoryname') #views.py def get_subcategories(request): #sub_dict={} if request.is_ajax() and request.method=='POST': category_id= request.GET.get('category') print(category_id) # category= Subjectcategories.objects.get(id=category_id).first() subcategories= Subjectsubcategories.objects.filter(category=category_id) return JsonResponse({'subcategory':subcategories}) #urls.py urlpatterns = [ url(r'^ajax_get_subcategories/$', views.get_subcategories, name='ajax_get_subcategories'), ] #sub_cats.js (function($) { $(function() { $('#id_category').change(function(e){ alert("test") e.preventDefault(); var category = $(this).serialize() $.ajax({ type : 'POST', url : "{% url 'ajax_get_subcategories' %}", data : { 'category_id': category, }, success : function(data){ $("#id_subcategory").html(`<tr> </tr>`)}, error : function(response){ alert(response["responseJSON"]["error"]); } }); }); }); })(django.jQuery); #admin class Media: js= ('admin/js/jquery-3.5.1.min.js','admin/sub_cats.js') -
Django dynamic data in modal window, content changes based on one of select form
I need a guidance on what and how to use in my situation. I have a modal that adds a new object. For simplification lets assume model only has 2 fields that are based on another models. class Object1(models.Model): object2_fk = models.ForeignKey(Object2) object3_fk = models.ForeignKey(object3) class Object2(models.Model): name = models.CharField() class Object3(models.Model): name = models.CharField() On my website (using only bootstrap + js/jquery if needed) I have a button "add new Object1" which opens modal with 2 Select forms: <div class="modal-body"> <div class="col-sm px-5"> <select class="form-select"> <option selected>...</option> {% for object in object2 %} <option>{{object}}</option> {% endfor %} </select> </div> <div class="col-sm px-5"> <select class="form-select"> <option selected>...</option> {% for object in object3 %} <option>{{object}}</option> {% endfor %} </select> </div> </div> And in this form it works perfectly but not the way I want. I want to select an object from first select form and want the selected value to be a filter for a second select. For example: In first select I choose APPLE Then I want to choose in the second select from APPLE 1 APPLE 2 APPLE 3 APPLE 4 APPLE 5, etc. (always like this, APPLE lands in front). Any idea on how to achieve it? Of … -
How to get an object from database in a different server in python?
I am trying to work with a machine learning and a web server with django. Machine learning server creates machine learning models and writes them to the database by using pickle. However, when i try to read them from database by using pickle in the machine learning server, i could not get the objects correctly. It throws "Can't get attribute 'Regressor' on <module 'main'" exception. How can i get them correctly in the web server? -
Handle Error when sending activation email in DRF
I had written an APIView where the user can register a new account on my website. When the user successfully creates an account, I send them a verified email. The code is below def create(self, request, *args, **kwargs): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) self.perform_create(serializer) headers = self.get_success_headers(serializer.data) user = CustomUser.objects.get(email=serializer.data.get('email')) token = RefreshToken.for_user(user).access_token current_site = get_current_site(request).domain relativeLink = reverse('verify-email') absurl = 'http://' + current_site + \ relativeLink + '?token=' + str(token) email_body = 'Hi ' + user.fullname + \ ' Use link below to verify your email \n' + absurl data = { 'to_email': user.email, 'email_body': email_body, 'email_subject': '[GetTheDeal] Verify your email' } send_email(data) return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers) But if the send_email() had failed. In my cases because I'm using 2-factor auth for my google account. In that scenario, what should I do? because if I don't, I'm getting an error but the account creates successfully, that doesn't make sense to me. Here is send_email() function def send_email(data): email = EmailMessage(to=[data['to_email']], subject=data['email_subject'], body=data['email_body']) email.send() -
How to create href link from one Django app to another
I know this has been asked multiply times before, but I still don't get it. How can I create a href-link in one Django app that sends the user to a 2nd app? This is my setup: myproject/ manage.py myproject/ __init__.py settings.py urls.py asgi.py wsgi.py app1/ migrations/ templates/ app1/ app1.html __init__.py admin.py apps.py models.py tests.py views.py app2/ migrations/ templates/ app2/ app2.html __init__.py admin.py apps.py models.py tests.py views.py myproject/urls.py from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('app1/', include('app1.urls'), name='app1'), path('app2/', include('app2.urls'), name='app2'), ] myproject/settings.py INSTALLED_APPS = [ 'app1.apps.App1Config', 'app2.apps.App2Config', 'django.contrib.admin', ... ] app1/urls.py (analogous for app2) from django.urls import path from . import views urlpatterns = [ path('', views.app1, name='app1'), ] app1/views.py (analogous for app2) from django.template import loader from django.http import HttpResponse def app1(request): template = loader.get_template('app1/app1.html') return HttpResponse(template.render()) app1/templates/app1/app1.html (analogous for app2) <p>This is the template of app1.</p> <a href="app2/">Go to App2</a> # doesn't work <a href="app2/app2.html">Go to App2</a> # doesn't work <a href="./app2/app2.html">Go to App2</a> # doesn't work My problem is that this sends me to the address 127.0.0.1:8000/app1/app2/ which gives me a 404 error. However, I can access app2 via 127.0.0.1:8000/app2/ without a problem. -
How should I improve my styling here (python class, Django models)?
My main model class looks like this: class Article(models.Model): title = models.CharField(max_length=120) content = models.TextField() authors = models.TextField(max_length=200) year = models.IntegerField() form = models.TextField(choices=FORMS) language = models.TextField(choices=LANGUAGES) region = models.TextField(choices=REGIONS) tags = models.TextField() def __str__(self): return self.title And, for my api to send backend data to front end, I have a serializers class that looks like this: class ArticleSerializers(serializers.ModelSerializer): class Meta: model = Article fields = ('id', 'title', 'content', 'authors', 'year'...) Clearly, the current way of writing fields as a bunch of hard-coded strings is very clumsy and prone to mistake (since I might change the fields in Article class but forget to update the fields in the serializer). So my question is, how can I improve the style of fields? Also, another side question, what is this type of coding rule / principle called, when you try to make one part of the code to be dependent on the other, so you need to change one part, instead of always having to remember changing both parts? Thanks! -
Where to save file for load in django project, FileNotFoundError
I have some_file.pkl with machine learning model and I need it load in my django project. Loading process is correct, because its working with another project. But django say: FileNotFoundError: [Errno 2] No such file or directory: 'some_file.pkl' Location of pickle files is under django-app what I think is a reason of error but i cant find right location for files to load, in Djano framework, please help. Here is my view: def home(request): content = '' if request.method == 'POST': if request.POST.get('sms'): content = request.POST.get('fakenews_textarea') #Load the Model back from file with open("FakeNews_Model.pkl", 'rb') as file: Fake_News_Model = pickle.load(file) #Load the Model back from file tfidf_vectorizer = pickle.load(open("tfidf.pickle", "rb")) return render(request,'web/home.html') -
Saving to a Django model ForeignKey with different key but the same value name
Good day SO. I hope you understood my question. I want to save to my model with a foreignkey. However, on the jobminor model, there are multiple value with the same name but different ID. models: class Applicant(models.Model): name = models.CharField(...) job = models.ForeignKey("JobMinor"...) class JobMinor(models.Model): job_name = models.CharField(...) job_major = models.ForeignKey("JobMajor"...) ... class JobMajor(models.Model): job_title = models.CharField(...) ... On my job model, this is the data inside: JobMajor1: JobMinor1 - ID1 JobMinor2 - ID2 Others - ID3 JobMajor2: JobMinor4 - ID4 JobMinor5 - ID5 Others - ID6 My Minor Jobs is inside a Select2 with an ID as value and Name as text so when saving, I am getting an ID. This is how I save my job in Applicant: job = request.POST['job'] # Others with ID 6 # Assign to DB since excluded from forms. Reason, Job is on a Select2 if job: job = JobMinor.objects.get(id=job) applicant.job = job So I am saving an instance of Job to Applicant( if my term is correct). However if I try to save Others with ID 6, I get get() returned more than one JobMinor -- it returned 13! Error. -
How to send an email in Django based on a condition?
I've a model where users fill out the form and enter details like start date and end date, based on the start date I want the emails to be sent automatically. Like start date is 03/23/21 and I want a email to be sent after 10 days and then again after 20 days. Currently I'm using Amazon SES for email service. Can someone please guide me how to set this up? I checked CRON and CELERY but couldn't find a way to do it. -
TypeError: 'Variants' object is not iterable in django rest framework
Here I am trying to create an add-products API. The product model is related to Category,Brand, Collection, Picture, and Variants models. Here Category, Picture, and Variants are M2M relationships with the Product model. From the frontend, all the chunks of data are sent at once to create a product object. I have added categories and pictures using .set() method. But for variants, I have to create variants objects first and then add them to product. How to do this. I tried but I got this error. TypeError: 'Variants' object is not iterable I am sending raw data like this. My models: class Variants(models.Model): SIZE = ( ('not applicable', 'not applicable',), ('S', 'Small',), ('M', 'Medium',), ('L', 'Large',), ('XL', 'Extra Large',), ) AVAILABILITY = ( ('available', 'Available',), ('not_available', 'Not Available',), ) product_id = models.CharField(max_length=70,default='OAXWRTZ_12C',blank=True) price = models.DecimalField(decimal_places=2, max_digits=20,default=500) size = models.CharField(max_length=50, choices=SIZE, default='not applicable',blank=True,null=True) color = models.CharField(max_length=70, default="not applicable",blank=True,null=True) variant_image = models.ImageField(upload_to="products/images", blank=True) thumbnail = ImageSpecField(source='variant_image', processors=[ResizeToFill(100, 50)], format='JPEG', options={'quality': 60}) quantity = models.IntegerField(default=10,blank=True,null=True) # available quantity of given product variant_availability = models.CharField(max_length=70, choices=AVAILABILITY, default='available') class Meta: verbose_name_plural = "Variants" def __str__(self): return self.product_id class Product(models.Model): merchant = models.ForeignKey(Seller,on_delete=models.CASCADE,blank=True,null=True) category = models.ManyToManyField(Category, blank=False) brand = models.ForeignKey(Brand, on_delete=models.CASCADE) collection = models.ForeignKey(Collection, on_delete=models.CASCADE) featured … -
Two Django Apps using Same Database Table
If I have two Django apps in the same project and both apps need to use the same table in the same database, how should I describe this table in two different models.py files? -
Search method inside Viewset class
I'm working on a small API project using Django rest framework, i'm using Viewset classes, and I would like to add a search function, I tried to use ListAPIView inside my search function but it doesn't work or i need to add something, I need a help, please class ContactView(viewsets.ViewSet): @action(detail=False, methods=['get']) def filter(self, request): class SearchContact(generics.ListAPIView): queryset = Contact.objects.all() serializer_class = ContactSerializer filter_backends = [filters.SearchFilter] search_fields = ['first_name', 'last_name', 'email', 'company', 'city'] -
How to automatically serialize request.user in Django?
In my viewset, before I save them, I override the create() method to tell serializer to save a field like uploaded_by from the self.request.user. serializer.save(uploaded_by=self.request.user) def create(self, request): data = request.data.copy() if request.data.get('product_type'): data['product_type'] = get_object_or_404( ProductType, name=request.data['product_type']) if request.data.get('capture_group'): data['capture_group'] = get_object_or_404( CaptureGroup, capture_group_id=request.data['capture_group']) serializer = CaptureGroupProductSerializer(data=data) if serializer.is_valid(): serializer.save(uploaded_by=self.request.user) # here I have reduced this create method by putting Slug Related Field to my serializer so I can delete querrying using get_object_or_404in my viewset. But I am still left directing serializer.save(uploaded_by=self.request.user). class CaptureGroupProductSerializer(serializers.ModelSerializer): product_type = serializers.SlugRelatedField( slug_field='name', queryset=ProductType.objects.all()) capture_group = serializers.SlugRelatedField( slug_field='capture_group_id', queryset=CaptureGroup.objects.all()) How can I do the same for the model of Super User. I want to automatically direct an incoming post "uploaded_by": "admin", to my super user model. I was thinking of something similar to Slug Related Field uploaded_by = serializers.SlugRelatedField( slug_field='username', queryset=settings.AUTH_USER_MODEL.objects.all()) But it does not work. -
Django chat app: WebSocket connection to wss://... failed
I have an instant chat app working successfully on my localhost, but after deploying to Heroku I got an error because I was using ws instead of wss. I changed that in room.html below, but now I'm getting a very generic error: WebSocket connection to 'wss://game-exchange-ca.herokuapp.com/ws/chat/room_name/' failed:, and it points to my javascript file reconnecting_websockets.js. In the Heroku logs, I get: Not Found: /ws/chat/room_name/. There are many suggested solutions to this seemingly common problem, but none of them worked for me. I installed redis on heroku and ensured it's working. Below is my code: asgi.py import os from channels.auth import AuthMiddlewareStack from channels.routing import ProtocolTypeRouter, URLRouter from django.core.asgi import get_asgi_application import chat.routing os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_project.settings") application = ProtocolTypeRouter({ "http": get_asgi_application(), # TODO: CONFIRM "websocket": AuthMiddlewareStack( URLRouter( chat.routing.websocket_urlpatterns ) ), }) routing.py from channels.auth import AuthMiddlewareStack from channels.routing import ProtocolTypeRouter, URLRouter import chat.routing application = ProtocolTypeRouter({ # (http->django views is added by default) 'websocket': AuthMiddlewareStack( URLRouter( chat.routing.websocket_urlpatterns #references urls defined in chat/routing.py ) ), }) wsgi.py import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_project.settings') application = get_wsgi_application() settings.py (relevent section) # ~~~MESSAGES CONFIG~~~ WSGI_APPLICATION = 'django_project.wsgi.application' ASGI_APPLICATION = 'django_project.asgi.application' # older version of django: 'django_project.routing.application' # Channels redis config: CHANNEL_LAYERS = { … -
Right/Best way to structure Django Model for given use case
I have a Meal model: class Meal(models.Model): meal_title = models.CharField(max_length=512, blank=False, null=False) created_at = models.DateTimeField(auto_now_add=True) last_modified_at = models.DateTimeField(auto_now=True) Sometimes a meal has a Pick any 1 of the 2 options kind of structure: Pizza and Garlic Bread/Dough Balls (Pick any 1). There are meals which have pick any 2 out of 3 or 4 options too. What is the best way to implement this in models? -
Cannot install geonode in window
i am getting the following error when i run the command pip install -e geonode. I am in the process of installing geonode. I am using window 10. ERROR: Command errored out with exit status 1: command: 'C:\Users\eidulameen.sh\Documents\geonode_env\Scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\eidulameen.sh\AppData\Local\Temp\pip-install-wk7ukb8e\uwsgi_17dc79202ede4643a13c8c5233dc91cc\setup.py'"'"'; file='"'"'C:\Users\eidulameen.sh\AppData\Local\Temp\pip-install-wk7ukb8e\uwsgi_17dc79202ede4643a13c8c5233dc91cc\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\eidulameen.sh\AppData\Local\Temp\pip-pip-egg-info-71v4l6zx' cwd: C:\Users\eidulameen.sh\AppData\Local\Temp\pip-install-wk7ukb8e\uwsgi_17dc79202ede4643a13c8c5233dc91cc Complete output (7 lines): Traceback (most recent call last): File "", line 1, in File "C:\Users\eidulameen.sh\AppData\Local\Temp\pip-install-wk7ukb8e\uwsgi_17dc79202ede4643a13c8c5233dc91cc\setup.py", line 3, in import uwsgiconfig as uc File "C:\Users\eidulameen.sh\AppData\Local\Temp\pip-install-wk7ukb8e\uwsgi_17dc79202ede4643a13c8c5233dc91cc\uwsgiconfig.py", line 8, in uwsgi_os = os.uname()[0] AttributeError: module 'os' has no attribute 'uname' ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/c7/75/45234f7b441c59b1eefd31ba3d1041a7e3c89602af24488e2a22e11e7259/uWSGI-2.0.19.1.tar.gz#sha256=faa85e053c0b1be4d5585b0858d3a511d2cd10201802e8676060fd0a109e5869 (from https://pypi.org/simple/uwsgi/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. ERROR: Could not find a version that satisfies the requirement uWSGI==2.0.19.1 (from geonode) ERROR: No matching distribution found for uWSGI==2.0.19.1 Any ideas how to solve the issue. Thank you in advance. -
Docker: ERROR: for web Cannot start service web: OCI runtime create failed
I'm having some error when building with sudo docker-compose up. The image builts well but when running the container it throws the following two errors: ERROR: for b21bd1503fed_django-docker-boilerplate_web_1 Cannot start service web: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:459: container init caused: write sysctl key net.ipv4.ip_unprivileged_port_start: open /proc/sys/net/ipv4/ip_unprivileged_port_start: no such file or directory: unknown ERROR: for web Cannot start service web: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:459: container init caused: write sysctl key net.ipv4.ip_unprivileged_port_start: open /proc/sys/net/ipv4/ip_unprivileged_port_start: no such file or directory: unknown I'm running docker on MacOS Catalina and the versions of docker and docker compose are version 20.10.5, build 55c4c88 and version 1.28.5, build c4eb3a1f respectively. My configuration files are the following: directories . |-- Dockerfile |-- README.md |-- docker-compose.yml `-- requirements.txt Dockerfile FROM python:3.10.0a6-slim-buster WORKDIR . ENV PYTHONUNBUFFERED=1 # Copy file into the working directory COPY requirements.txt . RUN pip install -r requirements.txt # Copy source code into the image COPY . . docker-compose.yml version: "3.9" services: web: build: . command: python manage.py runserver 0.0.0.0:8000 volumes: - . ports: - "8000:8000" env_file: - ./.env Any idea what's going on wrong here? -
(how to redirect it ) GenericDetailView' object has no attribute 'id'
Views.py class GenericDetailView(generics.GenericAPIView, mixins.ListModelMixin, mixins.CreateModelMixin): serializer_class = ArticleSerializer queryset = Article.objects.all().order_by('-date') def get(self, request): return self.list(request) def post(self, request): self.create(request) return redirect('generic-detail') {here when when i creating a new object it redirect me to 'generic-detail) it worked but when i change redirect from generic-detail to "generic-list") it's shows me an error I want redirect path something so that it's hit get method of GenericApiView please help me out sorry for bad english class GenericApiView(generics.GenericAPIView, mixins.RetrieveModelMixin): serializer_class = ArticleSerializer queryset = Article.objects.all() lookup_field = 'id' def get(self, request, id): return self.retrieve(request, id) urls.py urlpatterns = [ path('generic/<int:id>',views.GenericApiView.as_view(), name='generic- list'), path('generic/',views.GenericDetailView.as_view(), name='generic-detail'),] -
Django How to return viewset?
Enter /pro-detail-profile/{user_pk} to display the user's profile. class ProProfileDetailViewSet( mixins.RetrieveModelMixin, mixins.DestroyModelMixin, mixins.ListModelMixin, GenericViewSet, ): queryset = ProProfile.objects.all() serializer_class = ProProfileDetailSerializer permission_classes = ( permissions.IsAuthenticatedOrReadOnly, ProfileDetailPermission, ) def get_queryset(self): try: if self.kwargs["pk"]: user = User.objects.get(id=self.kwargs["pk"]) pro = ProProfile.objects.filter(id=user.proprofile.id) return pro except KeyError: return super().get_queryset() When debug was run [pro] sets the profile value, but when returned, an error of 404 appears. Why is that? models.py class ProProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, null=True, blank=True) user_birth = models.DateField( null=True) user_gender = models.CharField( max_length=1, choices=UserGenderChoice.choices, null=True ) serializers.py class ProProfileDetailSerializer(ModelSerializer): user_nm = serializers.CharField(source="user.user_nm") class Meta: model = ProProfile fields = ( "id", "user_nm", "user_birth", "user_gender", ) -
Vagrant ModuleNotFoundError: No module named 'django'
im runnning this command on my virtual env on vagrant server: python3 manage.py runserver 0.0.0.0:8000 and im getting this error that says: Traceback (most recent call last): File "manage.py", line 8, in <module> from django.core.management import execute_from_command_line ModuleNotFoundError: No module named 'django' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "manage.py", line 14, in <module> import django ModuleNotFoundError: No module named 'django' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "manage.py", line 17, in <module> "Couldn't import Django. Are you sure it's installed and " ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment? the funny part is that i installed django2.2 n i can prove it by pip3 packages list: (env) vagrant@ubuntu-bionic:/vagrant$ pip3 list DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning. asgiref (3.3.1) asn1crypto (0.24.0) attrs (17.4.0) Automat (0.6.0) blinker (1.4) certifi (2018.1.18) chardet (3.0.4) Django (2.2) <<<<======== i thought that it might be because of paths … -
error in django command "python manage.py migrate"
in the project2 of web development using python and java script after successfully makemigrations of models i created, running command "python manage.py migrate" showing following wrong behavior C:\Users\91740\Desktop\c++ programmming\programs\cs50\project2\commerce>python manage.py migrate Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "C:\msys64\mingw64\lib\python3.8\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line utility.execute() File "C:\msys64\mingw64\lib\python3.8\site-packages\django\core\management\__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\msys64\mingw64\lib\python3.8\site-packages\django\core\management\base.py", line 330, in run_from_argv self.execute(*args, **cmd_options) File "C:\msys64\mingw64\lib\python3.8\site-packages\django\core\management\base.py", line 371, in execute output = self.handle(*args, **options) File "C:\msys64\mingw64\lib\python3.8\site-packages\django\core\management\base.py", line 85, in wrapped res = handle_func(*args, **kwargs) File "C:\msys64\mingw64\lib\python3.8\site-packages\django\core\management\commands\migrate.py", line 95, in handle executor.loader.check_consistent_history(connection) File "C:\msys64\mingw64\lib\python3.8\site-packages\django\db\migrations\loader.py", line 302, in check_consistent_history raise InconsistentMigrationHistory( django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency auctions.0001_initial on database 'default' -
How to expand application to work with multiple users and seasons
Let's say that I have created an app for a school with several models (e.g. Student, Teacher, Course, Attendance, Grade, Timetable, Payments etc). It's working great for the current year. But now I want to expand my application, so that several schools can use it and it can store data of (mostly) independent seasons/years. The first solution that comes to my mind, is to add 2 extra models (1)school=user and (2)season=year. And then add ForeignKeys from (almost) ALL my models to both of these (school, season). (Maybe I could add a third model named SchoolSeason, with just these 2 fields and use this as FK to all my fields.) Is there a more elegant solution? Edit: a drawback to this solution would be that the models (e.g. Students) will share their auto-incremented ID with other schools. -
Get json or dictionary type data from string data from legacy database
I am working on a website and I have a legacy database in which a field saved data like this 'a:76:{s:6:\"marque\";a:6:{s:4:\"name\";s:6:\"Marque\";s:5:\"value\";s:10:\"Volkswagen\";s:8:\"position\";s:1:\"0\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:6:\"modele\";a:6:{s:4:\"name\";s:7:\"Modèle\";s:5:\"value\";s:11:\"Confortline\";s:8:\"position\";s:1:\"1\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:7:\"version\";a:6:{s:4:\"name\";s:7:\"Version\";s:5:\"value\";s:10:\"California\";s:8:\"position\";s:1:\"2\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:7:\"chassis\";a:6:{s:4:\"name\";s:7:\"Chassis\";s:5:\"value\";s:2:\"T5\";s:8:\"position\";s:1:\"3\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:13:\"pa_surnom-van\";a:6:{s:4:\"name\";s:13:\"pa_surnom-van\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:1:\"4\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:12:\"pa_amenageur\";a:6:{s:4:\"name\";s:12:\"pa_amenageur\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:1:\"5\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:8:\"pa_annee\";a:6:{s:4:\"name\";s:8:\"pa_annee\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:1:\"6\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:14:\"pa_carte-grise\";a:6:{s:4:\"name\";s:14:\"pa_carte-grise\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:1:\"7\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:11:\"pa_couchage\";a:6:{s:4:\"name\";s:11:\"pa_couchage\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:1:\"9\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:17:\"pa_places-assises\";a:6:{s:4:\"name\";s:17:\"pa_places-assises\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"10\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:22:\"pa_mise-en-circulation\";a:6:{s:4:\"name\";s:22:\"pa_mise-en-circulation\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"11\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:15:\"pa_motorisation\";a:6:{s:4:\"name\";s:15:\"pa_motorisation\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"12\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:19:\"pa_4-roues-motrices\";a:6:{s:4:\"name\";s:19:\"pa_4-roues-motrices\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"13\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:12:\"pa_carburant\";a:6:{s:4:\"name\";s:12:\"pa_carburant\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"14\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:23:\"pa_consommation-moyenne\";a:6:{s:4:\"name\";s:23:\"pa_consommation-moyenne\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"15\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:14:\"pa_amenagement\";a:6:{s:4:\"name\";s:14:\"pa_amenagement\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"16\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:14:\"pa_kilometrage\";a:6:{s:4:\"name\";s:14:\"pa_kilometrage\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"17\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:19:\"pa_boite-de-vitesse\";a:6:{s:4:\"name\";s:19:\"pa_boite-de-vitesse\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"18\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:13:\"pa_type-boite\";a:6:{s:4:\"name\";s:13:\"pa_type-boite\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"19\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:24:\"pa_regulateur-de-vitesse\";a:6:{s:4:\"name\";s:24:\"pa_regulateur-de-vitesse\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"20\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:22:\"pa_limiteur-de-vitesse\";a:6:{s:4:\"name\";s:22:\"pa_limiteur-de-vitesse\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"21\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:21:\"pa_controle-technique\";a:6:{s:4:\"name\";s:21:\"pa_controle-technique\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"23\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:6:\"pa_ebv\";a:6:{s:4:\"name\";s:6:\"pa_ebv\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"24\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:6:\"pa_eds\";a:6:{s:4:\"name\";s:6:\"pa_eds\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"25\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:27:\"pa_indicateur-pression-pneu\";a:6:{s:4:\"name\";s:27:\"pa_indicateur-pression-pneu\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"26\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:6:\"pa_abs\";a:6:{s:4:\"name\";s:6:\"pa_abs\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"27\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:16:\"pa_climatisation\";a:6:{s:4:\"name\";s:16:\"pa_climatisation\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"29\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:24:\"pa_fermeture-centralisee\";a:6:{s:4:\"name\";s:24:\"pa_fermeture-centralisee\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"30\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:21:\"pa_type-climatisation\";a:6:{s:4:\"name\";s:21:\"pa_type-climatisation\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"31\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:23:\"pa_siege-avant-pivotant\";a:6:{s:4:\"name\";s:23:\"pa_siege-avant-pivotant\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"32\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:24:\"pa_siege-avant-chauffant\";a:6:{s:4:\"name\";s:24:\"pa_siege-avant-chauffant\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"33\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:17:\"pa_toit-relevable\";a:6:{s:4:\"name\";s:17:\"pa_toit-relevable\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"34\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:11:\"pa_attelage\";a:6:{s:4:\"name\";s:11:\"pa_attelage\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"35\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:6:\"pa_gps\";a:6:{s:4:\"name\";s:6:\"pa_gps\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"36\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:13:\"pa_lecteur-cd\";a:6:{s:4:\"name\";s:13:\"pa_lecteur-cd\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"37\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:25:\"pa_convertisseur-12v-220v\";a:6:{s:4:\"name\";s:25:\"pa_convertisseur-12v-220v\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"39\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:25:\"pa_chauffage-stationnaire\";a:6:{s:4:\"name\";s:25:\"pa_chauffage-stationnaire\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"40\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:16:\"pa_store-lateral\";a:6:{s:4:\"name\";s:16:\"pa_store-lateral\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"41\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:14:\"pa_store-hayon\";a:6:{s:4:\"name\";s:14:\"pa_store-hayon\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"42\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:13:\"pa_porte-velo\";a:6:{s:4:\"name\";s:13:\"pa_porte-velo\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"43\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:14:\"pa_radar-recul\";a:6:{s:4:\"name\";s:14:\"pa_radar-recul\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"44\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:15:\"pa_camera-recul\";a:6:{s:4:\"name\";s:15:\"pa_camera-recul\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"45\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:20:\"pa_douche-exterieure\";a:6:{s:4:\"name\";s:20:\"pa_douche-exterieure\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"46\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:21:\"pa_rallonge-electique\";a:6:{s:4:\"name\";s:21:\"pa_rallonge-electique\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"47\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:8:\"pa_evier\";a:6:{s:4:\"name\";s:8:\"pa_evier\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"48\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:21:\"pa_plaque-cuisson-gaz\";a:6:{s:4:\"name\";s:21:\"pa_plaque-cuisson-gaz\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"49\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:16:\"pa_refrigerateur\";a:6:{s:4:\"name\";s:16:\"pa_refrigerateur\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"50\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:11:\"pa_penderie\";a:6:{s:4:\"name\";s:11:\"pa_penderie\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"51\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:25:\"pa_plan-travail-interieur\";a:6:{s:4:\"name\";s:25:\"pa_plan-travail-interieur\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"52\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:21:\"pa_occultation-sejour\";a:6:{s:4:\"name\";s:21:\"pa_occultation-sejour\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"53\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:21:\"pa_occultation-cabine\";a:6:{s:4:\"name\";s:21:\"pa_occultation-cabine\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"54\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:20:\"pa_banquette-lit-bas\";a:6:{s:4:\"name\";s:20:\"pa_banquette-lit-bas\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"55\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:11:\"pa_lit-haut\";a:6:{s:4:\"name\";s:11:\"pa_lit-haut\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"56\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:19:\"pa_table-exterieure\";a:6:{s:4:\"name\";s:19:\"pa_table-exterieure\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"58\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:10:\"pa_chaises\";a:6:{s:4:\"name\";s:10:\"pa_chaises\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"59\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:14:\"pa_set-cuisine\";a:6:{s:4:\"name\";s:14:\"pa_set-cuisine\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"60\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:17:\"pa_douche-solaire\";a:6:{s:4:\"name\";s:17:\"pa_douche-solaire\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"62\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:14:\"pa_coffre-fort\";a:6:{s:4:\"name\";s:14:\"pa_coffre-fort\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"63\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:21:\"pa_reserve-eau-propre\";a:6:{s:4:\"name\";s:21:\"pa_reserve-eau-propre\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"66\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:19:\"pa_reserve-eau-sale\";a:6:{s:4:\"name\";s:19:\"pa_reserve-eau-sale\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"67\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:17:\"pa_toilette-seche\";a:6:{s:4:\"name\";s:17:\"pa_toilette-seche\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"68\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:13:\"pa_complement\";a:6:{s:4:\"name\";s:13:\"pa_complement\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"72\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:19:\"equipement-securite\";a:6:{s:4:\"name\";s:20:\"Equipement securité\";s:5:\"value\";s:271:\"RŽgulateur de vitesse, limitateur de vitesse, assitance sationnement, attache Isofix bŽbŽ, correcteur trajectoire(EDS), antiblocage roues(ABS), rŽpartiteur Žlectronique freinage(EBV), indicateur pression pneu, fermeture centralisŽe, radal de recul, camŽra de recul\";s:8:\"position\";s:2:\"73\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:18:\"equipement-confort\";a:6:{s:4:\"name\";s:18:\"Equipement confort\";s:5:\"value\";s:95:\"climatisation, triptonic 3 zones,GPS,lecteur CD, attelage, port USB, pneu hiver, chaines neiges\";s:8:\"position\";s:2:\"74\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:10:\"pa_version\";a:6:{s:4:\"name\";s:10:\"pa_version\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"74\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"0\";s:11:\"is_taxonomy\";s:1:\"1\";}s:21:\"equipement-specifique\";a:6:{s:4:\"name\";s:22:\"Equipement spécifique\";s:5:\"value\";s:569:\"sige avant pivotant, sige avant chauffant, chauffage stationnaire, tŽlŽcommande, toit relevable manuel, store latŽral, store hayon, coffre fort, porte vŽlo(2), douche extrieure, convertisseur 12V/220, rallonge electrique, bloc Žvier, penderie, plaque cuissson, rŽfrigŽrateur, coffre rangement, plan de travail intrieur, occultation sŽjour, occultation cabien, sur matelas confort, insolite inside, Iso Top lit haut, multi-poches rangement, moustiquaire porte coulissante, moustiquaire fentre, moustiquaire hayon, rŽserve eau propre, rŽserve eau sale\";s:8:\"position\";s:2:\"75\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:10:\"pa_chassis\";a:6:{s:4:\"name\";s:10:\"pa_chassis\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"75\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"0\";s:11:\"is_taxonomy\";s:1:\"1\";}s:9:\"pa_modele\";a:6:{s:4:\"name\";s:9:\"pa_modele\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"76\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"0\";s:11:\"is_taxonomy\";s:1:\"1\";}s:11:\"accessoires\";a:6:{s:4:\"name\";s:11:\"Accessoires\";s:5:\"value\";s:122:\"vaisselles (4), set cuisine, cafetire, douche solaire, toilette sche, bbq extrieur, table extrieure, sige enfant\";s:8:\"position\";s:2:\"76\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:8:\"services\";a:6:{s:4:\"name\";s:8:\"Services\";s:5:\"value\";s:181:\"stationnement votre vŽhicule dans iun lieu privatif sŽcurisŽ, possibilitŽ de dŽpart depuis gare/aŽroport leplus proche, kit linge de maison, kit nettoyage, accepte les animaux\";s:8:\"position\";s:2:\"77\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:9:\"pa_region\";a:6:{s:4:\"name\";s:9:\"pa_region\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"78\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:8:\"pa_ville\";a:6:{s:4:\"name\";s:8:\"pa_ville\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"79\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:12:\"pa_lattitude\";a:6:{s:4:\"name\";s:12:\"pa_lattitude\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"80\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:12:\"pa_longitude\";a:6:{s:4:\"name\";s:12:\"pa_longitude\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"81\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:14:\"pa_code-postal\";a:6:{s:4:\"name\";s:14:\"pa_code-postal\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"82\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:9:\"pa_marque\";a:6:{s:4:\"name\";s:9:\"pa_marque\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"84\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"0\";s:11:\"is_taxonomy\";s:1:\"1\";}}' I want this data into json or disctionary or list format to save in DB. I have tried json (loads and dumps), pickel (loads and dumps), removed backslash from string data. but nothing worked. My …