I have to make an exercise for my examination but I can not find the solution. We have to create the following form:
The solution:
wijngroep: with al the unique names of the table wijngroepen (select list)
WIJNEN: with the unique names of the table wijnen based on the previous field (select list)
Wijn: combination of the jaar and inhoud field bases on previous field (select list)
So this seems very easy but now:
1) Load al groups of the wine (I know that one)
2) If you select a group then the name (WIJNEN) is filled in automatically
3) If you select a name (WIJNEN) then the Wijn-field (that exists out of the 'jaar' and 'inhoud' field as you can see in the pictures bellow) is automatically filled in.
There is my problem, I don't know how to combine the fields into one field and my dynamic actions do not work. Can someone help me?
Table Wijnen:
Wijnid
Jaar
Naam
Omschrijving
GroepsID
Inhoud
...
Table Wijngroepen:
GroepsID
Groepsnaam
Images are available in following links:
solution
and
tables
I have made an workspace:
name workspace = EXEC
Username = de.geyter.steffen#gmail.com
Password = dummy
The tables are loaded into te application.
This should work to combine the fields
select distinct to_char(JAAR)||' '||NAAM as display_value, NAAM as return_value
from WIJNEN
order by 1
I had a look at the application - apart from creating form what is the purpose. Remember a form only works on one record at a time
Related
I have an existing table called empname in my postgres database
(Projectid,empid,name,Location) as
(1,101,Raj,India),
(2,201,David,USA)
So in the app console it will have like the following
1)Projectid=Textbox
2)Ops =(view,insert,Edit)-Dropdown
Case1:
So if i write project id as 1 and select View Result:It will display all the records for Projectid =1(Here 1 record)
Case2:
If i write projectid as 3 and select insert it will ask for all the inputs like empid,name,address and based on that it will update the table .
Case3:
If i write projectid as 2 and select edit.Then it will show all the field for that id and user can edit any column and can save which will update the records in backend for the existing table
If there is not data found for the respective project id then it will display no records found
Please help me on this as I am stuck up with models
Once you have your models created, the next task should be the form models. I can identify atleast 3 form classes that you will need to create. One to display the information(case 1), another to collect information(case 2) and the last class to edit the information. Wire up the form to the views and add the urls.
A good reference could be a django a user registration form since it will have all the three cases taken care of.http://www.tangowithdjango.com/book17/chapters/login.html
I've got 2 existing models that I need to join that are non-relational (no foreign keys). These were written by other developers are cannot be modified by me.
Here's a quick description of them:
Model Process
Field filename
Field path
Field somethingelse
Field bar
Model Service
Field filename
Field path
Field servicename
Field foo
I need to join all instances of these two models on the filename and path columns. I've got existing filters I have to apply to each of them before this join occurs.
Example:
A = Process.objects.filter(somethingelse=231)
B = Service.objects.filter(foo='abc')
result = A.filter(filename=B.filename,path=B.path)
This sucks, but your best bet is to iterate all models of one type, and issue queries to get your joined models for the other type.
The other alternative is to run a raw SQL query to perform these joins, and retrieve the IDs for each model object, and then retrieve each joined pair based on that. More efficient at run time, but it will need to be manually maintained if your schema evolves.
A relevant image of my model is here: http://i.stack.imgur.com/xzsVU.png
I need to make a queryset that contains all cats who have an associated person with a role of "owner" and a name of "bob".
The sql for this would be shown below.
select * from cat where exists
(select 1 from person inner join role where
person.name="bob" and role.name="owner");
This problem can be solved in two sql queries with the following django filters.
people = Person.objects.filter(name="bob", role__name="owner")
ids = [p.id for p in people]
cats = Cat.objects.filter(id__in=ids)
My actual setup is more complex than this and is dealing with a large dataset. Is there a way to do this with one query? If it is impossible, what is the efficient alternative?
I'm pretty sure this is your query:
cats = Cat.objects.filter(person__name='bob', person__role__name='owner')
read here about look ups spanning relationships
I have an application that allows for "contacts" to be made completely customized. My method of doing that is letting the administrator setup all of the fields allowed for the contact. My database is as follows:
Contacts
id
active
lastactive
created_on
Fields
id
label
FieldValues
id
fieldid
contactid
response
So the contact table only tells whether they are active and their identifier; the fields tables only holds the label of the field and identifier, and the fieldvalues table is what actually holds the data for contacts (name, address, etc.)
So this setup has worked just fine for me up until now. The client would like to be able to pull a cumulative report, but say state of all the contacts in a certain city. Effectively the data would have to look like the following
California (from fields table)
Costa Mesa - (from fields table) 5 - (counted in fieldvalues table)
Newport 2
Connecticut
Wallingford 2
Clinton 2
Berlin 5
The state field might be id 6 and the city field might be id 4. I don't know if I have just been looking at this code way to long to figure it out or what,
The SQL to create those three tables can be found at https://s3.amazonaws.com/davejlong/Contact.sql
You've got an Entity Attribute Value (EAV) model. Use the field and fieldvalue tables for searching only - the WHERE caluse. Then make life easier by keeping the full entity's data in a CLOB off the main table (e.g. Contacts.data) in a serialized format (WDDX is good for this). Read the data column out, deserialize, and work with on the server side. This is much easier than the myriad of joins you'd need to do otherwise to reproduce the fully hydrated entity from an EAV setup.
I want to insert the product in the product table but the product table is also having a category Id which is the foreign key ,How will I insert the foreign key through code please tell me.
i have used this syntax
NewItemToInsert.tbl_PRODUCT_CATEGORY.category_id = Convert.ToInt32 (categoryId);
Categories are displayed in the dropdown list on the add product page and to bind that dropdown I have written a class.
Category Id which I want to insert already exists in the Category table and that Id I want to add into Product table
Please give me useful suggesstions
Thanks
Ritz
you need to have the category table in memory (or use a proper enum that is in sync with the values in the db), and set the right categoryid when you do the update / insert command.
if you post the code, we can see if there is any problem there.
CategoryId you want to insert in Product table, should already exist in ProductCategory table.