Neo
field2 is the seperate model having entries
Neo
field2 get all the entries from that model
Neo
Mirco
yes it have fk
ok, so this one can be useful for u to understand how select_related could speed up your queries when django has relationships
Neo
let me see
Mirco
Neo
but If you are right where can i use select_related
Neo
as I only used it in quesyset
Neo
not in fields
Mirco
not in fields
but your field2 makes a query so it calls get_queryset of that model
Neo
you mean I can do something like
def get_queryset():
super(something)
mynewqueryset here
Doragonsureiyā
Neo
ok thanksI will read it fully
Mirco
S.
hi friends I wanna send e mails periodicly. And my model has start date- end date-cronExpression
for example
startdate=04.04.2019
enddate=05.05.2019
cronExpression= 0 10 * * 1 (“At 10:00 on Monday.”)
how can I make this I dont know? Should I use Celery or CronTab? I dont know. Can you explain?
Mirco
S.
thank youuu
Mirco
highnes
I have a model userprofile with one to one relation with user model, how can i acess data of logged in user from userprofile model
inchidi
highnes
Can someone help, please
Doragonsureiyā
Please format the code you posted, by wrapping it in triple backticks. -> `
highnes
class UserProfile(models.Model):
models.OneToOneField(User,on_delete=models.CASCADE)
mob_no = models.CharField(max_length=10,blank=False,default=None)
house_no = models.CharField(max_length=80,blank=False,default=None)
street = models.CharField(max_length=80,blank=False,default=None)
district = models.CharField(max_length=80,blank=False,default=None)
state = models.CharField(max_length=80,blank=False,default=None)
pin = models.CharField(max_length=9,blank=False,default=None)
inchidi
class UserProfile(models.Model):
models.OneToOneField(User,on_delete=models.CASCADE)
mob_no = models.CharField(max_length=10,blank=False,default=None)
house_no = models.CharField(max_length=80,blank=False,default=None)
street = models.CharField(max_length=80,blank=False,default=None)
district = models.CharField(max_length=80,blank=False,default=None)
state = models.CharField(max_length=80,blank=False,default=None)
pin = models.CharField(max_length=9,blank=False,default=None)
actually you dont need to do this because django already provide default related_name value but you can add related name to your one to one field like this models.OneToOneField(User,on_delete=models.CASCADE, related_name='profile')
inchidi
then you can access user profile from user.profile
highnes
Thankyou @Inchidi
Anonymous
hello
Anonymous
Hello everyone i cant work is_valid() function in djangk when i loaded page is_valid() function auto working also clean methods dont work i click submit button page only refresh
Sebuhi
Anonymous
I cant share images
cj
Anonymous
forms.py https://i.hizliresim.com/P1yldb.png login view https://i.hizliresim.com/k9qOz7.png
st9_8
Hello
st9_8
Hmmm for fun?
st9_8
st9_8
On which project?
hik
Hey josha
hik
İ am with you
hik
What is the pejoct about?
hik
Project
Anonymous
valar dohaeries dead man
Sagar
Hi guys.
For loading static files, its {% load static %} or {% load staticfiles %}, which 1 is correct
Ronald
Ronald
but
Ronald
you also need static
Sagar
Ok, it doesn't load css and images even woth staic files
Ronald
it allows you to link to static files eg <link rel="stylesheet" href="{% static '/main.css' %}">
Ronald
Ronald
?
Sagar
Ronald
development or production?
Sagar
Ronald
Dev
where is your static folder?
Sagar
Ronald
also in your settings.py
Ronald
STATIC_URL = '/static/'
Ronald
for production that’s a bit different
Sagar
Sagar
Ronald
Under my app
technically it should be inside your app folder
Ronald
try that
Sagar
Sagar
https://pastebin.com/zrLyCAQJ
Mirco
Sagar
Ronald
use this
Ronald
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
Mirco
and u need to serve them using static() django app so you need to add a line into your urls.py if debug is True
Ronald
not familiar witht he staticfiles_dirs that you’re using
Ronald
that’s weird
Sagar
Mirco
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
You have to add this code to your main urls.py to get static works on dev mode
Ronald
in your html use both
{% load static %}
{% load staticfiles %}
Ronald
i see one is commented out
Ronald
#
I want to study django, but I couldn't get enough resources. If there is any who want to help me, attack me any resources on @erma43