EDIT
Why would you downvote this question? Is there any question on SO that answers this that would show i didn't try to find it or google has answer to it that I missed? Or this is not the proper place to ask such questions?
This is a simple question asking for advice on how to display options keeping MY particular data structure in mind.
Please mention the reason for downvote.
ORIGINAL
I am trying to make my first website. I am using Django for it.
I need advice from you people regarding UI of a portion of my template.
I have a doctor user who will have to choose his clinic timings. So he has to choose from 7 days of week. Each day will have three shifts(Morning, Afternoon, Evening).
He may choose 1 or more days and then for each day he may choose 1 or more shifts and provide time for each shift.
How should I go about making options available to him so that it is easier for him to choose days-shifts-time and at the same time not clutter the UI?
One way is to display all 7 days then under each day display three shift and for each shift show time field. But I think this is too much on a modal popup.
Can you please suggest anything to make it simpler or show any screenshot from any site etc to get an idea about this.
To get an idea how my data is, you can refer to the image
I assume the "Clinic X" tables in your picture are actually m2m intermediary through tables? Meaning they contain a foreign key to both the doctor and clinic tables? I think to remember this from yesterday, when you still had an excerpt of your models.py in your post (I wanted to ask for more details, but I dont have the rep to comment yet).
You could make a view based on the "Clinic X" models. It would contain ModelChoice fields for selecting the right clinic and the doctor (or, if the doctor is actually the USER responsible for creating the data, have the doctor be fixed by checking request.user).
Then you could employ inlineformsets for the selection of days and start times.
If the 'shifts' are not mandatory, I would drop them entirely. You would have to code in checks that the user does not begin his afternoon shift at 2 am, etc.
Also, while I appreciate MS Paint art... you should try to model this with something like UML. While modelling may seem like a waste of time at first, they really help you understand your own project.
Related
I am moving from Rails to Django and trying to convert a Hamper Business website I run. Love Django!!
I have hampers with a number of products. Each hamper has different products. I'd love to be able to use the following structure to move products into a hamper.
An example: Django uses the following to have a list of groups which then moves to Chosen Groups:
All I seem to be able to get with a ManyToManyField is a list box which I have to select by control and clicking to add multiple fields. This becomes impractical and not easy to read.
To take it one step further, I'd love to be able to include a product more than once. For example, a hamper which has three bottles of the same beer. I would like to not have to set up three seperate products for the same hamper.
Thanks so much in advance for pointing me in the right direction.
I found the answer for part of it. I simply added filter_horizontal to the admin.ModelAdmin class in admin.py.
Still not sure how to add multiple quantities, but I'll maybe save that for another day.
On SugarCRM 7+ how can I remove the "unlink relationship" either permanently, user based or amount of relationships?
My problem is that I have two custom modules with a many-to-many relationship between them and I can't limit a user from editing, deleting or creating records on both modules since I actually want the users to be able to do those actions etc but at the same time I need to block unlinking of relationships either:
permanently
user based
based on the current amount of relationships
I've gone through a lot of google searching (about 7 hours total) but I couldn't find a tutorial or blog post about this type of customization for SugarCRM 7.1+ (I feel things changed a bit on subpanel customization on this version)
also, is there a way to easily add a "created_datetime" and "deleted_datetime to the relationship itself? I found a few "overkills" for such customization and my sugar skills are not that high to implement them.
I've decided to have extra modules making the relationships so then I have a related field on each of my current modules pointing to a module in the middle where I can customise fields anyway I want "and" I will block the related fields from modification based on user and if the field has been set already etc.
This is an obvious solution but I wanted to have less modules for plain and simple OCD. Once I convinced my brain that not being able to customise the relationship with "control" fields was even worse for OCD than having more modules everything settled down!
I'm developing a Twitter-like system, and have a model to record who follows who. There are two fields and both fields are foreign keys and point to the User model.
Clearly you wouldn't want a follower-followee record duplicated, so I'm using the unique_together attribute in the inner Meta class, in order that the follower-followee pair is unique. Trying to violate this throws IntegrityError and 500 status code.
This feels like a "second line of defence" as my view and template code doesn't give a user the chance to follow someone twice.
Should I/can I do something similar to ensure you can't follow yourself?
The view and template that lists all users (each with a button to click to follow that user) does not list the currently logged in user, so there should be no opportunity to follow yourself. But I don't have anything equivalent to unique_together.
Dude, no.
I don't know why you're doing this, but assuming it isn't for a uni project with a lunatic professor, you're wasting your time.
That is, if he's not a lunatic he's not going to try and hack the following/followee . And so what if he does?
If its for a startup-idea, then spend less time solving this (trivial) problem and more time working on whatever business model or marketing or whathaveyou thing you need to do.
A little bug isn't going to be a show stopper.
If you're being contracted out, leave it as a bug and get the conteact extended to fix it :)
If you just want to fix this, just do a check in the model or the validation that the follower isn't the same as the followee
I'd like to list all active products (from all or a specific category) in a template. I've looked almost everywhere and I simply cannot find a way to do this.
I want to display them in the footer of the shop (10 products from 1 category). That means show them without selecting product category.
Is this even possible? Products are only listed in the category template...
I'm using Satchmo 0.9.2
EDIT: Somehow I've missed this:
http://www.satchmoproject.com/docs/dev/customization.html
So it's solved...
Thank you!
this is a more general answer since there isnt any answer yet, so dont beat me. You also have to know that I never used satchmo, I never had a look at it.
But despite this, if I had to deal with your situation, I would have a look at the source code.
You might find answers there to develop something custom for your situation. This can be a tricky task but at least its worth a try.
There have to be models which store the data for your product and categories. Have a look at them and the views that retrieve the products from the database to render them. Also a look into the database cant hurt (think of phpmyAdmin to have a nice webbased interface).
It can be helpful to fire up your ./manage.py shell, import your/satchmos product and category models and play around with them.
A possible solution then could be to write a custom context_processor which retrieves the needed products/categories and passes these products from a category to your footer on a more global basis. Have a look here https://docs.djangoproject.com/en/1.3/ref/templates/api/#writing-your-own-context-processors. Maybe a custom middleware could also be a possibility. https://docs.djangoproject.com/en/dev/topics/http/middleware/#writing-your-own-middleware
I hope this helps. At least worth a try :)
I'm trying to model a "what's hot right now" like function for a video library (i.e a Most-viewed related to time - Clustering views (in time) will cause a higher rating), but I can't quite get my head around how do to it properly in Django without causing a multitude of database queries. I realize there's no one right answer to this, but I'm at a complete loss. The list will vary on categories but will be displayed in all views on the site, so I can't just hack together a solution - it needs to be fairly optimal.
I'm pretty new to Django so if there's any trick I could employ to make this less of a problem I'd love to know.
I should point out that I can add fields to the models at will, as we're still working on the specification for the site.
You could use a table (model) for clusters, like one for days, one for weeks, one for months, etc, and store viewcount there instead of in the video's model itself, then you just reference it. Like:
Months.objects().filter(month=this_month).order_by(viewcount)[0].video