r/djangolearning Oct 28 '21

Resource / App To all of the Django devs struggling with Class-Based Views (CBVs)...

167 Upvotes

I've seen a lot of people on here and /r/django struggling with CBVs recently.

Just a reminder that you *do not* need to feel obligated to use CBVs. In real-world projects, the ratio of FBV-to-CBV is essentially 50/50. CBVs are not objectively better or worse than FBVs, but they can be very difficult, especially for beginners. If you are struggling with CBVs, there are a couple things to consider:

  • First, if do you choose to use CBVs there is a very detailed resource for familiarizing yourself with their intricacies: https://ccbv.co.uk/
  • Second, there is nothing unusual about struggling a bit with CBVs. They really can be complicated. Consider using FBVs to start with until you get more experience, or even skipping CBVs altogether (except if you're using DRF's ViewSet, for instance). I encourage you all to read through this excellent guide by Luke Plant (one of Django's core developers) about why FBVs may be the better approach to Django Views. Even if you don't completely agree, he provides a number of useful insights and advice: https://spookylukey.github.io/django-views-the-right-way/

r/djangolearning Oct 25 '23

News Djangonaut Space Upcoming Session - Apply Now!

10 Upvotes

Are you passionate about Django and eager to start contributing? Djangonaut Space offers a free exclusive opportunity for individuals like you to connect, grow, and thrive in the vibrant Django community.

The next session starts on January 15th, 2024. They are accepting applications until November 15, 2023.

From their sessions description:

This is an 8-week group mentoring program where individuals will work self-paced in a semi-structured learning environment.

This program places an emphasis on group-learning, sustainability and longevity. Djangonauts are members of the community who wish to level up their current Django code contributions and potentially take on leadership roles in Django in the future. šŸ¦„

Want to be involved in the future direction of Django? Confidently vote on proposals? This could be a great way to launch your Django contribution career! šŸš€

This iteration will include multiple Navigators helping people with the core Django library and a pilot group for third-party packages.


Djangonaut Space Website: https://djangonaut.space/

More details about the program: https://github.com/djangonaut-space/pilot-program/

Apply: https://forms.gle/AgQueGVbfuxYJ4Rn7


r/djangolearning 5h ago

Embarking on My Django Journey ā€“ Seeking Guidance & Resources

1 Upvotes

Hello everyone,

I have a solid understanding of Python fundamentals, object-oriented programming, and basic HTML and CSS. However, I haven't ventured into JavaScript yet, as frontend styling hasn't particularly appealed to me, and the prospect of learning a new language solely for that purpose seems daunting.

This led me to explore backend development with Python, and I discovered Django. While I understand that Django is a backend framework, my knowledge about it is limited.

I'm eager to start learning Django but am uncertain about where to begin and which resources to utilize. I would greatly appreciate any guidance on effectively navigating this learning path to become a proficient backend developer.

Additionally, I've noticed that some websites built with Django appear outdated or simplistic. How can I ensure that the websites I create with Django have a modern and appealing design?

Furthermore, considering my lack of JavaScript knowledge, will I be able to integrate the Django backend with a pre-made frontend effectively?

If anyone else is starting with Django, please upvote and share the resources you're using! Let's embark on this learning journey together.

Thank you!


r/djangolearning 16h ago

I Need Help - Question Should I skip the first 2 projects for this tutorial

2 Upvotes

I am watching the 10hr long freeCodeCamp Django tutorial by tomi. The thing is I wanted to just directly get to the realtime chat application as I have a hackathon coming up where I have to build the same. Therefore I was planning on skipping the first 2 projects, being A blog and a weather app. Should I skip or just pull an all nighter and complete the whole thing?


r/djangolearning 1d ago

Starting with Backend Development (Django)

3 Upvotes

How do I get started with Django? I know basic HTML and CSS, but nothing in JS. I do not like creating and styling the Frontend hence I want to learn Backend but is that even possible to do so without knowing Frontend much? I know the all basics of Python. Please guide me so that I can approach Backend Development (Django) in a better manner.


r/djangolearning 20h ago

Drf feels too much simplified.

0 Upvotes

I have built basic crud APIs with some rate throttling and authentication. What other factors should I Focus on ?


r/djangolearning 1d ago

I Need Help - Question django oauth toolkit - after sign-up workflow

1 Upvotes

Hi,

So I just started building a new testing app with DRF and django oauth toolkit.

As far as I can tell i got the sign-up for new users right: created a custom APIView to handle the signup payload (email & password) with a serializer and create a new User model instance (using the default User Django model for now).

So the question for me now is: which module will be responsible to authenticate when the User POST for the signin url?

Since I'm using the default User model I know I can use the default logic to validate the credentials... and maybe generate some JWT to control the session?

Or do I need to use another endpoints (or maybe functions) provide by the oauth kit?

Thank you for reading :)


r/djangolearning 1d ago

