Creating models

To make a webpage that contains images, videos, texts, how can i creat models. My project is let say a person(john) have tiktok acc, insta acc, his youtube channel etc. My website should show these data so for this how can i creat models.

The first thing you need to do is identify what all the data is that you need to track for each user.

For this webpage how can i write module. Help plz.

How much experience with Django do you have? How many other Django projects have you built? (Your answers here will help us target our answers for you.)

This is be my first project. I dont have too much experience.

Ok, so if you’ve worked through either the official Django Tutorial or the Django Girls tutorial, you’ve learned how to build a model and how to create relationships between tables.

From there, you’ll want to read the Model field docs to get an idea of what kinds of data you can store in your models. You may want to look specifically at the FileField and ImageField docs to get some ideas.

Beyond that, then it’s just a matter of identifying what the data is you want to store and creating the fields to store them.

What I would suggest is that you trim down your scope for this first iteration. Instead of trying to build everything all at once, pick just one facet of this to get something up and running to minimize the number of different components you may need to code to start. Once you’ve gained the knowledge of seeing how all the pieces fit together, then you’ll find it a lot easier to add the other components.

Is this correct

Class Person_detail(models.Model):
name = models.CharField(max_length = 20)
profession = models.CharField(max_length = 20)
bio = models.CharFirld( max _length = 150)

Class video(models.Model):
name = models.Charfield(max_length = 20)
videofile = models.File.field( upload _to = ‘media_root_directory’)

Class img(models.Model):
name = models.Charfield(max_length = 20)
imgfile = models.Image.field( upload _to = ‘media_root_directory’, height_field = ‘100’, width_field = ‘100’, max_length = ‘100’)

You’ve got a fair number of typos in there - I’ll assume are due to retyping it here rather than copy/pasting your actual code.

Assuming the syntax is correct, those could be valid models. But since you haven’t really described what your data structures need to be, I can’t say whether this will fit your requirements or not.

This leads me back to the more fundamental question - do you know precisely what it is you’re trying to do here? Do you know what data you’re needing to manage, and how that data relates to the other data in your proposed system?
Also, have you come up with your “minimum” implementation for what you want to do to get started?

There i am just trying to creat table for datas such as videos, image and texts from which i can describe about a person detail.

You’re still being vague here. “Create table for data such as…” is just a starting point. You need to identify exactly what data you need to store for a person. You need to have a very clear understanding of what you’re trying to do, and what you need to store in order to accomplish this.

So far I think you’ve got a general idea of what you want the end result to look like, but you haven’t yet shared what that all means from the perspective of the data. This may be why you’re struggling with creating your models - you may not have figured out what the data is that you need to store, and that’s what you need to work on next.

Yeah you are right.

Now i am getting clear
Here i want:
A person
For whose i want to store:
His name( first and last) it would be text.
His profession( example, webdeveloper) [ text]
His pp size photo :man_technologist: , [ img]

Or say i want to make identycard.

And now i should work for these data. Right.

Cool, ok. Then all those fields would be fields in your Person model. For each of those pieces of data, you’ll define a field to hold it.

But since we’re talking about people, there’s one aspect of this that may affect how you design this. Are these people all “registered users” of your site, in which case they would be associated with the build-in User model, or are they different people?

Yeah, registered user

In that case, you’ll want to read the docs on Extending the existing User model, particularly starting from the second paragraph where it starts to talk about a “profile model”.

1 Like