According to my assignment admin must be able to create Polls with Questions (create, delete, update) and Choices related to this questions. All of this should be displayed and changable on the same admin page.
Poll
|
|_question_1
| |
| |_choice_1(text)
| |
| |_choice_2
| |
| |_choice_3
|
|_question_2
| |
| |_choice_1
| |
| |_choice_2
| |
| |_choice_3
|
|_question_3
|
|_choice_1
|
|_choice_2
|
|_choice_3
Ok, it's not a problem to display one level of nesting like so on
class QuestionInline(admin.StackedInline):
model = Question
class PollAdmin(ModelAdmin):
inlines = [
QuestionInline,
]
But how to do to get the required poll design structure?
Check out this library it should provide the functionality.
Related
The problem is the following:
Let's consider 2 sets of images embedded in a PowerBI file .pbix:
Set 1: Img1, Img2
Set 2: Img3, Img4, Img5, Img6
For each combination of 2 images between the two sets, we want to set an action (to a bookmark) to display a corresponding visual.
So here, we have these combinations:
(Img1, Img3) -> display Viz1.3
(Img1, Img4) -> display Viz1.4
(Img1, Img5) -> display Viz1.5
(Img1, Img6) -> display Viz1.6
(Img2, Img3) -> display Viz2.3
(Img2, Img4) -> display Viz2.4
(Img2, Img5) -> display Viz2.5
(Img2, Img6) -> display Viz2.6
Let's suppose that we have selected (Img1, Img3) and then we select (click) Img2.
How can we keep the selection on Img3 in order to display Viz2.3 ?
Marco
Each image can, I'm pretty sure, only trigger one bookmark. If I'm reading right, I think you need to duplicate the images and hide/show according to the state of the display.
For example in the example above, if the display is Viz1.3 and you click image 2, the updates would be to the viz and to the images in set 2:
Viz1.3 -> Viz2.3
Img3.1 -> Img3.2
Img4.1 -> Img4.2
Img5.1 -> Img5.2
Img6.1 -> Img6.2
And if you updated from there by clicking Img4 to get to Viz2.4, you'd have to update the images in set one
Viz2.3 -> Viz2.4
Img1.3 -> Img1.4
Img2.3 -> Img2.4
So, ultimately, you'd need four version of each image in set one (one for each in set two) and two of each in set two (to match set one). And though you're only showing 6 at any given time, that's 16 which is twice as many as you have visuals. But if you have to have it that way for UX, then I can't think of another way to do it.
| Image | Bookmark |
|-----------|--------------|
| Img1.3 | Viz1.3 |
| Img1.4 | Viz1.4 |
| Img1.5 | Viz1.5 |
| Img1.6 | Viz1.6 |
| Img2.3 | Viz2.3 |
| Img2.4 | Viz2.4 |
| Img2.5 | Viz2.5 |
| Img2.6 | Viz2.6 |
| Img3.1 | Viz1.3 |
| Img3.2 | Viz2.3 |
| Img4.1 | Viz1.4 |
| Img4.2 | Viz2.4 |
| Img5.1 | Viz1.5 |
| Img5.2 | Viz2.5 |
| Img6.1 | Viz1.6 |
| Img6.2 | Viz2.6 |
Showing or hiding bookmarks by screen state
I've got a question regarding a mysterious doctrine query error.
Long story short: I'm trying to store longblob data within my database (which can go up to x00mb for example), so i did the following steps:
Create my own longblob type and field, register it according to:
https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/cookbook/advanced-field-value-conversion-using-custom-mapping-types.html
Doctrine custom data type
My MySQL database looks like: so i think it works?
mysql> describe DataBlocks;
+-----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| data_type_id_id | int(11) | NO | MUL | NULL | |
| project_id_id | int(11) | NO | MUL | NULL | |
| data_block_name | varchar(100) | YES | | NULL | |
| content | longblob | YES | | NULL | |
| comment | longtext | YES | | NULL | |
| ts_added | datetime | NO | | NULL | |
+-----------------+--------------+------+-----+---------+----------------+
My Symfony4.1 FormType file field is as follows:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('dataBlockName', TextType::class)
->add('content', FileType::class)
I also adjusted the lines in my php.ini file for unlimited file size (i know this isn't really secure but.. it's just for now)
post_max_size = 0M
upload_max_filesize = 0M
And I get this error when my entity manager flushes the entity:
An exception occurred while executing 'INSERT INTO DataBlocks
(data_block_name, content, comment, ts_added, data_type_id_id,
project_id_id) VALUES (?, ?, ?, ?, ?, ?)' with params
["BTC_DOGE_tradehistory", Resource id #66, "450mb", "2018-10-08
10:19:44", 1, 1]:
Warning: Error while sending QUERY packet. PID=6016
Your help would be kindly appreciated!
FYI: it works for small files, but when i try to upload something big it becomes that vague error
The query describe in the exception tells you that the column content has for value a PHP resource. So i think it's a cast problem. Blob data are stored as bytes string. You also have possible issue with server configuration. There is Apache/Nginx or whatever, PHP but also the server sql.
Here an example for mysql: doc
I am creating a listview with 5 columns in Gtk+ using C++. I was able to do that. But the problem is, I need subcolumns for the 2nd column which I'm not sure how to proceed.
firstcolumn | second column | third |
|SC1 | SC2 | SC3| |
| | | | |
Is this possible? Can you suggest how to go about it?
I publish an OG action/object but the attachment layout of the action (which has been set to "Item") is simply ignored. On my timeline, I click on the date/time link to see the action in full details (along with the attachment)... but all I see is a box with object image in the center and the object title at the bottom:
------------------
| |
| |
| Image |
| |
| |
------------------
| Object Title |
------------------
Instead I expect to see a smaller image at the left side along with the title and other captions on the right side (like what "Item" layout preview is showing):
-----------------------------------------
| | Object Title |
| | Caption 1 |
| Image | Caption 2 |
| | Caption 3 |
| | Caption 4 |
-----------------------------------------
And the OG tags of my object page, hosted on my website, are correct (at least the Facebook OG Debugger says so!).
Does anyone know what I'm missing here?
Thank you,
I want to make an form for purchasing tickets. The problem is that for every event there can be diferent types of ticket with diferent price.
For every kind of ticket I will have to create an edit box where user can select how much tickets he wants.
Then in view class I will just display the dynamicly created form ... the only problem that I see now is that I don't know where to save an information for each ticket price so I can easy display it in the the same row where the edit box is?
P.S. I'm also not sure how can I dynamicly create a form using Django ... but this have to be easy ;)
P.S. Form have to be something like this:
--------------------------------------------------------
| Tiket Type | Price | How much? | Price |
--------------------------------------------------------
| Tiket Type Name | Price $1.00 | [ ] | Price... | [tiketkind.id = 1]
| Tiket Type Name | Price $2.00 | [ ] | Price... | [tiketkind.id = 12]
| Tiket Type Name | Price $3.00 | [ ] | Price... | [tiketkind.id = 18]
| Tiket Type Name | Price $4.00 | [ ] | Price... | [tiketkind.id = 21]
--------------------------------------------------------
| TOTAL PRICE: | ... |
--------------------------------------------------------
| Email: [ ] |
--------------------------------------------------------
This is pretty easy. Instead of thinking about making dynamic forms, think about making dynamic fields.
You'll have one form. When you initialize it, you'll pass it information about the tickets available. In the init of your form you will dynamically add field objects to the form by appending to self.fields.
Example:
self.fields['this_field_I_just_made_up'] = forms.CharField()
Notes:
The first thing you'll need to do in your init is to pop off your custom values.
The second thing you'll need to do in your init is to call the init of the superclass with *args and **kwargs.
If you don't do those two things, in that order, you will get errors.
Shawn
Source: http://groups.google.com/group/django-users/browse_thread/thread/3629184ceb11aeef
First of all, you're thinking in PHP. Don't do that. There's no need for array-like HTML element names.
I'm not entirely sure I understand your requirements, but it sounds like a formset will do what you want.