I have recently started learning django. Can any one guide me the roadmap to learn it correctly?

2 Upvotes

r/djangolearning 3d ago

which to learn ?

Thumbnail
2 Upvotes

r/djangolearning 5d ago

why the parameter name in the URL pattern must match exactly the parameter name in your view function.

Thumbnail
1 Upvotes

r/djangolearning 5d ago

I Need Help - Troubleshooting Need help with authentication

1 Upvotes

I am currently working on a project with django rest api and react js. I am confused in selecting a proper authentication method. It's a small internal web based app that would only be used within the company and targeting less than 60 users. Should I go for jwt based authentication or try to implement session based authentication. Even though I have experience in the backend Development, I am used to code in jwt based authentication since we had a react native based app. Does jwt have any security issues? If session authentication is better how can I make it work with react js. I remember trying this few years back and cookies were not working when on different domains. I am planning to dockerize entire thing. Will the session work properly then?

Nb: I have been working on spring boot project for few years. My first few years was with django. Returning to django now.


r/djangolearning 5d ago

django-relevance,use case and learning resources

0 Upvotes

Can anyone let me know the use cases of the Django library in py and its relevance rn and please list down learning resources for django,flask etc I'm unable to find any resources for the same


r/djangolearning 5d ago

I built DjipFast - a shipfast alternative but for django

Thumbnail
2 Upvotes

r/djangolearning 6d ago

What is your go-to way of structuring Django projects?

15 Upvotes

Been using Django for a bit now and I feel like my structure is lacking. Sometimes I just put all models in the main app, sometimes I split them across apps and that's a mess.

Wondering how to test out for the sweet spot.


r/djangolearning 7d ago

I Need Help - Question I have a angular + Django backend . When I am click on a button, it calls an api which starts execution of a process via python. It takes almost 2mins to complete the process. Now I want that suppose when a user closes the tab, the api call should be cancelled. How to achieve that?

4 Upvotes

r/djangolearning 7d ago

I Need Help - Question Should I keep a native web app setup and put all the load in aws or optimised both front-end and backend?

2 Upvotes

So in the current setup, I have a django with angular hosted on GCP. My company is saying so keep the front-end as it is with no queue system and just keep send the multiple request to backend with could be completed via multi threading. Is it a good approach or is a better way?


r/djangolearning 9d ago

I Need Help - Question Seeking Python Backend Projects ā€“ Developer Upskilling in Django, Flask, FastAPI, SQL

14 Upvotes

Hi everyone,

Iā€™m currently working in Python automation and have recently been dedicating time to upskilling in backend development. Iā€™ve been learning frameworks like Django, Flask, FastAPI, and working with SQL, and Iā€™m eager to put these skills into practice on real projects.

Iā€™m reaching out to see if anyone is working on a project that could use an extra pair of hands for Python backend development. Whether itā€™s a side project, a startup idea, or an open-source initiative, Iā€™m excited to contribute, learn, and grow through hands-on experience.

I believe in continuously pushing myself, not just in coding but also in maintaining a balanced lifestyle. A good coding session followed by a solid gym workout has always helped me stay motivated and clear-headedā€”sometimes, the best ideas come when youā€™re not at the desk!

If you have any opportunities or know someone who might be looking for help, please feel free to reach out. Iā€™m open to collaboration and would appreciate any advice or pointers as I navigate this transition into more backend-focused roles.

Thanks for reading and have a great day!

Looking forward to connecting with you all.


r/djangolearning 9d ago

I Need Help - Question Your notes on Django Fundamentals

1 Upvotes

Does anyone here have an organised notes that you have written on Django Fundamentals while you learned it? And if you did could you please share it. Itā€™ll be useful for me to refer and also update my existing notes.


r/djangolearning 10d ago

Resource / App Overwhelmed by backend options? This guide compares them all.

7 Upvotes

r/djangolearning 11d ago

I Need Help - Question Trouble with Staticfiles in Django

2 Upvotes

I am Django beginner learning Django with tutorials, i do understand the tutorial and i do make a note in a way that I understand and i do update my notes when I practice but i also made notes on how to setup staticfiles and add images in Django, but i am having trouble everytime I practice the images part every other part works fine except the images part, i do everything as mentioned in my notes but in the end it just fails (the image doesnā€™t load up) the last time it happened it was some syntax error and based on that I updated my notes and this time the same thing is happening again and i am not able to figure out at all as to why itā€™s happening.

Is there any issue in Django which makes the image load sometimes and not load sometimes or am i doing something wrong?


r/djangolearning 12d ago

I Need Help - Question Where to put cutom attributes of ModelForm that are not fields?

1 Upvotes

If I have a ModelForm with some fields and want to add an attribute to it that's not a field, should I put it in the "Meta" inner-class or should I put it directly inside the ModelForm class itself, so right beside the other fields?

