Posts

jquery - Need help making Django + Ajax like button -

i new coding , have implemented button online book - tango django: http://www.tangowithdjango.com/book17/chapters/ajax.html#add-a-like-button however project need record users have liked , ensure can item once (similar instagram/facebook). have looked @ other related questions online have found there no laid out answer other beginners follow. if easy follow answer me , other people trying achieve same in future, appreciated! my current code follows: models class userproject(models.model): user = models.foreignkey(user) title = models.charfield(max_length=100) date_created = models.datetimefield(auto_now_add=true) project_likes = models.integerfield(default=0) slug = models.slugfield(max_length=100, unique=true) views @login_required def like_project(request): proj_id = none if request.method == 'get': proj_id = request.get['project_id'] likes = 0 if proj_id: proj = userproject.objects.get(id=int(p...

html - How to classify li tags when we want it 2 times -

i wanted use li tags 2 times first time used class li tag <ul *class="2"*> <li *class="!"*><.......jpg" width="280" height="280" \></li> <li class="!"><img src="......jpg" width="280" height="280" \></li> and 2nd time... did this <ul> <li><a href="........html">home</a></li> <li><a href="........html">songs</a></li> <li><a href="........html">games</a></li> <li><a class="active" href=".........html">gallery</a></li> </ul> my css ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; position: fixed; bottom: 0; width: 100%; } li { float: left; } li { display: block; color: white; text-align: cente...

angular-cli, Google Visualization Charts, SystemJS -

i'm building charts app angular 2 (angular-cli) , google charts. just putting google-loader script tags in index.html works in development mode, when building production (everything bundled) error typeerror: cannot read property 'arraytodatatable' of undefined when calling google.visualization.arraytodatatable(data); the next thing tried putting loader.js in systemjs config: const map: = { 'google-visualization': 'https://www.gstatic.com/charts/loader.js' }; importing in main.ts import 'google-visualization'; and loading corechart package in app.ts google.charts.load('current', { 'packages': ['corechart'], 'language': 'pl' }); now error saying xmlhttprequest cannot load https://www.gstatic.com/charts/loader.js. no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:4200' therefore not allowed access. is there othe...

javascript - Selectize load function is not triggered on typing -

i have following selectize element: $('#my_selectize').selectize({ valuefield: 'value', labelfield: 'text', options: [{'value':1,'text':'abc','inn':123}], render: { option: function(data, escape) { //return .... }, load: function(query, callback) { if (!query.length) // breakpoint not triggered return callback(); $.ajax({ url: '{% url my_url %}', type: 'get', data: {q: query}, error: function() { callback(); }, success: function(res) { callback(json.parse(vendor_options_json.f)); } }); } }}); according docs , once user starts typing, should see browser sto...

sql server - Select statement with a where clause and add 'comment' in another column -

i need add ‘comment’ in additional column select statement clause. current code first statement select * [table] [dep] = 'm' , ([join m] <> [join b] or [resign m] <> [resign date beneficiary]) go second statement select * [table] [join b] < [resign b] , ([join m] > [join b] or [resign m] < [resign b]) go this 2 different select statements, combine both outputs 1 table. wrong code - (example explain) first statement select * [table] [dep] = 'm' , ([join m] <> [join b] or [resign m] <> [resign date beneficiary]) set [comment] = 'main' go second statement select * [table] [join b] < [resign b] , ([join m] > [join b] or [resign...

Read JSON file with different format -

Image
i have custom platform upload files. platform content of files (mapping) , have screen can see content. my problem specific json file. original format : {"schema:actor:image":"https://link.png","schema:activity.timestamp:timestamp":"01/06/2016 19:23:01","schema:metadata:datatype":"text","schema:actor:name":"aaaa","schema:metadata.tags:key":null,"schema:activity.content:value":"value1","schema:activity.content:language":["english"],"schema:activity.location:placename":"city of london, united kingdom","schema:actor:followers_count":1518,"schema:activity.content:sentiment":"positive","schema:activity.content:opinion":"neutral","schema:activity.content:gender":"unknown","schema:activity.content:age":"35-49","schema:actor:synthetic":...

java - How to get updated entities from JPA resultList .? -

i have updated object within transaction, updated , sync database...but whenever i'm retrieving entities using query.getresultlist() , not returning list updated objects , values. here code refers how i'm doing... javax.persistence.entitymanager entitymanager = java.beans.beans.isdesigntime() ? null : javax.persistence.persistence.createentitymanagerfactory("jdbc:oracle:thin:@siddhant-pc:1521:xepu").createentitymanager(); javax.persistence.query professionalworkquery = java.beans.beans.isdesigntime() ? null : entitymanager.createquery("select p professionalwork p order p.jobno"); java.util.list<professionalwork> professionalworklist = java.beans.beans.isdesigntime() ? java.util.collections.emptylist() : professionalworkquery.getresultlist(); code updating object... professionalwork prowork = entitymanager.find(professionalwork.class, jobno); entitymanager.gettransaction().begin(); prowork.se...