Posts

python - How to use 2 ForeignKey filters one by one in 1 view - Django? -

hello , thank your answer: my taks: show article, show 3 questions (related article), show 3 answer each queston (related these questions). coomon test page. my models: class step(models.model): #main article title = models.charfield(max_length=200) description = models.charfield(max_length=200) annotation = models.textfield() main_text = models.textfield() def __str__(self): return self.title class question(models.model): #questios related article. step = models.foreignkey(step, on_delete=models.cascade) title = models.charfield(max_length=200, default = "pages") question_text = models.textfield() question_name = models.charfield(max_length=40, help_text="английские буквы", blank=true, null=true) class answer(models.model): #answers related questions question = models.foreignkey(question, on_delete=models.cascade) choice_text = models.textfield() votes = models.integerfield(default=0) answ...

actionscript 3 - Load the first 30 items in my TextField then loading the rest when click -

i'm making air app (as3) flash. i've got sprite that's loading items database table. function complete(e:event):void { addchild(list); products = json.parse(loader5.data) array; for(var i:int = 0; < products.length; i++){ createlistitem(i, products[i]); } showlist(); } function createlistitem(index:int, item:object):void { var listitem:textfield = new textfield(); var myformat:textformat = new textformat(); myformat.size = 25 listitem.defaulttextformat = myformat; listitem.text = item.title; listitem.y = 140+ index * 40; listitem.width = 100; listitem.addeventlistener(mouseevent.click, function(e:mouseevent):void { showdetails(item); }); list.addchild(listitem); } function showlist():void { list.visible = true; } i have more 200 items loaded. i'd load (or display) 30 first one, , click on button load/display 30 next..etc (like "pages"). any idea how can ? ...

java - Android String.format locale set explicitly to US but Persian numbers are used for Integer -

the title explains all. string method = string.format( "select studymap.id,studymap.title,studymap.zorder,studymap.hierarchy_id,studymap.book_id," + "studymap.abstract,studymap.type,studymap.free_view,studymap.localpath,studymap.flags," + "studymap.visit_status,downloads.status download_status,downloads.studymap_id,studymap.publish_status "+ "from studymap left join downloads on studymap.id = downloads.studymap_id" + " studymap.book_id = %d order studymap.zorder", book.id); book.id integers, still error on devices: android.database.sqlite.sqliteexception: no such column: ۵۴۵ (code 1): , while compiling: select studymap.id,studymap.title,studymap.zorder,studymap.hierarchy_id,studymap.book_id,studymap.abstract,studymap.type,studymap.free_view,studymap.localpath,studymap.flags,studymap.visit_status,downloads.status download_status,download...

c - OpenGL window doesn't open in xcode (7.2) when run as a child process -

i on os x 10.10.5, , xcode 7.2. have program spawns child process run visualization using opengl/glut, i.e. pid_t childpid; childpid = fork(); if(childpid == 0) { // child process glutinit(&argc, argv); ... } else{ // parent process else ... } when run in xcode, program never returns glutinit. if instead use parent process visualization, , child run else, i.e. if(childpid != 0) { // parent process glutinit(&argc, argv); ... } ... then opengl window pops up, , whole program runs fine. additionally, if run original version (with child doing visualization) when building makefiles in terminal outside of xcode, runs fine. any ideas on cause this? i haven't been able debug things far within xcode, because debugger follows parent process. if try attach child process through debug->attach process, error: "xcode couldn't attach “j2”. “j2” not support debuggable architecture." found questions on last issue of attaching other processes ...

ruby on rails - Schema dump with pre-existing MySQL database results in NoMethodError -

i've been trying schema dump new rails project using existing mysql database. here's setup in database.yml file: default: &default adapter: mysql2 encoding: utf8 pool: 5 username: username_example password: password_example host: localhost socket: /tmp/mysql.sock development: <<: *default database: databasename i added following gems gemfile , bundled: gem 'mysql2' gem 'activerecord-mysql2-adapter' after using command rake db:schema:dump following error in schema file: activerecord::schema.define(version: 0) # not dump table "tablename" because of following nomethoderror # undefined method `type' "text":string end any ideas on how fix appreciated, thanks! i discovered mysql version messing dump. removed activerecord mysql adaptor changed gemfile , dump worked perfectly: gem 'mysql2', '~> 0.3.13'

php - How do I make this loop once, break then continue the loop? -

i looping div horizontally float:left , works way should problem each div has unique height influenced content contained within, result can messy looking when browser re sized. php loop once, break, start new row looks same no matter how browser sized. if it's not obvious, not php , struggled piece have. <?php $url = "xml.php"; $xml = simplexml_load_file($url); $namespaces = $xml->getnamespaces(true); // namespaces for($i = 0; $i < 10; $i++){ $poster = $xml->channel->item[$i]->children($namespaces['x'])->poster; $html .= "<div class='wrapper' style='float:left;'>$poster</div>";} echo $html; ?> if understand want information have here suggest: your loop fine. lets want same no mater size of page. exemple : want 5 div on each row. use css it. you have total of 10 div need 2 rows. add loop : if($i = 5){ $html .= "<div class='wrapper' style='float:left;...

php - Select one value from same column with same id -

i want select product detail , display 1 image of product same column. ex : fm_product table | p_id | p_name | p_price | p_member_id | << (added product member) ----------------------------------------- | 1 | shirt | 600 | 44 | | 2 | pants | 700 | 44 | | 3 | shoes | 800 | 45 | | 4 | bag | 900 | 45 | fm_product_image table | img_id | p_id_img | img_name | ----------------------------------- | 1 | 1 | shirt_1.jpg | | 2 | 1 | shirt_2.jpg | | 3 | 1 | shirt_3.jpg | | 4 | 2 | pants_1.jpg | | 5 | 2 | pants_2.jpg | | 6 | 2 | pants_3.jpg | | 7 | 3 | shoes_1.jpg | | 8 | 3 | shoes_2.jpg | | 9 | 4 | bag_1.jpg | | 10 | 4 | bag_2.jpg | member ids 44 select added product out put should : | p_name | p_price | img_name | ---------------------------------- | shirt | 600 | shirt_1...