Posts

Django REST - separating valid data from non-valid and serializing the former with many=True -

i using django rest framework come rest api app. in 1 of views, trying use many=true when initializing serializer object in order bulk_insert multiple rows @ once. problem if 1 of records in dataset invalid, serializer's is_valid() method return false , rejecting entire dataset. whereas desired behavior inserting valid records , ignoring invalid ones. have succeed in achieving using following code, have terrible feeling junk code , rest framework has native way this. my code below (that consider junk code :)): serializers.py class myserializer(serializers.modelserializer): class meta: model = calendareventattendee fields = '__all__' view.py def my_view(request): validated_data = [] # separate valid data invalid record in request.data: if myserializer(data = record).is_valid(): validated_data.append(record) # bulk_insert valid data serializer = myserializer(data=validated_data, many=true) i...

java - Convert JPA model classes into the MongoDB model class? -

i new mongodb , looking implement below 3 classes in mongodb. have annotated model class @document, not sure how can implement relationship ? how can implement relationship here ? authority.java @entity @table(name = "authority") public class authority { @id @column(name = "id") @generatedvalue(strategy = generationtype.sequence, generator = "authority_seq") @sequencegenerator(name = "authority_seq", sequencename = "authority_seq", allocationsize = 1) private long id; @column(name = "name", length = 50) @notnull @enumerated(enumtype.string) private authorityname name; @manytomany(mappedby = "authorities", fetch = fetchtype.lazy) private list<user> users; user.java @entity @table(name = "user") public class user { @id @column(name = "id") @generatedvalue(strategy = generationtype.sequence, generator = "user_seq...

r - prop.test function in a loop -

i wanting 2 sample proportions test in r using loop , split health center , measure. below link show example of how data set (the website not allow me upload image of dataset) basically, want compare health center a's measure a's using prop.test function , repeat health centers (29 of them) , measures (14 of them). not sure on code loop proportion tests want , split how want. any appreciated! i went ahead deleted 0's. however, code worked did not split data how wanted to. hoping split health center , measure instead splits health center have 28 measures prop.test analyzing instead of health center measure a. see output example below: click here see output you can perform split , prop.test using this lapply(split(df, df$health_center), function(x) prop.test(as.matrix(cbind(x[,3], x[,4]-x[,3])))) output $a1 2-sample test equality of proportions continuity correction data: as.matrix(cbind(x[, 3], x[, 4] - x[, 3])) x-squared = 1.713, df = 1, ...

Formatting html object to make card using css -

so i'm working on project , i'm having trouble css/formatting since i've never heavily used css before. below code snippet. in snippet text kinda far below image. need same height image , have same line spacing between lines (right bettween bold text , regular text there large space) prevent text wrapping under image. see link example of how need css make look. i'm not sure how , appreciated. <head> <style> * { box-sizing: border-box; } #myinput { background-image: url('/css/searchicon.png'); background-position: 10px 12px; background-repeat: no-repeat; width: 100%; font-size: 16px; padding: 12px 20px 12px 40px; border: 1px solid #ddd; margin-bottom: 12px; } #myul { list-style-type: none; padding: 0; margin: 0; } #myul li { /*border: 1px solid #ddd;*/ /* not needed @ point */ ...

xamarin - I can not run my project on iphone -

Image
always when run project direct on iphone following error occurs what can cause since error, use visual studio 2017 , xamarin updated, xcode in mac updated. can not identify, know solution?

unit testing - How do I test Django views when they don't return values -

i'm new django. i've worked through tutorials, written models, views, forms etc. don't understand how can tested since either nothing returned, or whatever returned tightly bound doesn't make sense in terms of test. for example here 2 view classes: class listblogpostview(listview): model = blogpost template_name = 'app/blogpost_list.html' class createblogpostview(createview): model = blogpost template_name = 'app/blogpost_edit.html' form_class = blogpostform def get_success_url(self): return reverse('blogpost-list') def get_context_data(self, **kwargs): context = super(createblogpostview, self).get_context_data(**kwargs) context['action'] = reverse('blogpost-new') return context the first, listblogpostview, doesn't return anything. how can ever check working correctly? the second has couple of functions return values not things can test assert how ...

javascript - Glassdoor API 404 error chrome extension -

i'm writing chrome extension retrieves ratings companies on glassdoor. accomplish have content script send message background script make xmlhttprequest. the url used request was "http://api.glassdoor.com/api/api.htmv=1&format=json&t.p=177556&t.k=kvtuqd0ashs&userip=" + address + "&actions=employers&q=" + companyname + "&useragent=" + navigator.useragent both address , companyname defined before this. i got message: failed load resource: server responded status of 404 (not found) when ran script. in addition, got message: xmlhttprequest cannot load [above link]. no 'access-control-allow-origin' header present on requested resource. origin 'chrome-extension://maonbpchkpdlcpobmfdkkephdbniognp' therefore not allowed access. response had http status code 404. i checked format of api call several times, , can't find problem it. changed permissions in manifest file "all_urls" got ri...