Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django - only admin account can login
I created a function for users to log in to my website. However, it only works if I log in with an admin account, otherwise it cannot detect a registered user exist and said "This is user does not exist". Here is the code: class LoginForm(forms.Form): username = forms.CharField() password = forms.CharField(widget=forms.PasswordInput) def clean(self, *args, **kwargs): username = self.cleaned_data["username"] password = self.cleaned_data["password"] if username and password: user = authenticate(username=username, password=password) if not user: raise forms.ValidationError("This is user does not exist") if not user.check_password(password): raise forms.ValidationError("Incorrect password") if not user.is_active: raise forms.ValidationError("This user is not longer active") return super(LoginForm, self).clean(*args, *kwargs) Thanks for any help! -
How to rewrite the APIView's `post` method?
How to rewrite the APIView's post method? I try to rewrite the post method like bellow, but seems it miss something. class CloudServerShutdownAPIView(APIView): """ shut down the server """ serializer_class = CloudServerShutdownSerializer def post(self, request): cloudserver_id = request.data.pop("cloudserver_id") try: openstackServerShutdown(server_or_id=cloudserver_id) except Exception as e: return Response(data="shut down server fail", status=HTTP_404_NOT_FOUND, exception=e) How can I rewrite the post method correctly? -
endpoint that returns a json with all django api endpoints and its structure
I'd like to know if it's possible to get an endpoint that returns all the endpoints of a django api with its structure. I had this in a previous company on a php symphony app. This is what it would look like: Call to /api/expose would return: {/user/{id}: ["name", "age", "bday"], /user/{id}/photos: ["url", "format"].... } thanks -
Django annotate sub-group with totals of parent grouping - optimising the query
I am trying to annotate groupings of a model with totals of a broader group. One reason is to allow me to return percentages rather than raw counts. I have the below subquery and query which give me the desired output, however, it requires making three calls to the Subquery, which is really inefficient; it more than triples the query time. What I think I really want here is to effectively perform a JOIN on the subquery and the main query but I have no idea how to do so in the ORM? It may be that there is not an efficient way to do this using the ORM? I am using Python 3.5, Django 1.11.6, PostgreSQL 9.3.8 subquery = Typing.objects.filter( cell=OuterRef('cell'), ) .values( 'cell', ) .annotate( SumReads=Sum('NumReads'), SumCell=Count('NumReads'), ) Typing.objects.values( 'cell', 'Gene').\ annotate( PerGeneMeanReads = Avg('NumReads'), PerGeneTotalReads = Sum('NumReads'), PerCellSumReads = Subquery(totals.values('SumReads')), CellCount = Subquery(totals.values('SumCell')), GenePercReads = Cast(Sum('NumReads'), FloatField()) * 100 / Cast(Subquery(totals.values('SumReads')), FloatField()), GeneCountPerc = Cast(Count('NumReads'), FloatField()) * 100 / Cast(Subquery(totals.values('SumCell')), FloatField()), ) -
Django WebTest - I fill and save a form, data are updated in the new page but not in the database
I have a test in which I create a Profile model with factory_boy and a biography with value 'Starting biography'. Then I get the form from the page and I fill it the bio field with 'Test Updated Bio' and I see that the response has the updated value, but the database has not. When I get the profile page after update I have the 'Test Updated Bio' in the HTML and 'Starting biography' in the biography field of the Profile model. class ProfileFactory(DjangoModelFactory): class Meta: model = 'profiles.Profile' #user = SubFactory(UserFactory) user = SubFactory('users.tests.factories.UserFactory', profile=None) bio = 'Starting Bio' def test_user_change_biography(self): test_bio = 'Test Updated Biography' form = self.app.get( reverse('profiles:update'), user=self.profile.user, ).form form['bio'] = test_bio tmp = form.submit().follow().follow() print('\n\n\n', tmp, '\n\n\n') print('\n\n\n', self.profile.__dict__, '\n\n\n') self.assertEqual(self.profile.bio, test_bio) I thought that there could be some caching mechanism but I don't know. Some ideas ? -
Django - wkhmltopdf - CalledProcessError (only works with sudo from command line)
I'm trying to render PDF from Django template using django-wkhtmltopdf. The problem is that wkhtmltopdf started raising: Command '['/usr/bin/wkhtmltopdf', '--encoding', u'utf8', '--quiet', u'False', '/tmp/wkhtmltopdfRDyi61.html', '-']' returned non-zero exit status 1 Can't figure out where the problem is but I noticed that I can't even do in command line (I'm in virtualenv): wkhtmltopdf http://www.google.com g.pdf Loading pages (1/6) QPainter::begin(): Returned false============================] 100% Error: Unable to write to destination Exit with code 1, due to unknown error. It works only with sudo privileges (but I'm in PyCharmProject my users directory): sudo wkhtmltopdf http://www.google.com g.pdf I also noticed that some of the temporary html files from /tmp/ folder wasn't deleted. This is a whole traceback Django returns: TRACEBACK: Environment: Request Method: GET Request URL: http://127.0.0.1:8000/render/ Django Version: 1.11.7 Python Version: 2.7.12 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'agreements', 'weasyprint'] Installed 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'] Traceback: File "/home/milano/.virtualenvs/maklerienv/local/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner 41. response = get_response(request) File "/home/milano/.virtualenvs/maklerienv/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response 217. response = self.process_exception_by_middleware(e, request) File "/home/milano/.virtualenvs/maklerienv/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response 215. response = response.render() File "/home/milano/.virtualenvs/maklerienv/local/lib/python2.7/site-packages/django/template/response.py" in render 107. self.content = self.rendered_content File "/home/milano/.virtualenvs/maklerienv/local/lib/python2.7/site-packages/wkhtmltopdf/views.py" in rendered_content 78. cmd_options=cmd_options File "/home/milano/.virtualenvs/maklerienv/local/lib/python2.7/site-packages/wkhtmltopdf/utils.py" in render_pdf_from_template 186. cmd_options=cmd_options) File "/home/milano/.virtualenvs/maklerienv/local/lib/python2.7/site-packages/wkhtmltopdf/utils.py" in convert_to_pdf 124. return wkhtmltopdf(pages=filename, … -
Wagtail: Can i use the API for fetching read-only drafts of pages for review?
The title pretty much sums up the question, the early docs talk about a /revision endpoint but i cannot find if it was ever implemented. Wagtail have excellent functionality to edit and save the pages, i just need to preview how the draft looks when consumed by my application. -
Web Appliation that works completely offline
i started creating a TaskManger/ProjectManager in C#. It s about managing tasks and project as efficient as possible. This Project included a SQL DataStorage for Text and Images (RichTextBox).Played also with OCR. Tasks have been ranked similar like on TaskWarrior (https://taskwarrior.org/). The database is growing pretty fast. I am trying to implement this at Work. My Question anyway is moving away from desktop application to Web Appliation: Can i create this kind of project as an WebApplication that could work completely offline? I mean lets say my co worker having a link of the (lets say) html file (that would be saved on a global folder of our company) and the are able to work completely offline? Thank you all for your time and effort! BR Nasuf -
Django allauth social login - limit list of domains
I have implemented social login(provider-google) using django-allauth for my web application. I want to allow only a limited domains to the application. The following is my settings for allauth settings.py AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', 'allauth.account.auth_backends.AuthenticationBackend', ) SOCIALACCOUNT_ADAPTER = 'mbaweb.socialaccount_adapter.NoNewUsersAccountAdapter' LOGIN_REDIRECT_URL = "/" SOCIALACCOUNT_PROVIDERS = { 'google': { 'SCOPE': [ 'profile', 'email', ], 'AUTH_PARAMS': { 'access_type': 'online', 'hd': 'abc.com' } } } By using 'hd' parameter I am able to allow only the accounts with domain 'abc.com'. It restricts all other domain accounts. But my requirement is to allow a list of domains to the application for example:- allowed_domains = ['abc.com', 'xyz.co.in', 'pqr.com'] Is there any way to achieve this? Thanks for any help. -
Django Linking an account details with checkout in ecommerce apllication
I have a django ecommerce application which customers are enabled to create account and update their accounts with their shipping address. In the application there is ability to checkout carts which I have designed the code and now what I want to do which I am confused about is how to link the created profile which contains the shipping and billing address to the product order checkout. below is my code for the user registration and my checkout. Accounts models class BaseOrderInfo(models.Model): class Meta: abstract = True # shipping information phone = models.CharField(max_length=20) address = models.CharField(max_length=50) city = models.CharField(max_length=250) state = models.CharField(max_length=50) postal_code = models.CharField(max_length=10) # Create your models here. class Account(BaseOrderInfo): user = models.OneToOneField(settings.AUTH_USER_MODEL, related_name='account') def __str__(self): return 'Account for {}'.format(self.user.username) Order models class Order(models.Model): # each individual status SUBMITTED = 1 PROCESSED = 2 SHIPPED = 3 CANCELLED = 4 user = models.ForeignKey(Account, related_name='user_account') created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) paid = models.BooleanField(default=False) coupon = models.ForeignKey(Coupon, related_name='orders', null=True, blank=True) discount = models.IntegerField(default=0, validators=[MinValueValidator(0), MaxValueValidator(100)]) # set of possible order statuses ORDER_STATUSES = ( (SUBMITTED, 'Submitted'), (PROCESSED, 'Processed'), (SHIPPED, 'Shipped'), (CANCELLED, 'Cancelled'),) status = models.IntegerField(choices=ORDER_STATUSES, default=SUBMITTED) class Meta: ordering = ('-created',) def __str__(self): return 'Order {}'.format(self.id) def get_total_cost(self): total_cost … -
django backend connect to frontend react native
i have problem in my App with react native my backend use Django to make it and I'm create app with react native but when i use to fetch() to connect the backend its won't work its my fetch function fetch('http://pezeshkam.com/api/v1/doctors/') .then((response )=> response.json()) .then((json)=>{ console.log(json); }) .catch(error =>console.log(error)) how to setup in my code for connect to react native? its response my console : TypeError: Network request failed at XMLHttpRequest.xhr.onerror (fetch.js:441) at XMLHttpRequest.dispatchEvent (event-target.js:172) at XMLHttpRequest.setReadyState (XMLHttpRequest.js:548) at XMLHttpRequest.__didCompleteResponse (XMLHttpRequest.js:381) at XMLHttpRequest.js:487 at RCTDeviceEventEmitter.emit (EventEmitter.js:181) at MessageQueue.__callFunction (MessageQueue.js:306) at MessageQueue.js:108 at MessageQueue.__guard (MessageQueue.js:269) at MessageQueue.callFunctionReturnFlushedQueue (MessageQueue.js:107) -
Why I get "Relation fields do not support nested lookups"?
I am trying to display all Expenses I am getting for certain building. However, expences can be or for a particular unit in the building or for particular extra property in the building. So for this in my view I am filtering my data like this: expense_list = Expense.objects.filter(Q(payment_date__range=[start_date, end_date],noteunit__unit__building = building) | Q(payment_date__range=[start_date, end_date],noteextra__unit__building = building) ) But getting error:Relation fields do not support nested lookups How to resolve it? And What I am doing wrong? -
How to test a new user activation in Django?
I am trying to test django.contrib.auth-based user signup view with django-nose, where an activation link is being sent to a new user: def signup(request): if request.method == 'POST': user_form = SignUpForm(request.POST) profile_form = ProfileForm(request.POST) if user_form.is_valid() and profile_form.is_valid(): user = user_form.save(commit=False) user.is_active = False user.save() user.profile.user_type = profile_form['user_type'].data user.save() current_site = get_current_site(request) subject = 'activation email' message = render_to_string('registration/account_activation_email.html', { 'user': user, 'domain': current_site.domain, 'uid': urlsafe_base64_encode(force_bytes(user.pk)), 'token': account_activation_token.make_token(user), }) user.email_user(subject, message) return redirect('account_activation_sent') else: user_form = SignUpForm() profile_form = ProfileForm() return render(request, 'registration/signup.html', { 'user_form': user_form, 'profile_form': profile_form }) Currently I use Django built-in email back-end, so that activation email is being sent to the server terminal. I want to test the activation view which requires uid and token. Is there any way to access the email sent to the user? Is there any other way to test that? Regenerating token in the test does not work, because hash value is generated using timestamp. -
Django get_or_create returns False
I'm creating a population script, from an MysqlDatabase to Django Models. Im looping through my receiving data from the Mysql and thats going good. Now I have to write it to the Django Database... mdl, succeeded = models.User.objects.get_or_create( name=name, password=password, email=email ) I'm printing succeeded so I can see what the feedback is, but all it gives me is False My Django Model User is edited so all fields can be blank and allows NULL or have a default My Model User: username = models.CharField(max_length=20, blank=True, null=True) slug = models.SlugField(null=True, blank=True) email = models.EmailField(unique=True, null=True) name = models.CharField("First and last name", max_length=100) uses_metric = models.BooleanField(default=True) position = models.CharField("Position", max_length=70, blank=True, null=True,) utility = models.ForeignKey(Utility, default=1, blank=True, null=True) supplier = models.ForeignKey(Supplier, default=1, blank=True, null=True) currency = models.ForeignKey(Currency, default=1) phone = models.CharField("Direct phone number", max_length=40, blank=True, default='+') gets_notifications_on_reply = models.BooleanField("Receive notifications", default=False) memberlist = models.BooleanField("Show member in memberslist", default=True) registration_date = models.IntegerField(default=floor(time.time()), blank=True, null=True) is_staff = models.BooleanField( _('staff status'), default=False, help_text=_('Designates whether the user can log into this site.'), ) is_active = models.BooleanField( _('active'), default=True, help_text=_( 'Designates whether this user should be treated as active. ' 'Deselect this instead of deleting accounts.' ), ) USERNAME_FIELD = 'email' -
Store Data from different websites in Django Database
I would like to create a Django project to save tags or pixels fires from different websites in a my database: For this reason, create the following Django model. This one, include all variables that I want to save class Purchase (models.Model): account = models.CharField(max_length=250, blank=True) user_cookie = models.CharField(max_length=250, blank=True) session_id = models.CharField(max_length=250, blank=True) …. For collect data from other websites I saw this method. I don’t know if it’s the base way to collect this data. <script> var e= document.createElement("script"); e.async = true; e.src =e.src ="https://mydomain.js;m=001;cache="+Math.random()+ "?account=0001"+ "&user_cookie=" + String(utag_data.uidCookie) + "&session_id =" + utag_data.Session_ID); var s =document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(e,s); </script> Finally, I would like to collect this javascript request in my Django database. Which url I need to use? How can store this data in my dataset? Thank you for your help -
How to start and stop django server from java servlet?
I have two separate applications one written in django python and other one in java. These applications are communicating with each other through API's now I want to stop django server from java servlet and also want to restart it again from java servlet. Is it possible to do this ? -
authentication Django on LDAP server
I would like my web application authenticate users on an ldap server (only for username and password), but that the permissions reside on django. Not all ldap users must have access to the web application. In particular, I would like to allow users to see only a few records (for example, suppose there is a model with a city field: some users should only be able to see records whose city field is london, others whose city is milano, etc.). How can i define django permissions if users are defined on ldap? How can I define the user's application admin if users are defined on ldap? Do I need to implement a double authentication? Do I have to define ldap users who can access the web application even on django? What is the best way to proceed? Do you have any suggestions? Examples? Thanks pacopyc -
Django dynamic HTML table refresh with AJAX
First of all, I am new with Django, and pretty much completely unfamiliar with AJAX and jQuery. So I'm trying to achieve a HTML table, that is dynamically refreshed every X amount of seconds with help from AJAX, but I can't seem to get my code to work. I've already used the example provided in this question: https://stackoverflow.com/a/34775420/6724882 (If I had enough rep, I would have either replied to that question, or asked help from chat, but I don't have that luxury yet) I've been trying to get this to work for 10+ hours, and I start to feel helpless. I've been searching the web like crazy, but I'm overwhelmed by all the different ways of doing this, and every question and answer seems to be either too many years old, or just not relevant to my app. So, I got couple questions. Should I include the script in its own separate file, and not in the HTML file (in my case, displaykala.html). If so, should that file be in the static/js folder, or somewhere else? Do I need to include AJAX/JS somewhere separately, in order for the script to work? Am I clearly doing something wrong, or is the … -
Django settings for Microsoft exchange
How to configure setting for send_mail that using Microsoft Exchange. Can we still use the settings below. EMAIL_PORT = 443 EMAIL_USE_TLS = True EMAIL_HOST = 'host' EMAIL_HOST_USER = 'username' EMAIL_HOST_PASSWORD = 'password' When i try to send email i got an error Connection timed out -
Django query optimization for merging two tables . update_or_create
I am retrieving some info from another table and want to update or create a new row in my local table . I am following this logic , its working fine but taking a huge time approx 150sec , to complete 10000 loops . Is there anything i can do to make it work fast and optimize . And i am already using celery background process for this thing PS : I HAVE NEARLY 8 FIELDS TO CREATE OR UPDATE ACCORDING TO ID . for row in results: id = row['id'] id = row['id'] check = Agents.objects.update_or_create(id=id, defaults={ 'abc': abc, },) -
Broken django-debug-toolbar panels with sub domains configuration
I'm working on djangoproject.com website with Django Debug Toolbar configured in this dev settings. I founded an issue with django-debug-toolbar that I reported in the issue #796 of djanoproject.com but after some test I think it's only a configuration problem and we need help to solve it. All the below sentence are related with the code on branch master used locally. Django Debug Toolbar works well for www , for example, if I open http://www.djangoproject.dev:8000/ I can show the toolbar and open the SQL panel. If I try to open for example http://docs.djangoproject.dev:8000/en/1.11/ I can see the toolbar but I got 0: error if I try to open SQL panel This is the message I saw on browser console: Failed to load http://www.djangoproject.dev:8000/debug/render_panel/?store_id=212b2bb5adc54a3a81b97b6da5547d4c&panel_id=SQLPanel: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://docs.djangoproject.dev:8000' is therefore not allowed access. I can see all the data if I open directly the url: http://www.djangoproject.dev:8000/debug/render_panel/?store_id=212b2bb5adc54a3a81b97b6da5547d4c&panel_id=SQLPanel I think the problem is that the toolbar is trying to open a www. for the panel instead of a docs. url but I don't know how to update the settings to fix this. Can you suggest to us how to change the dev settings to use django-debug-toolbar … -
Django UpdateView is giving empty forms without object data
I'm using UpdateView to edit data using forms. After I click to edit the popup using modal is showing a few forms with blank data! It doesn't retrieve the previous data that was in the Database. Anyone know what should I add? I am stuck with this edit for about a week :( If anyone has a clue I will be grateful! Thank you! views.py - # Create your views here. from django.shortcuts import render_to_response from django.shortcuts import get_object_or_404 from django.shortcuts import render, redirect from django.template import RequestContext from django.views.generic import TemplateView, UpdateView, DeleteView, CreateView from DevOpsWeb.forms import HomeForm from DevOpsWeb.models import serverlist from django.core.urlresolvers import reverse_lazy from simple_search import search_filter from django.db.models import Q class HomeView(TemplateView): template_name = 'serverlist.html' def get(self, request): form = HomeForm() query = request.GET.get("q") posts = serverlist.objects.all() forms = {} if query: posts = serverlist.objects.filter(Q(ServerName__icontains=query) | Q(Owner__icontains=query) | Q(Project__icontains=query) | Q(Description__icontains=query) | Q(IP__icontains=query) | Q(ILO__icontains=query) | Q(Rack__icontains=query)) else: posts = serverlist.objects.all() for post in posts: forms[post.id] = HomeForm(instance=post) args = {'form' : form, 'forms': forms, 'posts' : posts} return render(request, self.template_name, args) def post(self,request): form = HomeForm(request.POST) posts = serverlist.objects.all() if form.is_valid(): # Checks if validation of the forms passed post = form.save(commit=False) post.save() form … -
Forbidden (403) CSRF verification failed. Request aborted when login to admin mezzanine
i deploy project web into server but when i login addmin page it has an error "Forbidden (403) CSRF verification failed. Request aborted." . It's normal when i test in local. my project used mezzanine cms and i use default login of mezzanine I need some help -
django ajax call from template
I have a model: class ok(models.Model): name = models.CharField(max_length=255) project = models.CharField(max_length=255) story = models.CharField(max_length=500) depends_on = models.CharField(max_length=500, default='') rfc = models.CharField(max_length=255) I have model form. class okForm(ModelForm): class Meta: model = ok fields='__all__' I am getting first 3 fields: name, project, story user manual entry. Now I want to populate the last two fields with respect to third field using AJAX call from views function that will query to mysql database. I have a fucntion in views.py def get(self, request): name = request.GET.get('name') project = request.GET.get('project') story = request.GET.get('story') if name and project and story: try: obj = ok.objects.get(name=name, project=project, story=story) return JsonResponse(data={ 'depends_on': ok_obj.depends_on, 'rfc': ok_obj.rfc}, status=200) except ok.DoesNotExist: pass return JsonResponse(data={'error': 'bad request'}, status=400) How i will make the ajax call with the third value the user just filled, as he has not submitted the form yet . Kindly help. -
How to serializer the openstack.compute.v2.server.ServerDetail?
How to serializer the openstack.compute.v2.server.ServerDetail ? I use the openstacksdk for develop my own openstack app. But when I get the generator of my connection: user_conn = UserOpenstackConn() openstack_servers_gen = user_conn.conn.compute.servers() I can use the list() to convert the openstack_servers_gen to list: : [openstack.compute.v2.server.ServerDetail(OS-EXT-AZ:availability_zone=, key_name=None, hostId=, os-extended-volumes:volumes_attached=[], OS-SRV-USG:launched_at=None, OS-EXT-STS:vm_state=error, flavor={'id': '5c5dca53-9f96-4851-afd4-60de75faf896', 'links': [{'href': 'http://controller:8774/233cf23186bf4c52afc464ee008cdf7f/flavors/5c5dca53-9f96-4851-afd4-60de75faf896', 'rel': 'bookmark'}]}, updated=2017-11-27T10:29:50Z, accessIPv4=, image={'id': '60f4005e-5daf-4aef-a018-4c6b2ff06b40', 'links': [{'href': 'http://controller:8774/233cf23186bf4c52afc464ee008cdf7f/images/60f4005e-5daf-4aef-a018-4c6b2ff06b40', 'rel': 'bookmark'}]}, created=2017-11-27T10:29:49Z, metadata={}, links=[{'href': 'http://controller:8774/v2.1/233cf23186bf4c52afc464ee008cdf7f/servers/3db46b7b-a641-49ce-97ef-f17c9a11f58a', 'rel': 'self'}, {'href': 'http://controller:8774/233cf23186bf4c52afc464ee008cdf7f/servers/3db46b7b-a641-49ce-97ef-f17c9a11f58a', 'rel': 'bookmark'}], OS-DCF:diskConfig=MANUAL, id=3db46b7b-a641-49ce-97ef-f17c9a11f58a, user_id=41bb48ee30e449d5868f7af9e6251156, OS-SRV-USG:terminated_at=None, name=123456, config_drive=, accessIPv6=, OS-EXT-STS:power_state=0, addresses={}, OS-EXT-STS:task_state=None, status=ERROR, tenant_id=233cf23186bf4c52afc464ee008cdf7f), openstack.compute.v2.server.ServerDetail(OS-EXT-AZ:availability_zone=, key_name=None, hostId=, os-extended-volumes:volumes_attached=[], OS-SRV-USG:launched_at=None, OS-EXT-STS:vm_state=error, flavor={'id': '5c5dca53-9f96-4851-afd4-60de75faf896', 'links': [{'href': 'http://controller:8774/233cf23186bf4c52afc464ee008cdf7f/flavors/5c5dca53-9f96-4851-afd4-60de75faf896', 'rel': 'bookmark'}]}, updated=2017-11-27T10:27:42Z, accessIPv4=, image={'id': '60f4005e-5daf-4aef-a018-4c6b2ff06b40', 'links': [{'href': 'http://controller:8774/233cf23186bf4c52afc464ee008cdf7f/images/60f4005e-5daf-4aef-a018-4c6b2ff06b40', 'rel': 'bookmark'}]}, created=2017-11-27T10:27:41Z, metadata={}, links=[{'href': 'http://controller:8774/v2.1/233cf23186bf4c52afc464ee008cdf7f/servers/721467ac-440f-4784-b825-f6155c65abee', 'rel': 'self'}, {'href': 'http://controller:8774/233cf23186bf4c52afc464ee008 ....... But how can I make it to be serializable in my project?