Ghazwan
you can use graphQL but don't
inchidi
also separate means 2 running server right?
inchidi
Nope
yes
Anonymous
Why?
inchidi
because something need to make angular running
inchidi
to consume the rest api from django
Anonymous
Doesn't angular run on your browser
Anonymous
It's more of an app
inchidi
Doesn't angular run on your browser
no, that's not how spa works
Anonymous
SPA?
inchidi
SPA?
yeah single page application
Tushar
For object I have to fields Name = charField slug = charField(default = Name) but it doesn't work. I want "slug" to hold whatever "Name" is given
Tushar
I want to change the name of the slug to whatever i apply in default field
Tushar
form
inchidi
maybe slug = charField(default=get_name()) def get_name(self): return self.name
inchidi
self.name must be wrong
inchidi
but the idea is get default value from class function
inchidi
cuisine_name initialized as modelfield object not string, so you cant lower it
inchidi
oh wait, i think thats gonna work but will always None
inchidi
wow cool a correct
inchidi
because technically you are doing something like this clean_slug = str(charfieldobject).lower()
inchidi
and the charfield object doenst return any str type version of him
inchidi
what you need is value of charfield object
inchidi
and most familiar way is with self.cleaned_data['cuisine_name']
Tushar
can u tell me what to do all I need to do is change slug to some name which is given in the char field
inchidi
so you must do that inside class function
Tushar
but change the return with this
I didnt get it till now
Tushar
class Crusine(model.Model): crusine_name=models.Charfiled(max_length=100) crusine_description=models.CharFiled(max_length=256) clean_slug=str(crusine_name).lower crusine_slug=models.CharField(max_length=100, default=clean_slug) def str(self): return self.crusine_name
Tushar
Can you please make changes in this for me @DimasInchidi
inchidi
class Crusine(model.Model): crusine_name=models.Charfiled(max_length=100) crusine_description=models.CharFiled(max_length=256) clean_slug=str(crusine_name).lower crusine_slug=models.CharField(max_length=100, default=clean_slug) def str(self): return self.crusine_name
class Cuisine(models.Model): crusine_name = models.CharField(max_length=100) crusine_slug = models.CharField(max_length=100) def __str__(self): return self.crusine_name def save(self, *args, **kwargs): self.crusine_slug = self.crusine_name.lower() super().save(*args, **kwargs)
inchidi
okay
Ghazwan
class PostForm(forms.ModelForm): class Meta(): model = Post fields = ('author', 'title', 'text') widgets = { 'author': forms.Select(attrs={'class': 'form-control'})
Ghazwan
any idea why this bootsrapp class is not working well ?
Ghazwan
others widgets work just fine
Django Bot
>> Jobs - Python / Django developer for backend community mapping system
inchidi
can you check that form field element and see the value of class attribute of it?
inchidi
if its already form-control then maybe you forgot define css parent of that value
inchidi
or the js
Ghazwan
It's just bootstrap class, I was using bootswatch theme abd it gave that weird look
Ghazwan
Worked with bootstrap default theme
Ghazwan
Thank you
inchidi
Worked with bootstrap default theme
sometimes you need to put it inside div with another bootstrap class to make it work tho
inchidi
something like <form class="cool-form"><input class="form-input">....
Ghazwan
My form already had form-group class I used the Widgets for affecting forms fields itself, it turned out that I used bootswatch theme 3 for bootsrapp alpha 4, I think that was the issue
JZA
I have an issue with a queryset
JZA
I have published articles and unpublished ones, the queryset seems to hide the unpublished ones but still 'shows' them. As in, a blank space is formed on the result.
JZA
something like: * published * published * not published * published results in: * published * publsihed * * published
JZA
anyway to avoid this?
inchidi
how did you hide them?
JZA
by chaninging the published filter =true
JZA
cmsblogmodels.Post.objects.filter(sites=site_id, language_code=language_code, publish=True).order_by("-id")[:last_by_num]
inchidi
looks like nothing wrong with that
JZA
but still return a space for the unpublished article, I wonder if I could ignore the NULL result.
inchidi
maybe you can try print the queryset via shell to check it
JZA
ok
inchidi
>>> post=Post.objects.filter(sites=site_id, language_code=language_code, publish=True).order_by("-id")[:last_by_num] >>> for p in post: ....print(p.publish) ....
Ghazwan
something like: * published * published * not published * published results in: * published * publsihed * * published
Usually you set the default to false and return all objects like this return Model.objects.filter(publish_date__isnull)
Ghazwan
That would be your draft list
Ghazwan
Then you could add a function in your views.py that set publish_date to timezone.now
Ghazwan
In your post list view return the objects that had publication date
Ghazwan
That should work
Ghazwan
Also, provide a code for what you did so people can help u
Ghazwan
Side note, Don't execute timezone.now() in your model, took me a week of debugging :( it should have been timezone.now
Anonymous
I am experiencing problem in tests
Anonymous
When I create a new row in database and set a foreign key. It looks like it's not saving it's foreign key
Ghazwan
Population ?
Anonymous
As when create a query with fields of that foreign key then it's returns empty queryset
Ghazwan
?
Do you use fake library for population process in your test.py ?
Ghazwan
To fill randomly your database tables
Anonymous
no