Welcome, Guest: Join Nairaland / LOGIN! / Trending / Recent / New
Stats: 2,523,963 members, 5,774,584 topics. Date: Friday, 07 August 2020 at 12:00 AM

For Django Developer - Programming (5) - Nairaland

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

Django Developer Plz Help / Please Review My Python (django) Site / Python/django Developer Needed (2) (3) (4)

(1) (2) (3) (4) (5) (Reply) (Go Down)

Re: For Django Developer by LSarcastic: 5:30pm On Jul 19
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.
Re: For Django Developer by Taofeekdboy(m): 6:38pm On Jul 19
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
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
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
Are there jobs for django in nigeria at all?
Re: For Django Developer by Taofeekdboy(m): 5:33am On Jul 31
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
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
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
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
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
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
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
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
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
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
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

(1) (2) (3) (4) (5) (Reply)

MATLAB: The Language Of Technical Computing / Meet Nairachat - Nigeria's New Phenomenon / Garage48 Winner's Idea - "A call Center Application"?

(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 - 2020 Oluwaseun Osewa. All rights reserved. See How To Advertise. 93
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.