In order to uniquely identify my model records in the django admin interface, I am joining the unicode of several fields in sequence. These become the links to select individual records to edit.
To improve readability I'd like to display them to appear as columns. So rather than...
Fred Flintstone 1985-06-11
Jim Bean 1999-03-02
Wolfgang Amadeus Mozart 1756-01-27
I want
Fred Flintstone 1985-06-11
Jim Bean 1999-03-02
Wolfgang Amadeus Mozart 1756-01-27
If I format my __unicode__ function return to have extra whitespace, Django will include it in the html but the browser collapses the whitespace. Is there a simple way to change the layout of these line items while keeping the admin? Maybe by somehow getting "pre" tags to be output - I'm not an html expert so I suspect that may not be legal inside the "a href", but maybe the text could be appended after the link, with a fixed link at the front something like
Select<pre>Fred Flintstone 1985-06-11</pre>
Select<pre>Jim Bean 1999-03-02</pre>
Apologies if that's bad html but hopefully you understand what I'm saying.
I realise I could do a template and my own view but the admin almost does what I need for a lot of the application apart from this formatting issue, and there will be quite a lot of different pages like this.
You want this instead: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display
Basically, you specify how to list your model items and this is used instead of calling __unicode__ on your model.
Related
I have a large text file, which is an Italian-English dictionary. A typical line is:
Mazzapícchio, a long pole that fishers vse to bob vp and down for Eeles, and also to make fish to stirre. Also a kind of meate or custard in some parts of Italie made with milke and egges.
(Yes, it's a 17th-century dictionary.)
I'm looking for the best/easiest way to turn this into a searchable database.
The search would need to ignore the diacritics; with everything up to the first comma as the 'entry'. There are some cross-references, e.g.: Mefíte, as Mephíte.
My first thought is simply to turn it into HTML, with anchor tags for the word/phrase up to the first comma. That should be easy enough with a bit of Grep. I could also add links to the crossrefs in the same way (using BBEdit to confirm each change). It would then be easy to query just using a browser's search field.
However, ideally, I'd like something that returned only (all) the matching results. XML/HTML Tagging is the easy bit: the problem is the front-end to access/query it.
I'm on MacOS. (I'm also investigating Apple's Dictionary format...)
Any ideas on how to proceed would be welcome. Thanks.
This is a huge question. So many choices at so many areas.
A small start:
A searchable db. Look at https://solr.apache.org/
Php to handle interaction front-end with solr and to serve your html search form and results.
So I'm writing an app where there's a HTML tag which should have all the ACM CCS tags/fields as options and basically users should be able to select one or more of these tags and assign them.
However how can I go about getting all the ACM CCS tags as strings in the first place, so I can create the element with the proper options in the first place?
Getting them manually isn't really an option as there are probably thousands of them by the looks of it.
Considering they're part of the academic culture I thought they'd already been extracted at some point by someone in a certain format and then shared somewhere but I couldn't find any such thing.
For reference, if you don't know what I'm talking about, I want all the names of all the CCS tags in no particular order from this site: https://dl.acm.org/ccs
So for example, in the end I wanna obtain such strings as "General and reference", "Hardware" , etc.
I've looked into web crawlers and the likes but I seriously have no clue how to even use one, let alone build one. As far as I've seen all these names are stored inside <li> tags so if I had something that'd "parse" the whole site with all its pages and then store the content of all the <li> tags it encounters as strings that would work.
So I'm building a website that contains information about a bunch of different animal species. I will have a list of 500 items, that should be able to be filtered and sorted by different criteria. For example, I will have a 'country selection' option. If Brazil is selected, the Capuchin monkey among other animals (living in Brazil) should be added to the list.
I could see myself making a list with 50 species with no problem, as the HTML would be manageable. But would having 500 items in a list with filterabilty even be possible without using some sort of database?
I was thinking of just pairing animal items from the list with certain filter criteria. For example, Capuchin monkey with "Brazil", "Mammal", "Omnivore", etc.
And when e.g. "Mammal" is selected in the filter, all animals paired with that property (all mammals of the list) is added to the list, or if not paired with the property, then removed from the list.
As you probably can tell, I'm really uneducated on how to go about creating this filterable list. Down the road I might even look into adding a search function.
After pluggin in all content, I would never need to change anything. I've read that databases should only be used if you have dynamic content.
I wouldn't list all 500 items on the same page, as that would make it very slow. I would have 10 items per page.
I don't need a solution per se. I just wish to be pushed in the right direction.
Should I look into MySQL? Can a filterable list of 500 items be possible with just HTML/CSS/Javascript? I am somewhat familiar with javascript, and have read that JSON might be able to provide the things I need.
Sorry if my question is vague or if I'm in the wrong anywhere (this is my first post). Please ask for any clarification and any advice or suggestion is greatly appreciated.
Thanks,
Manne
No you don't need a database. Have a look at this very robust jQuery plugin that will easily allow you to sort/filter/search 500 items in JavaScript alone:
https://datatables.net/
There are examples that are powered from JSON alone so I would suggest you simply store your data in a JSON file until you grow large enough that you need to change that (if you ever do).
Here is an example where the data is pulled from a .txt file:
https://datatables.net/examples/data_sources/ajax.html
I understand the majority of this topic and how to nest something like address vocabulary in person vocabulary.
but I'm wondering into more details for less straight forward pieces of info or "mixed up" info. Any Advice documentation is appreciated
So Couple Example Questions
1.) Is there no way to associate an email address that google understands? Maybe I missed this?
2.) Let's say John & Jane Sign the bottom of their Blog Together They both have the same site and affiliations, would using the name prop twice in one section of person be appropriate? would it associate that both John and Jane are two separate people both affiliations?
3.) Can more than one of any itemprop be used for example I have 3 affiliations and 3 titles, I don't want to write my name three times so i would use itemprop name and than title prop 3 separate times? furthermore how would i associate the title and role of the the three separate ones together?
4.) To take that farther what if Jane also had the Title of SEO where as John had the title of Music and Jane and John had the title of Web Development and both had the same URL how could more intertwined mark ups like this be represented without listing all the info for each person separately?
4.) Let's say you have an affiliation with company a and company b what would be the best method to also nest the business information for company a and company b ?
The Majority of my questions are along the same lines but I think nipping these or any documentation that covers scenarios similar to these would help clear up alot of confusion
I don't think most of this is possible with the current status of microdata. One way round it would be to add the info in another place (i.e. first person at the end of a post, then second person hidden at end of page), which semantically is stupid, but would allow naive parsing to pick up both cards.
As I say though, I don't think there is a neat way to do this in the page at the moment.
I have a query In our application we have lots of HTML tags. During development many tags were not given any id because of no requirement.Now the QA team wants to automate the test cases using QTP. In most of the cases this tool doesn't recognizes because it does not find ids for most of the HTML tags.Now we are asked to add ids to all the HTML tags.
I want to know if there will be any effect adding id attribute to these tags. Even positive impact are welcome
I do not think there will be any either positive or negative effect : maybe the size of the HTML page will increase a bit, but probably not that much.
Still, are you sure you need to put "id" attributes on every HTML tag of your pages ? Wouldn't only a few of those be enough ? Like on form fields, on links, on error-messages ; and that's probably about it ?
One thing you must take care, though, is that "id", as in "identifers", must be unique ; which implies it might be good, before starting adding them, to define some kind of "id-policy", to say, for instance, that "ids for elements of that kind should be named that way".
And, for your next projects : have developpers add those when theyr're developping ;-)
(And following the policy, of course)
Now that I'm thinking about it : a positive effect might be that it'll be easier to write Javascript code interacting with your HTML document -- but that'll be true for next projects or evolutions for this one, when those id are already present in the HTML at the time developpers put the JS code in place...
Since there are no QTP related answers yet.
GUI recognition in QTP is object-oriented. In order to identify an object QTP needs a unique combination of object's properties, and checking them better to be as fast as possible - that is why HTML ID would be ideal.
Now, where it is especially critical - for objects that do not have other unique identifiers. The most typical example - html tables. Their contents is dynamic, their number on the page may vary. By adding HTML ID you allow recognition mechanism get straight to the right table.
Objects with other unique properties can be recognized well without HTML ID. For example, if you have a single "submit" link on the page QTP will successfully recognize it by inner text.
So the context-specific answer: don't start adding ids to every single tag. Ask automation guys to prepare a list of objects they have problem with. And add ids to those objects.
PS. It also depends on automation programming skills. There are descriptive programming and dynamic recognition methods. They allow retrieving the right objects even without ids provided.
As Albert said, QTP doesn't rely solely on elements' id, in fact due to the fact that many web applications generate different ids for each session, (as far as I remember) the id property isn't part of the default description for most web test objects.
QTP is pretty good at recognizing most simple web controls and if you're facing problems it may be the case that a Web Extensibility project will help you bridge the gap between the semantics of your web application and the raw HTML it is created in. If a complex control is recognized by QTP as a WebElement (which is actually the div that contains the span that drives the code) you will understandably have object recognition problems since there are many divs on the page but probably many less complex controls.
If you are talking about side-effects - NO. Adding ids won't cause any problems (apart from taking up some extra bytes of course)
If you really have the need to add ids, go ahead and add them.
http://www.w3.org/TR/html4/struct/links.html#anchors-with-id says: The id and name attributes share the same name space. This means that they cannot both define an anchor with the same name in the same document. It is permissible to use both attributes to specify an element's unique identifier for the following elements: A, APPLET, FORM, FRAME, IFRAME, IMG, and MAP. When both attributes are used on a single element, their values must be identical.