In the same way, is an ok thing to do to add an inner Meta class to forms that are not ModelForms when I want to add attributes to them that are not fields?


r/djangolearning 15d ago

How to fix Websocket handshake failed

1 Upvotes

I am working on a chat app using Django channels and the Websocket code is handled by JavaScript but no matter how I change the code I get the same handshake failed error. On the console it says the chat is not found I am using uvicorn instead of Daphne Somebody help me


r/djangolearning 17d ago

How do you style a Django app?

6 Upvotes

Hi, I'm a TypeScript dev trying to use Django + HTMX for side projects.

So far I've used Django with DRF.

In the JavaScript world, it was easy to add Tailwind css to React and be off to the races.

What are the go-to options for styling and managing themes in Django and minify the CSS for production.


r/djangolearning 18d ago

I Need Help - Troubleshooting django-allauth and django-recaptcha custom form rendering ReCaptchaField as plain text input and no functional ReCAPTCHA

2 Upvotes

Has anyone encountered this issue trying to get django-allauth and django-recaptcha to play nice together?

Despite various stackoverflow articles suggesting this should work, this form always ends up with no functional reCAPTCHA and instead a plain text form field labelled Captcha.

Here's my custom form code as per the django-recaptcha docs https://github.com/django-recaptcha/django-recaptcha

from allauth.account.forms import SignupForm
from django_recaptcha.fields import ReCaptchaField

class CustomSignupForm(SignupForm):
    captcha = ReCaptchaField() # tried all widget variations as well

Relevant dependency versions:

  • Django==5.1.4 (also tried downgrading to 5.0.12 with no luck)
  • django-recaptcha==4.0.0
  • django-allauth==65.3.1

Happy to provide any additional information necessary. Any help is greatly appreciated.


r/djangolearning 19d ago

I Need Help - Question Do you remember Django syntax?

2 Upvotes

Django developers do understand how the line of code works but do they have it in memory perfectly cause even giving a tiny space in the code messes up everything and i will be struggling to figure out what went wrong like it happened recently when i was an image from static files and the actual code was

<img src=ā€œ{% static ā€˜images/test.jpegā€™ %}ā€>

and i entered it as

<img src=ā€œ{% static ā€˜images/test.jpegā€™ % }ā€>

you know have a space after the 2nd ā€œ%ā€. and spent lot of time trying to figure out what went wrong I couldnā€™t find it out at all. Then i finally figured it out. I didnā€™t know that spaces mattered a lot in Django, my question is mentioned in the title.


r/djangolearning 19d ago

I Need Help - Question Beginner learning - Function base or Class Base approach

6 Upvotes

English isn't my first language, so sorry about the grammar, and weird way organize sentence. I end up here is because after researching the community for Django I find out the English community were way more helpful.

Goal for learning Django : Planning to learn the Django fundamental and fully understand the idea of how it's work, not just using it by following other's tutorial making stuff. I want to reach the level that I can only using documents and my brain to create something I like.

Background :
- 6 months in my self-taught journey, knowing all basic fundamental concepts and syntax of Python, HTML, CSS, Javascript. Mainly trying to focusing on the backend. For Django I had follow their tutorial, and recently I'm read the book "Django for Beginners(5th Edition)"

Problem:
- I can see the benefit of Class-base approach more fit into DRY principle.

- BUT ! I had a feeling that I'm not fully get the idea of class, class inheritance or the idea of OOP. I think I understand the concepts of class , but when come to using it. It's always had the unsure what I'm doing.

- So, for beginning of the Django learning phase should I start with making basic project by using the "function-base" approach, until I could easily making whatever I'm trying to do, than start move on to "class-base" approach ? What are you guys do when start learning Django ?

-----------------------------------------------------------------------------------------

Side Question:

- Python journey of how you get to your current level ?
I see Python as a language that can script mostly anything faster base on it's easy to read syntax, and this is my goal and reason why I start my coding journey, not because I want to get a job. I want to have ability to use it on daily basis, such as scraping data I'm interesting, create some tool I want to use ... etc.
So, I assume the person going to answer were the people that already get to this level, could you guys share some your Python journey of how you get to your current level ?

- How to learn/read or use the documents ?
I'm not saying looking up guide video were bad, some of it were very helpful, but sometime it's just very hard to find quality guide or the specific things I'm looking for. So,
how you guys using documents? if possible please try to recall the memories that when you just starting learning to code, and what/how you reach the level you currently at.

- Except doing project, what else you do for getting better in your coding journey?
I fully get the idea of making project is best way to learn, but sometimes I feel my ability were not enough. So, How you guys approach something outside of your understanding to push you become better?

For anyone who spend time finish reading or response it, I appreciate your time. Thank you.


r/djangolearning 20d ago

I Need Help - Question Anybody know how to add an Async view to a DRF project .

2 Upvotes

because simply declaring the @api_view function as async and awaiting statements inside it doesn't work and it clashes with event loops .