Anonymous
Hi I have a query can anyone help me on django
Anonymous
I creating a game application
Rank depends on score if score is high than rank is 1.
Can anyone help me
Anonymous
Anonymous
MR_X
hello
MR_X
pls tell websites for ..
templates
MR_X
html,css,js
Mirco
Doragonsureiyā
pls tell websites for ..
templates
Please don't ask meta questions like:
"Any user of $x here?"
"Anyone used technology $y?"
"Hello I need help on $z"
Just ask about your problem directly! With 42k+ people the probability that someone will help is pretty high.
Also please read: http://catb.org/~esr/faqs/smart-questions.html
Anonymous
Anonymous
I tried but not able to find solution
Muflone
Just sort the results
Anonymous
In models or in view???
Muflone
In the view you extract the data from the model, sorted using Model.objects.all().order_by("score") and pass them to the template
Muflone
If you want the rank number explicitly you wrap the data in an enumerate function
Anonymous
Muflone
Use enumerate function looping the results and you'll have an index for each row
Anonymous
Muflone
A model is a single row, it shouldn't have things related to other records.
You could but you shouldn't
Anonymous
Okay
Sávio
Good evening guys, could you give me a hint on how I put a value inside a django tag?
Germinate
Germinate
unless you need to allow the user to click on each product, you do not need to use a form.
you can just set the variables as dictionary of product names and costs. then send it to the html from the server using render and do the loops in html using {{variable name}} loops to display the names and costs
Germinate
even if you use a form, you still have to do the {{variable name}} loops to display. a form only helps you post data to the server from the html.
to collect data, you need to indicate the form name under a form tag, after the csfr token
Anonymous
User should to full in form about everyone product (subscription term, and update frequency). And maybe I need to iterate formset, and product data together? But how are I can do it?
Yash
i am facing error when user is verfiy is mail Manager isn't available; 'auth.User' has been swapped for 'accounts.CustomUser'
Yash
anyone have solution then please help
Manik
Object of type datetime is not JSON serializable,
Manik
help me
Manik
its utc ,cant covert to int
Денис
Manik
'poldate':datetime.utcnow().replace(tzinfo=tz.gettz('UTC'))
Manik
i want to post the poldate to django server with json conversion
Manik
resp = requests.post(BASE_URL+ENDPOINT, data=data1) —hitting error
Muflone
Just remove the milliseconds
Manik
tempdate = int(utnow)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'datetime.datetime'
Muflone
Muflone
The decimal part will be the milliseconds, if you don't need it just remove them (from datetime or from the timestamp) or if you need the precise time including milliseconds you could just multiply it for 1000 (like Java does)
Manik
timestamp = datetime.timestamp(utnow) and sent timestamp to server
but database didnt parse it — timestamp = datetime.timestamp(utnow)
Manik
datetime_re.match(value)
TypeError: expected string or bytes-like object
Muflone
Sávio
Anonymous
Ok
Muflone
Where did you got this "operator"?
Firdaus
I heard of isinstance... but not instance
https://docs.python.org/3/library/functions.html#isinstance
Firdaus
https://docs.djangoproject.com/en/2.2/ref/models/fields/#django.db.models.FileField.upload_to
instance:
An instance of the model where the FileField is defined. More specifically, this is the particular instance where the current file is being attached.
In most cases, this object will not have been saved to the database yet, so if it uses the default AutoField, it might not yet have a value for its primary key field.
Firdaus
I think the example a few scrolls below that is already self explainatory
Firdaus
in the example case that would be the instance of MyModel
Mirco
Do you know what a class and instance of a class is ?
Mirco
If u are not sure, study better OOP
Mirco
I don't think so if u are still asking yourself what instance means
Maybe u need more time to study better
Firdaus
also... the instance in the official doc that we just refered to... it is not an operator. It's a parameter in the user_directory_path function.
Sorry, I wish I can explain better... English is not my first language.
🙏🏽
Mirco
bar = Foo()
bar is an instance of Foo
Imagine Foo is a model, bar is an instance of that model
Germinate
Germinate
basically an instance is a copy of whatever you are calling
Germinate
you declared a class which contains a bunch of variables. you are now calling a copy of it
Mirco
Yup
Mirco
Germinate
Germinate
sorry having difficulty understanding you
Anonymous
Of course)
Anonymous
Firdaus
I think the convention is to use the word instance. The same convention that suggest we use self, and cls.
Firdaus
But you can use any word that you like.
Germinate
Wisdom
Hello please how can i convert my django project to a windows desktop app?
Reginald
Please I need a resourceful tutorial on Django it's urgent please 😁
JAN
SkyLord
Hello
here is the situation:
there is an application in which there is a user model UserShop with its own structure
this application have registration form and of course the authorization
for authorization the following URL is used:
path ('login /', LoginView.as_view (template_name = 'shopapp / sign_in.html'), name = 'shop-sign-in'),
Apparently I am using the standard django LoginView.
Now, for example, I have 2 registered users according to the UserShop model, BUT, there is also a superuser
when in the front I try to login with those 2 users, all is ok get into the dashboard of the user of this application BUT if I try to log in with the superuser, an error pops up:
django.contrib.auth.models.User.usershop.RelatedObjectDoesNotExist: User has no usershop.
as far as I understand, it appears from the above error that the user I am trying to authorize is not part of the usershop
can someone explain to me how to check this and how to handle this error
Денис
Hello
here is the situation:
there is an application in which there is a user model UserShop with its own structure
this application have registration form and of course the authorization
for authorization the following URL is used:
path ('login /', LoginView.as_view (template_name = 'shopapp / sign_in.html'), name = 'shop-sign-in'),
Apparently I am using the standard django LoginView.
Now, for example, I have 2 registered users according to the UserShop model, BUT, there is also a superuser
when in the front I try to login with those 2 users, all is ok get into the dashboard of the user of this application BUT if I try to log in with the superuser, an error pops up:
django.contrib.auth.models.User.usershop.RelatedObjectDoesNotExist: User has no usershop.
as far as I understand, it appears from the above error that the user I am trying to authorize is not part of the usershop
can someone explain to me how to check this and how to handle this error
A superuser created by createsuperuser command is a User, and any ForeignKey-related fields, as well as subclasses of the User model are ignored on creation. You have to create related field yourself and save
O
Any simple and efficient way to refresh grid without refreshing page ?
Maksim
Alexander