Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,143,447 members, 7,781,292 topics. Date: Friday, 29 March 2024 at 11:56 AM

For Django Developer - Programming (5) - Nairaland

Nairaland Forum / Science/Technology / Programming / For Django Developer (11692 Views)

Python/django Developer / CI/CD Pipeline For Django Application / Django Developer Plz Help (2) (3) (4)

(1) (2) (3) (4) (5) (6) (7) (8) (9) (Reply) (Go Down)

Re: For Django Developer by LSarcastic: 5:30pm On Jul 19, 2020
I believe that by 'knowledge' it's not only Django and Flask but HTML and CSS. Yes, you can call yourself a Backend developer. You'll have to prove it with projects though.
Heylonmusk:
Can I call myself a BACKEND developer if I have knowledge of Django or flask alone.

1 Like

Re: For Django Developer by Taofeekdboy(m): 6:38pm On Jul 19, 2020
LSarcastic:
I think the OneToOne relationship is a better approach. One thing I've learnt about OOP is the SOLID principle. Responsibilities should be divided across classes and models. Leave the User model to handle core Django features while you have a different model that provides other functionalities for a user. So many things could go wrong with Abstract User.

I understand you perfectly but there are some scenarios where AbstractUser is a better approach as well and based on the example I made earlier, it is a better approach, when you are writing permissions, it is a better approach to inherit from AbstractBaseUser when you know what you are doing. Using User model directly is very tho because if things go wrong then it can be fatal.

1 Like

Re: For Django Developer by fortifiedng: 11:44pm On Jul 19, 2020
Taofeekdboy:

I understand you perfectly but there are some scenarios where AbstractUser is a better approach as well and based on the example I made earlier, it is a better approach, when you are writing permissions, it is a better approach to inherit from AbstractBaseUser when you know what you are doing. Using User model directly is very tho because if things go wrong then it can be fatal.

Even the Django documentation recommends you start every project inheriting from AbstractUser.

E get why.

1 Like

Re: For Django Developer by LSarcastic: 11:49pm On Jul 23, 2020
You've got a solid point man.
Taofeekdboy:

I understand you perfectly but there are some scenarios where AbstractUser is a better approach as well and based on the example I made earlier, it is a better approach, when you are writing permissions, it is a better approach to inherit from AbstractBaseUser when you know what you are doing. Using User model directly is very tho because if things go wrong then it can be fatal.
Re: For Django Developer by teamoneline: 9:47pm On Jul 30, 2020
Are there jobs for django in nigeria at all?
Re: For Django Developer by Taofeekdboy(m): 5:33am On Jul 31, 2020
teamoneline:
Are there jobs for django in nigeria at all?
If there is, it will be few because most request for PHP, C# e.t.c but foreign companies do use django
Re: For Django Developer by hitan(m): 12:10pm On Jul 31, 2020
Hello guys i am building a django web app, and i run into this error..... NoReverseMatch at /groups/posts/in/python/
Reverse for 'user-posts' with keyword arguments '{'username': ''}' not found. 1 pattern(s) tried: ['user/(?P<username>[^/]+)$']

below is the sample of the template HTML page

<h3 class="mr-5"><a href="{% url 'posts:user-posts' username=post.user.username %}">@{{ post.user.username }}</a></h3>
<div class="media-body">
<strong>{{ post.user.username }}</strong>
<h5>{{ post.message_html|safe }}</h5>
<time class="time"><a href="{% url 'posts:post-detail' username=post.user.username pk=post.pk %}">{{ post.created_at }}</a></time>
{% if post.group %}
<span class="group-name">in <a href="#">{{ post.group.name }}</a></span>
{% endif %}
</h5>


below also is a sample of the app urls.py code

