Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7936763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:18:43+00:00 2026-06-03T22:18:43+00:00

I’ve been developing product catalog. All my needs fit perfectly with MongoDB but there

  • 0

I’ve been developing product catalog. All my needs fit perfectly with MongoDB but there is one problem:

There are categories with structure like these:

{
 title:"Auto", // for h1 on page
 id: 1,        // for urls
 level: 1,     //
 left: 2,      // nested set implementation
 right:10      //
}

When user goes to url like “http://www.example.com/category/1” I need to show html forms to filter shown goods. I’m pretty sure it is bad idea to store static definitions for every category on the server(about 300 categories, i’m using Django => 300 form models?)

So my idea is to store meta-information about each category in MongoDB. After some research I found out that I need 3-4 “html widgets” to construct any filter form that I need.

For example:

Range fields will look like this in HTML

<fieldset>
<legend>Price</legend>

<label for="price_from">from</label>
<input type="text" name="price_from">

<label for="price_to">to</label>
<input type="text" name="price_to">
</fieldset>

And its MongoDB JSON representation:

{
 name:"price",
 title:"Price",
 type:"range",      // "range" type - 2 inputs with initial values
 categories:[1,2,5],// categories to which this so called "widget" relates
 values:[
   {from: 100},
   {to: 500}
 ]

}

One more example:

Group of selects:

Its HTML version

 <fieldset>
   <legend>Size and color</legend>

   <select name="size">
    <option value="small">Small size</option>
    <option value="medium">Medium size</option>
    <option value="huge">Huge size</option>
   </select>
   <select name="color">
    <option value="white">White color</option>
    <option value="black">Black color</option>
    <option value="purple">Purple color</option>
   </select>
 </fieldset>

And its MongoDB JSON version:

{
  title:"Size and color",
  type:"selectgroup",
  categories:[2,4,6]
  items:[
         {
           name:"size",
           values:["small", "medium", "huge"]
         },
         {
           name:"color",
           values:["white", "black", "purple"]
         }
  ]
}

So the main idea is : fetch all widgets from collection by category_id, parse them and print complete HTML form.

Pros

  • Easy to add any new type of widget to database
  • Easy to add parser for such widget to generate HTML from JSON
  • Each widget can relates to many categories => no duplicates

Cons

  • Collection of widgets has no less or more fixed structure of the document(actually i don’t see real problem here)
  • Аll values related to widget are embedded.
  • Hard validation because fields are dynamic => no corresponding model on server side (right now i don’t have any idea how to validate this)

My question is: does anybody know a better way of doing this? Pros of my method are cool, but cons are terrible.

Thanks for help and sorry for bad English.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T22:18:44+00:00Added an answer on June 3, 2026 at 10:18 pm

    If you only need 3-4 sets of form widgets to display all necessary query forms for the 300+ categories, you should use Django forms to specify the widgets. You do not need 300+ Django forms for that as you can easily use multiple forms in one page.

    As a quick example, your

    <fieldset>
    <legend>Price</legend>
    
    <label for="price_from">from</label>
    <input type="text" name="price_from">
    
    <label for="price_to">to</label>
    <input type="text" name="price_to">
    </fieldset>
    

    would become

    class PriceForm(forms.Form):
        price_from = forms.IntegerField()
        price_to = forms.IntegerField()
    

    …and of course the template to embed the form into which would provide the <fieldset> and other necessary html document structure.

    EDIT:
    As it seems that your form labels etc. depend on the category, you still need to have some information about the forms in the category documents in mongodb. However, by using django forms you get a lot of useful functionality for free, such as input validation.

    You probably can parametrize the templates in such a way that you give the category-specific values (labels etc.) to the template from mongodb, along with the necessary forms.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.