mindobiee / DjangoProject2

Django를 이용한 instagram clone new Repository입니다.
0 stars 1 forks source link

NoReverseMatch at /photo/ #1

Closed mindobiee closed 4 years ago

mindobiee commented 4 years ago

image

zair07 commented 4 years ago

Can I work on this issue? If yes are there any guidelines for contribution?

mindobiee commented 4 years ago

Thanks, but I don't understand your context..."guidelines for contribution"

zair07 commented 4 years ago

@mindobiee are there any steps to follow while documenting the code or anything like that

mindobiee commented 4 years ago

@zair07 I got it, but now when I try to run server and go to login page, it doesn't appear, either. I think it get wrong since I change some codes to figure out above issue...

this is what I changed...

  1. add app_name ="member" at app "member\urls.py"
    
    from django.conf.urls import url
    from . import views
    from django.conf.urls.static import static
    from django.conf import settings

app_name = "member"

urlpatterns = [ url('join/', views.create_user, name="join"), url('login/', views.sign_in, name="login"), url('logout/', views.sign_out, name='logout'), url('delete/',views.delete, name='delete'), url('change_password/',views.change_password,name='change_password'), url('profile/',views.profile, name='profile'), url('follow/',views.follow, name='follow'), url('user_list/',views.UserList, name='Userlist'), url('people//',views.people, name="people") ] urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


2. change urls where they are used
- something like below @ "template\home\navbar"
```html
 <div class="dropdown-menu">
                        <a class="dropdown-item" href="{% url 'member:login' %}">Login</a>
                        <a class="dropdown-item" href="{% url 'member:join' %}">Register</a>
 </div>
  1. and now, the new errors.... image
mindobiee commented 4 years ago

And, the steps what I encounter first, is... 1) I wanted to add "following" function 2) make a logic in views.py 3) make a template of "people.html" which has a follow button (and includes the information of the individual)

{% extends 'home/base.html' %}
{% block container %}
<div class="container">
    <div class="row">
        <div class="col-3">
            <h1>
            {% if people.photo %}
            <img src="{{ people.photo.url }}" width= 70,
                 alt="{{ people.photo}}">
            {% endif %}
            {{ people.username }}
            </h1>
        </div>
        <div class="col-9">
            <div>
                <strong>{{ people.username }}</strong>
                {{ people.followers.all }}
                {% if user != people %}
                    {% if user in people.followers.all %}
                    <a href="{% url 'follow' people.id %}">UnFollow</a>
                    {% else %}
                    <a href="{% url 'follow' people.id %}">Follow</a>
                    {% endif %}
                {% endif %}
            </div>
            <div>
                <strong> Followers: </strong> {{ people.followers.count }}
                <strong> Followings: </strong> {{ people.followings.count }}
            </div>
        </div>
    </div>
</div>
{% endblock %}

4) and make a link to "photo_list.html" through tag

<a href="{% url 'member:people' object.user.username %}">
 <p class="card-text">{{ object.user }}</p>
</a>

5) add urls

url('people/<str:username>/',views.people, name="people") 

and when I go to page (/photo) that is linked to page "photo_list.html", the issue appears...

zair07 commented 4 years ago

@mindobiee Ok I will look at it

zair07 commented 4 years ago

Its working fine on my pc. have you committed the changes that you made?

mindobiee commented 4 years ago

Yes, I pushed the new version right before

mindobiee commented 4 years ago

@zair07 I am deleting the "app_name" : It seems to be working anyway and the problem is this one.

NoReverseMatch at /photo/
Reverse for 'people' with arguments '('rosa',)' not found. 1 pattern(s) tried: ['member/people/<str:username>/']
mindobiee commented 4 years ago

@zair07 I'v just solved the problem! It was "url problem" I got a big help on this site thanks for helping me anyway!