path('', PostListView.as_view(), name="blog-home"wink,
path('user/<str:username>', UserPostListView.as_view(), name="user-posts"wink,
path('post/<int:pk>/', PostDetailView.as_view(), name="post-detail"wink,


And here is my views.py code that controls the username

class UserPostListView(ListView):
model = Post
template_name = 'blog/user_posts.html'
context_object_name = 'posts'
paginate_by = 6

def get_queryset(self):
user = get_object_or_404(User, username=self.kwargs.get('username'))
return Post.objects.filter(author=user).order_by('-date_posted')


How can I fix this, it seems the "username" is empty hence not matching the regex in urls.py?
Re: For Django Developer by Taofeekdboy(m): 12:54pm On Jul 31, 2020
hitan:
Hello guys i am building a django web app, and i run into this error..... NoReverseMatch at /groups/posts/in/python/
Reverse for 'user-posts' with keyword arguments '{'username': ''}' not found. 1 pattern(s) tried: ['user/(?P<username>[^/]+)$']

below is the sample of the template HTML page

<h3 class="mr-5"><a href="{% url 'posts:user-posts' username=post.user.username %}">@{{ post.user.username }}</a></h3>
<div class="media-body">
<strong>{{ post.user.username }}</strong>
<h5>{{ post.message_html|safe }}</h5>
<time class="time"><a href="{% url 'posts:post-detail' username=post.user.username pk=post.pk %}">{{ post.created_at }}</a></time>
{% if post.group %}
<span class="group-name">in <a href="#">{{ post.group.name }}</a></span>
{% endif %}
</h5>


below also is a sample of the app urls.py code

path('', PostListView.as_view(), name="blog-home"wink,
path('user/<str:username>', UserPostListView.as_view(), name="user-posts"wink,
path('post/<int:pk>/', PostDetailView.as_view(), name="post-detail"wink,


And here is my views.py code that controls the username

class UserPostListView(ListView):
model = Post
template_name = 'blog/user_posts.html'
context_object_name = 'posts'
paginate_by = 6

def get_queryset(self):
user = get_object_or_404(User, username=self.kwargs.get('username'))
return Post.objects.filter(author=user).order_by('-date_posted')


How can I fix this, it seems the "username" is empty hence not matching the regex in urls.py?
In your urls. py, did you add any app_name 'posts' or not, of you have not, add it and try again
Re: For Django Developer by hitan(m): 3:29pm On Jul 31, 2020
Taofeekdboy:
In your urls. py, did you add any app_name 'posts' or not, of you have not, add it and try again
Please I would like to know why adding an app name in the urls.py would have that effect on the app
Re: For Django Developer by hadamz: 4:49pm On Jul 31, 2020
hitan:

Please I would like to know why adding an app name in the urls.py would have that effect on the app


Since you are will be calling it in the html i.e post:name of url therefore you must add create the app name. Sorry which book or tutorial video are are you using to learn?
Re: For Django Developer by Taofeekdboy(m): 5:25pm On Jul 31, 2020
hitan:

Please I would like to know why adding an app name in the urls.py would have that effect on the app
it is mandatory to add it because if you have more than one app in your django project, and the URL name is the same, then the URL need to match up with URL name you provide, that's why it is important to prefix it an app_name. I wish I could explain much better.
Re: For Django Developer by hitan(m): 5:34pm On Jul 31, 2020
Taofeekdboy:
it is mandatory to add it because if you have more than one app in your django project, and the URL name is the same, then the URL need to match up with URL name you provide, that's why it is important to prefix it an app_name. I wish I could explain much better.
In my groups app urls.py I did create an app name groups, so I don't know why there should be a clash, cos when I am referencing groups component using template tag I always use "groups:group_detail"... I removed app name from posts because it was giving me "namespace" error.
I am using Corey Shafer tutorial on Django for the development of the web app, but I decided to add groups to the web app to make it robust
Re: For Django Developer by hitan(m): 7:59pm On Jul 31, 2020
Taofeekdboy:
In your urls. py, did you add any app_name 'posts' or not, of you have not, add it and try again
I just did and still get the same error, please how can I resolve this issue its really giving me concern...
Re: For Django Developer by Donpre(m): 8:21pm On Jul 31, 2020
hitan:

I just did and still get the same error, please how can I resolve this issue its really giving me concern...

did you add the app_name to your main urls.py using 'namespace'
Re: For Django Developer by westfield: 2:31pm On Aug 01, 2020
Please am really in need of a hacker someone who can track someone phone 07059874837
Re: For Django Developer by teamoneline: 4:52pm On Aug 06, 2020
django tip:

insert import ipdb; ipdb.set_trace() at the end of the file django identifies as the source of the error,
reload the page and your browser will pause(continue loading not stopping),
then go to your console. an interactive debugger will be set up, just type a variable name and hit enter, the value will be displayed.

Good for debugging
Re: For Django Developer by pixey(m): 11:08am On Aug 07, 2020
@Taofeekboydb,donpre and co ! Hello guys ! I am really enjoying this thread.I am also a django beginner too.I would like if we present our django issues on whatsapp or telegram group.More a like mini stackoverflow for us.
Re: For Django Developer by Toppytek(m): 6:13pm On Aug 08, 2020
pixey:
@Taofeekboydb,donpre and co ! Hello guys ! I am really enjoying this thread.I am also a django beginner too.I would like if we present our django issues on whatsapp or telegram group.More a like mini stackoverflow for us.

Did you know that you wouldn’t have come across this thread had it been it has been moved to WhatsApp?

1 Like

Re: For Django Developer by saheedniyi22(m): 7:08pm On Aug 08, 2020
Toppytek:


Did you know that you wouldn’t have come across this thread had it been it has been moved to WhatsApp?
I wanted to say that too.

Nairaland has the advantage of being open, so there is continuous flow of knowledge unlike whatsapp and telegram.
Re: For Django Developer by pixey(m): 1:50pm On Aug 09, 2020
Toppytek:


Did you know that you wouldn’t have come across this thread had it been it has been moved to WhatsApp?

I understand you bro but dont get me wrong here .What I am saying is that we can develop a community of django devs where django related problems are resolved just like a mini stackoverflow etc.... for NL members. We don't have to use whatsapp. Just an opinion.
Re: For Django Developer by Daejoyoung: 6:52pm On Aug 09, 2020
pixey:


I understand you bro but dont get me wrong here .What I am saying is that we can develop a community of django devs where django related problems are resolved just like a mini stackoverflow etc.... for NL members. We don't have to use whatsapp. Just an opinion.
But can't all of that still be achieved on the thread?
Re: For Django Developer by pixey(m): 11:14pm On Aug 09, 2020
Well like I said its just an opinion.
Re: For Django Developer by Donpre(m): 9:28pm On Aug 12, 2020
Bosses them, abeg wetin be 'instance', can't find anything in the documentation about it

Re: For Django Developer by fortifiedng: 1:13am On Aug 13, 2020
Donpre:
Bosses them, abeg wetin be 'instance', can't find anything in the documentation about it

Instance there means that, when the user wants to update their profile, their previous information would be filled automatically.

It's like creating an instance of what was there, before you edit it.

TIP: Check the meaning of instance in the dictionary for better understanding

2 Likes

Re: For Django Developer by Taofeekdboy(m): 5:18am On Aug 13, 2020
Donpre:
Bosses them, abeg wetin be 'instance', can't find anything in the documentation about it

In any OOP language, when you create a class, then you can create a variable name to instantiate the class e.g

Class Dog :
Def ___init____(self, name, age):
self. name =name
self. age = age

So here you can instantiate the class dog like this

dog1 = Dog('bingo', 5)
dog2 = Dog('linzy', 2)

So dog1 and dog2 are both instance of the dog class. You can read more on classes on python to understand better.
Re: For Django Developer by Donpre(m): 10:32am On Aug 13, 2020
fortifiedng:


Instance there means that, when the user wants to update their profile, their previous information would be filled automatically.

It's like creating an instance of what was there, before you edit it.

TIP: Check the meaning of instance in the dictionary for better understanding

Thanks, I finally get it now
Re: For Django Developer by Donpre(m): 10:34am On Aug 13, 2020
Taofeekdboy:


In any OOP language, when you create a class, then you can create a variable name to instantiate the class e.g

Class Dog :
Def ___init____(self, name, age):
self. name =name
self. age = age

So here you can instantiate the class dog like this

dog1 = Dog('bingo', 5)
dog2 = Dog('linzy', 2)

So dog1 and dog2 are both instance of the dog class. You can read more on classes on python to understand better.
OOP in python is quite confusing. Starting with "self" instead of "this" to the weird init constructor.

I get what instance is, just didn't understand how it could be a property of a form. It's clear now though.

Thanks for the help
Re: For Django Developer by saheedniyi22(m): 10:06pm On Aug 13, 2020
Donpre:


It's nothing complex, just ordering of url patterns, I already got some insight as to how to do it tho.

the editor is Acode, while I use pydroid3 terminal to run command-line comands... I don't use iOS, but I'm sure a Google search would produce results
Good evening,

I use pydroid too, I want to know if you have been able to use the pydroid terminal to perform GitHub stuffs like push, clone and co?
Re: For Django Developer by Donpre(m): 10:17pm On Aug 13, 2020
saheedniyi22:

Good evening,

I use pydroid too, I want to know if you have been able to use the pydroid terminal to perform GitHub stuffs like push, clone and co?

No I haven't tried it
Re: For Django Developer by saheedniyi22(m): 10:23pm On Aug 13, 2020
Donpre:


No I haven't tried it

I've been trying recently but haven't been successful with it.

How do you upload your codes on GitHub?
For now I do copy and paste though.
Re: For Django Developer by Donpre(m): 10:42pm On Aug 13, 2020
saheedniyi22:


I've been trying recently but haven't been successful with it.

How do you upload your codes on GitHub?
For now I do copy and paste though.
Haven't published my code to GitHub since my PC crashed.

I didn't even think to try.

I'll try it later tonight, and see if it works

1 Like

(1) (2) (3) (4) (5) (6) (7) (8) (9) (Reply)

Can Obfuscated Php Script Be Decoded? / Best Laptops For Programmers / ALC 2.0 Is Here

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 61
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.