Friday, March 3, 2023

Re: Ordering of code

Both are related to the python language, nothing Django specific about them.

This may help (not in explaining so much as demonstrating workarounds):


Regards,
/d

------ Original Message ------
From "Michael Starr" <starrtennis@gmail.com>
To "Django users" <django-users@googlegroups.com>
Date 3/4/2023 7:43:18 AM
Subject Ordering of code

Does anyone know why in django models (and I don't know how it is in etc. python), you can define a function below, and use it above in the code, but a class can't reference a class defined later in the code, or it won't find it?

That seems like beyond stupid to me.

Michael

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2409c040-107d-40e3-a828-0013851d0d98n%40googlegroups.com.

Thursday, March 2, 2023

Re: "Django road map and resources"

I'll second that - Udemy is a great resource and frequent run specials on courses.

Also, don't overlook Youtube where you can often find same/similar and good quality content available for free.

Regards,
David

------ Original Message ------
From "Sebastián Bevc Costa" <sebastian.bevc@gmail.com>
To "Django users" <django-users@googlegroups.com>
Date 3/3/2023 12:06:11 AM
Subject Re: "Django road map and resources"

You can search for Udemy courses. In some of them they build complete projects that you can follow along. There are books as well that guide you through projects, a quick google search or search in amazon books should give you some resources

Re: How to retrieve the latest object added (new one) in Django models and display it in the template?

Your problem is still about where the 'published' value is coming from in the call to filter(published=published).

Is it coming from a form? A Get parameter? A post parameter? Extract it appropriately before calling filter()


> On Mar 2, 2023, at 3:46 AM, Byansi Samuel <samuelbyansi87@gmail.com> wrote:
>
> def action (request):
> latest_action=ActionGame.objects.filter(published=published). latest()


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/A09FDF66-9845-4B93-854D-8BBFC4F5A03D%40showmethesource.org.

Wednesday, March 1, 2023

Re: django

In Django, roles are called groups:

https://docs.djangoproject.com/en/4.1/topics/auth/default/#groups



On February 27, 2023 9:49:26 AM CST, Abhishek ozha <abhishekojha123455@gmail.com> wrote:
I just created a normal school name adding API and how do I add role based authentication In that

On Mon, Feb 27, 2023, 8:24 PM OSP PRO <osp123ug@gmail.com> wrote:
Yes, Django is much trustworthy admin dashboard, than other frameworks. 

On Mon, Feb 27, 2023 at 5:29 PM Ikrombek <ikromdev25@gmail.com> wrote:
Hello
Can I create strongest dashboard with django 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f305c42f-915a-46d5-b535-559b18bb5040n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACng%3Deibg0sfVojeAVoZmFxHZyFGZtyLwgN%3D8%3DY3q6r0Bpc1KA%40mail.gmail.com.

invalit format for join_date when I ran a migration

Hi, I'm trying to run the command 'python manage.py migrate auth' but im getting this error 'django.db.utils.OperationalError: (1067, "Invalid default value for 'date_joined'")'.

I'm using Django 3.2.9 and MySQL 8.0.32-0ubuntu0.22.04.2. I changed the sql config altering the sql_mode variable but I'm getting the same error.

The declaration of the field date_joined is the default of django instalation

date_joined = models.DateTimeField(_('date joined'), default=timezone.now)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/19fa95b0-0e82-49d2-9007-b36bae8f770en%40googlegroups.com.

Tuesday, February 28, 2023

Re: How to retrieve the latest object added (new one) in Django models and display it in the template?

Se comments below.


Den fre 24 feb. 2023 kl 12:14 skrev Byansi Samuel <samuelbyansi87@gmail.com>:

Hey everyone, l got a problem. Am trying to retrieve a single latest object added everytime, and display it in the template.
Below is my codes but;

Help me figure it out the source of the problem in these different instances below 👇

_______________________ issue number 1_______

#Action/models.py
class ActionGame(models.Model):
        name=models.Charfield()
        published=models.DateTimeField()

#Action/views.py
from Action.models import ActionGame

def action (request):
        latest_action=ActionGame.objects.filter(published=published). latest()
Context={ 'latest_action': latest_action }
return....

But it returns *error* :
name 'published' is not defined


You haven't defined what the value of published is. If you want to get the last created one the query should be:
latest_action=ActionGame.objects.latest("published") - that would give you the last published item. Another way would be:
latest_action=ActionGame.objects.order_by("published").last()
 

____________________ issue number 2________

#Action/models.py
class ActionGame(models.Model):
        name=models.Charfield()
        published=models.DateTimeField()
        class Meta:
              get_latest_by='published'

#Action/views.py
........
latest_action=ActionGame.objects. latest()
.......

#but it returns *error* :
'ActionGame' object is not iterable

Even if I try this:
............
latest_action=ActionGame.objects. latest('published')
.......

#it returns the Same error:
'ActionGame' object is not iterable

But this second issue, the error is referred in #action.html

{% for x in latest _action %}
<p>{{ x.game_name }}</p>
{% endfor %}


So the latest_action variable that you have sent to the template is an instance of ActionGame - and not a list or anything. You can only access variables in the ActionGame class. For example:

 <p>{{ lastest_action.name }}</p>

would print out the value of the name of the ActionGame instance.

Please l need your assistance.

I'm Samuel,
Thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGQoQ3wMUno6hLAO-1FtN0Nn7VtkCn4qf-O4U%3DpeJ4JzY%2B%3DcAQ%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCeBCST7o-5WZx%2BmhGO2yH-Msdse%3DKusk9UOyW8XZBXRBw%40mail.gmail.com.

Re: How can I serve an Angular app from root?

Hi,

You shouldn't be serving your angular application that way. Running it in development, you run it and serve it from the "ng serve" command. Running in production, you need to have a webserver in front of your application any way, and should serve the angular files from the webserver.

Med vänliga hälsningar,

Andréas


Den sön 26 feb. 2023 kl 21:22 skrev Zayd Krunz <zaydkrunz@gmail.com>:
Hello,
I have a prebuilt Angular app, which is basically just static files. How can I serve it from the root project? If I set STATIC_URL to "/", I get the following:

django.core.exceptions.ImproperlyConfigured: runserver can't serve media if MEDIA_URL is within STATIC_URL.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/60f7e50e-7900-46f1-a91e-67038ea91e30n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCdKVjmtThYiKdQnRTYe9PEP-5Smee2LWfqUq7_edLC81Q%40mail.gmail.com.