IntegrityError: null value in column "image" violates not-null constraint - python

When I register a new user the website was creating a profile automatically and was using default.jpg image. Suddenly it stopped working. And the error says that I have a problem with my 'image' field. This is the error I get:
IntegrityError at /accounts/register/
null value in column "image" violates not-null constraint
DETAIL: Failing row contains (20, pbkdf2_sha256$150000$72dkND5yT5M0$+/chH/5Vu76KM7oNMjU694EWFZ/p+B..., null, f, kazanda, f, 2019-04-21 17:41:29.969889+00, Andreas, Swarchft, Germany, Frankfurt, andreas_sw#gmail.com, t, null).
This is my models.py
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
image = models.ImageField(default='default.jpg', upload_to='profile_pics', null=True)
def __str__(self):
return self.user.username
def save(self, force_insert=False, force_update=False, using=None):
super().save()
img = Image.open(self.image.path)
if img.height > 250 or img.width > 250:
output_size = (250, 250)
img.thumbnail(output_size)
img.save(self.image.path)
def create_profile(sender, **kwargs):
if kwargs['created']:
user_profile = Profile.objects.create(user=kwargs['instance'])
post_save.connect(create_profile, sender=User)
my views.py
class UserRegistrationView(SuccessMessageMixin, CreateView):
form_class = UserCreationModelForm
model = User
success_url = reverse_lazy('login')
success_message = "Account for %(first_name)s was created successfully. You will get email notification when admin will activate your account!"
template_name = 'users/registration.html'
def get_success_message(self, cleaned_data):
return self.success_message % dict(cleaned_data)
#login_required
def profile(request):
if request.method == 'POST':
uform = UserUpdateForm(request.POST, instance=request.user)
pform = ProfileUpdateForm(request.POST, request.FILES, instance=request.user.profile)
posts = Post.objects.filter(author=request.user)
if uform.is_valid() and pform.is_valid():
uform.save()
pform.save()
messages.success(request, 'Your account has been updated!')
return redirect('users:cabinet')
else:
uform = UserUpdateForm(instance=request.user)
pform = ProfileUpdateForm(instance=request.user.profile)
posts = Post.objects.filter(author=request.user)
context = {
'uform': uform,
'pform': pform,
'posts': posts
}
return render(request, 'users/user_detail.html', context)
#login_required
def cabinet(request):
profile = Profile.objects.all()
context = {
'profile': profile
}
return render(request, 'users/user_detail.html', context)
my registration.html
which is a form to create a user:
{% extends 'shared/base.html' %}
{% load staticfiles %}
{% load crispy_forms_tags %}
{% block content %}
<div class="content-section mt-5 pl-5 p-4">
<form method="post">
{% csrf_token %}
<fieldset class="form-group pr-4">
<legend class="mb-4">Join Today</legend>
<div class="form-row">
<div class="form-group col-md-3 mb-0">
{{ form.first_name|as_crispy_field }}
</div>
<div class="form-group col-md-3 mb-0">
{{ form.last_name|as_crispy_field }}
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6 mb-0">
{{ form.username|as_crispy_field }}
<div class="form-row">
<div class="form-group col-md-6 mb-0">
{{ form.country|as_crispy_field }}
</div>
<div class="form-group col-md-6 mb-0">
{{ form.city|as_crispy_field }}
</div>
<div class="form-row">
<div class="form-group col-md-12 mb-0">
{{ form.email|as_crispy_field }}
</div>
<div class="form-row">
<div class="form-group col-md-6 mb-0">
{{ form.password1|as_crispy_field }}
</div>
<div class="form-group col-md-6 mb-0">
{{ form.password2|as_crispy_field }}
</div>
<!-- <div class="form-check">
{{ form.access_challenge }}
<label class="form-check-label" for="Checkbox"> Access Challenge Country</label>
</div> -->
</fieldset>
<div class="form-group">
<button style="border-radius: 0; width: 200px; padding-left: 4px;" class="btn btn-info btn-block" type="submit">Sign Up</button>
</div>
</form>
<div class="border-top pt-3">
<small class="text-muted">
Already Have An Account? <a class="ml-2" href="{% url 'login' %}">Sign In</a>
</small>
</div>
</div>
{% endblock %}
Here is my post_form.html
{% extends 'shared/base.html' %}
{% load staticfiles %}
{% load crispy_forms_tags %}
{% block content %}
<div class="content-section mt-5 pl-5 p-4">
<form method="post" id="personForm" data-cities-url="{% url 'users:ajax_load_cities' %}" novalidate>
{% csrf_token %}
<fieldset class="form-group">
<legend class="mb-4">Church Info</legend>
<div class="form-row">
<div class="form-group col-md-3 small">
{{ form.area|as_crispy_field }}
</div>
<div class="form-group col-md-3 small">
{{ form.country|as_crispy_field }}
</div>
</div>
<div class="form-row">
<div class="form-group col-md-3 small">
{{ form.name|as_crispy_field }}
</div>
<div class="form-group col-md-3 small">
{{ form.city|as_crispy_field }}
</div>
</div>
<div class="form-row">
<div class="form-group col-md-3 small">
{{ form.email|as_crispy_field }}
</div>
<div class="form-group col-md-3 small">
{{ form.website|as_crispy_field }}
</div>
</div>
<div class="form-row">
<div class="form-group col-md-3 small">
{{ form.address|as_crispy_field }}
</div>
<div class="form-group col-md-3 small">
{{ form.phone|as_crispy_field }}
</div>
</div>
<div class="form-row">
<div class="form-group col-md-3 small">
{{ date_posted }}
</div>
<div class="form-group col-md-3 small">
{{ author }}
</div>
</div>
<div class="form-group">
<button style="border-radius: 0; width: 200px; padding-left: 4px;" class="btn btn-info btn-block" type="submit">Submit</button>
</div>
</form>
<div class="border-top pt-3">
<small class="text-muted">
Already Have An Account? <a class="ml-2" href="{% url 'login' %}">Sign In</a>
</small>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
$("#id_area").change(function () {
var url = $("#personForm").attr("data-cities-url");
var areaId = $(this).val();
$.ajax({
url: url,
data: {
'area': areaId
},
success: function (data) {
$("#id_country").html(data);
}
});
});
</script>
{% endblock %}
Here is my forms.py
from django import forms
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from django.contrib.auth import get_user_model
from .models import Profile, Post, User, Country
class UserCreationModelForm(UserCreationForm):
class Meta:
model = User
fields = ['username', 'first_name', 'last_name', 'country', 'city', 'email', 'password1', 'password2']
class UserUpdateForm(forms.ModelForm):
username = forms.CharField()
email = forms.EmailField()
class Meta:
model = User
fields = ['username', 'first_name', 'last_name', 'country', 'city', 'email']
class ProfileUpdateForm(forms.ModelForm):
class Meta:
model = Profile
fields = ['image']
class PostForm(forms.ModelForm):
class Meta:
model = Post
fields = ('name', 'area', 'country', 'city', 'address', 'email', 'phone', 'website')
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['country'].queryset = Country.objects.none()
if 'area' in self.data:
try:
area_id = int(self.data.get('area'))
self.fields['country'].queryset = Country.objects.filter(area_id=area_id).order_by('name')
except (ValueError, TypeError):
pass # invalid input from the client; ignore and fallback to empty City queryset
elif self.instance.pk:
self.fields['country'].queryset = self.instance.area.country_set.order_by('name')

Related

Django filters date range filter is not working

I really don't understand how to connect these two fields or should I just create one. On my front, I have a starting date and end date I can not connect to the backend properly using django-filters Please see the below code
My filters.py
class VideoFolderFilter(FilterSet):
name = CharFilter(field_name='name', lookup_expr='icontains', widget=forms.TextInput(attrs={'class': "form-control"}))
subscription_plan = ModelChoiceFilter( label='subscription_plan', queryset=Plans.objects.all())
start_date_range = DateFromToRangeFilter(field_name='start_date_range', widget=forms.TextInput(attrs={'class': "form-control"}))
end_date_range = DateFromToRangeFilter(field_name='end_date_range', widget=forms.TextInput(attrs={'class': "form-control"}))
def get_date_range(self, start_date_range, end_date_range):
return Sample.objects.filter(sampledate__gte=start_date_range,
sampledate__lte=end_date_range)
class Meta:
model = VideoFolder
fields = '__all__'
widgets = {'start_date_range': DateInput(),}
exclude = [ 'thumbnail_link', 'link', 'name']
My views.py
#login_required
def search_videos(request):
if Subscriber.objects.filter(user=request.user).exists():
subscription = Subscriber.objects.get(user=request.user)
else:
message = "Seams like you don't have subscription with us please select one of the plans"
return redirect(reverse('main'))
video_filter = VideoFolderFilter(request.GET, queryset=VideoFolder.objects.filter(type='video').order_by('-created_date'))
videos = video_filter.qs
return render(request, 'search-videos.html', locals())
Should I change the views.py to query if yes how to date range and other fields will be included
And my search-videos.html
<div class="search-video-form-section mb-3">
<p>Use one or more filters to search below</p>
<form method="GET">
<div class="form-group mb-px-20 filter-form">
<label class="text-base">Name Contains</label>
<!-- <input type="text" class="form-control" placeholder="Keyword" /> -->
{{ video_filter.form.name }}
</div>
<div class="d-flex flex-wrap date-box">
<div class="form-group input-field">
<label class="text-base">Start Date</label>
<div class="input-group input-daterange">
{{ video_filter.form.start_date_range }}
</div>
</div>
<div class="form-group input-field">
<label class="text-base">End Date</label>
<div class="input-group input-daterange">
{{ video_filter.form.end_date_range }}
</div>
</div>
</div>
<div class="form-group filter-form">
<label class="text-base">Subscription</label>
{{ video_filter.form.subscription_plan }}
</div>
<button class="btn text-white bg-info mt-4">Search</button>
</form>
</div>

Django HTML for loop with filter

In my django project, I have an HTML that renders questions header, and inside the question headers I have question items. In my model, Question headers and items are two different entities. I need to show for every header, just the items related to that header. As it shows all items for all questions without any filters. Greatly appreciate any help!
Model:
class Question(models.Model):
question = models.CharField(max_length=240)
mission_section = models.ForeignKey('Mission_Section', on_delete=models.CASCADE)
type_question = models.ForeignKey('Type_Question', on_delete=models.CASCADE)
categories_question = models.ForeignKey('Categories_Question', on_delete=models.CASCADE, default=1)
order = models.IntegerField(default=1)
def __str__(self):
return self.question
class Question_Option(models.Model):
question = models.ForeignKey('Question', on_delete=models.CASCADE,default=1)
option = models.CharField(max_length=240)
correct = models.BooleanField()
order = models.IntegerField(default=1)
View:
class Questions(LoginRequiredMixin, FormView):
template_name = "questions.tmpl"
def get(self, request, pk):
context = {
'pk': pk,
'section': Mission_Section.objects.get(pk = pk ),
'questions_items': Question_Option.objects.filter(question__mission_section__pk=pk).order_by('order','pk'),
'questions': Question.objects.filter(mission_section__pk = pk ),
'question_types' : Type_Question.objects.all(),
'questions_categories': Categories_Question.objects.all()}
return render(self.request, self.template_name, context)
HTML
<input type="hidden" class="form-control" id="section" name="section" value="{{section.id}}" required>
<h1>{{ section.name }}</h1>
<div id="contentDiv">
<ol>
{% for question in questions %}
<div name="question" class="form-group" id="question-{{question.id}}" >
<form class='my-ajax-form' id="form-question-{{question.id}}" method='GET' action='.' data-url='{{ request.build_absolute_uri|safe }}'>
<li><div class="input-group">
{% csrf_token %}
{{ form.as_p }}
<input type="text" value= "{{question.id}}" id="question" name="question-hidden" class="form-control">
<input type="text" value= "{{question.question}}" id="question_name_{{question.id}}" class="form-control" aria-label="Amount" onchange="UpdateQuestion({{question.id}})">
</div>
</form>
<br>
<!-- Options -->
<div id = "question_content_{{question.id}}" name="question-options" class="collapse">
<ol class="example list-group">
{% for qi in questions_items %}
<li class="list-group-item d-flex justify-content-between align-items-center" id={{qi.id}} name="opt-{{question.id}}-{{qi.id}}" onclick="setCorrect({{qi.id}},{{question.id}})" contenteditable="true">{{ qi.option }}
<span class="badge badge-warning badge-pill">-</span>
</li>
{% endfor %} </ol>
<div>
<div class="d-flex justify-content-center">Add Option</div>
<div class="d-flex justify-content-center"> <br><i class="fa fa-plus-circle fa-1x" aria-hidden="true"></i></div>
</div>
</div>
</div></li>
{% endfor %} </ol>
using this answer I figured it out Double loop in Django template
What I need is:
<div id = "question_content_{{question.id}}" name="question-options" class="collapse">
{% csrf_token %}
{{ form.as_p }}
<form class='ajax-form-option' id="form-option-{{question.id}}" method='GET' action='.' data-url='{{ request.build_absolute_uri|safe }}'>
<ol class="example list-group">
{% for qi in question.question_option_set.all %}
<li class="list-group-item d-flex justify-content-between align-items-center" id=option-{{qi.id}} name="opt-{{question.id}}-{{qi.id}}">
<div contenteditable="true">{{ qi.option }}</div>
<div>
<button type="button" name='option-check' class="btn btn-light" value={{qi.id}} id="check-option-{{question.id}}-{{qi.id}}">
<i class="fas fa-check"></i>
</button>
<button type="button" class="btn btn-warning" id="delete-option-{{question.id}}-{{qi.id}}" onclick="deleteOption({{qi.id}})">
<i class="fa fa-trash" aria-hidden="true"></i>
</button>
</div>
</li>
{% endfor %} </ol>
<div onclick="CreateOption({{question.id}})">
<div class="d-flex justify-content-center">Add Option</div>
<div class="d-flex justify-content-center"> <br><i class="fa fa-plus-circle fa-1x" aria-hidden="true"></i></div>
</div>
</form>

Django form doesn't appear on template

I'm currently working on a project that require Django Forms but I ended up with some issues. My form doesn't display at all ... No field appear on my template.
So my code :
models.py
class Place(models.Model):
name = models.CharField(max_length=255)
longitudeMax = models.DecimalField(max_digits=8, decimal_places = 4 ,blank=True)
longitudeMin = models.DecimalField(max_digits=8, decimal_places = 4, blank=True)
latitudeMax = models.DecimalField(max_digits=8, decimal_places = 4, blank=True)
latitudeMin = models.DecimalField(max_digits=8, decimal_places = 4, blank=True)
datasetPath = models.CharField(max_length=255)
isActive = models.BooleanField(default=True)
def __str__(self):
return self.name
def get_place(self, name):
return None
forms.py
class NewPlaceForm(forms.Form):
name = forms.CharField(
widget=forms.TextInput(
attrs={
"placeholder" : "Name",
"class": "form-control"
}
))
longMax = forms.DecimalField(
widget=forms.NumberInput(
attrs={
"placeholder" : "Longitude Max",
"class": "form-control"
}
))
longMin = forms.DecimalField(
widget=forms.NumberInput(
attrs={
"placeholder" : "Longitude Min",
"class": "form-control"
}
))
latMax = forms.DecimalField(
widget=forms.NumberInput(
attrs={
"placeholder" : "Latitude Max",
"class": "form-control"
}
))
latMin = forms.DecimalField(
widget=forms.NumberInput(
attrs={
"placeholder" : "Latitude Min",
"class": "form-control"
}
))
class Meta:
model = Place
fields = ('name', 'longitudeMax', 'longitudeMin', 'latitudeMax', 'latitudeMin')
views.py
def upload(request):
msg = None
if request.method == "POST":
form = NewPlaceForm(request.POST)
if form.is_valid():
form.save()
msg = 'Place created'
else:
msg = 'Form is not valid'
else:
form = NewPlaceForm()
return render(request, "pages/place_upload.html", {"form": form, "msg" : msg})
urls.py
from django.urls import path, re_path
from app import views
urlpatterns = [
#Data modification page
path('pages/place_modification.html', views.modification, name="place_modification"),
#New place adding page
path('pages/place_upload.html', views.upload, name="place_upload"),
# Matches any html file
re_path(r'^.*\.html', views.pages, name='pages'),
# The home page
path('', views.index, name='home'),
]
html file
<form method="post" action="">
{% csrf_token %}
<div class="card-body">
<div class="row">
<div class="col-md-6 col-lg-4">
<div class="form-group">
<div class="input-group mb-3">
<div class="input-group-prepend">
</div>
{{ form.name }}
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 col-lg-4">
<div class="form-group">
<div class="input-group mb-3">
<div class="input-group-prepend">
</div>
{{ form.longMax }}
</div>
</div>
<div class="input-group mb-3">
<div class="input-group-prepend">
</div>
{{ form.longMin }}
</div>
</div >
<div class="col-md-6 col-lg-4">
<div class="input-group mb-3">
<div class="input-group-prepend">
</div>
{{ form.latMax }}
</div>
<div class="input-group mb-3">
<div class="input-group-prepend">
</div>
{{ form.latMin }}
</div>
</div>
<div class="col-md-6 col-lg-4">
<div class="form-group form-floating-label">
<small id="emailHelp2" class="form-text text-muted">Use negative numbers for South and positive numbers for North</small>
</div>
<div class="form-group form-floating-label">
<small id="emailHelp2" class="form-text text-muted">Use negative numbers for West and positive numbers for East</small>
</div>
</div>
</div>
</div>
<div class="card-action">
<button type="submit" class="btn btn-success">Submit</button>
<button class="btn btn-danger">Cancel</button>
</div>
</form>
I don't see why it doesn't work and it's been several days that I try to make it work ... Did I do something wrong ? Have I forgot something ? Because I don't feel like I did and it's getting on my nerve ahaha
Django handles the form rendering out of the box, to display a basic form, try:
<form method="POST" action="{% url 'namespaced:url' %}">
{ csrf_token %}
{{ form.as_p }}
<input type="submit" value="submit">
</form>
That said, it looks like you're using bootstrap in your template, you might find the package django-bootstrap4 useful (https://github.com/zostera/django-bootstrap4).
Quick example:
pip install django-bootstrap4
and add bootstrap4 to your installed apps.
Then in your template:
{% load bootstrap4 %}
{# Load CSS and JavaScript #}
{% bootstrap_css %}
{% bootstrap_javascript jquery='full' %}
<form action="{% url 'namespaced:url' %}" method="post" class="form">
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
<button type="submit" class="btn btn-primary">
Submit
</button>
{% endbuttons %}
</form>
If you want, you can render each field manually using:
{% bootstrap_field field %}, so you can do things like <div class="col-md-6">{% bootstrap_field my_field %}</div>, to manually arrange your form fields on the page.

Keep data in the form after submit

I am implementing search by two fields in form in Django.
I want to keep input data after search.
For example I input "C++" and chose "IT"
then I received Default values
I tried to parse request variable --- e.g. data = request.POST.copy()
but did not achieved result. What is the reason of this problem?
How can I solve this problem?
This is my code:
models.py
class Company(models.Model):
name = models.CharField(max_length=200)
about = models.TextField()
def __str__(self):
return self.name
class Vacancy(models.Model):
company_key = models.ForeignKey(Company, on_delete=models.CASCADE)
title = models.CharField(max_length=200)
salary = models.CharField(max_length=200, default='40.000')
text = models.TextField(default="The text about vacancy")
city = models.CharField(max_length=200, default='Москва')
date_str = models.CharField(max_length=50, default='12 сентября')
created_date = models.DateTimeField(default=timezone.now)
published_date = models.DateTimeField(blank=True, null=True)
CHOICES = [
('ALL', 'ALL'),
('IT', 'IT'),
('FINANCE', 'FINANCE'),
('OTHER', 'OTHER'),
]
department = models.CharField(
max_length=20,
choices=CHOICES,
default='ALL',
)
def publish(self):
self.published_date = timezone.now()
self.save()
def __str__(self):
return self.title
urls.py
urlpatterns = [
path('', HomePageView.as_view(), name='vacancy_list'),
path('search/', SearchResultsView.as_view(), name='search_results'),
path('vacancy/<int:pk>/', views.vacancy_detail, name='vacancy_detail'),
path('accounts/login/', BBLoginView.as_view(), name='login'),
path('accounts/profile/', profile, name='profile'),
path('accounts/logout/', BBLogoutView.as_view(), name='logout'),
views.py
class HomePageView(ListView):
model = Vacancy
template_name = 'vacancy_list/vacancy_list.html'
paginate_by = 2
page_kwarg = 'vacancy'
context_object_name = 'vacancies'
def vacancy_detail(request, pk):
vacancy = get_object_or_404(Vacancy, pk=pk)
return render(request, 'vacancy_list/vacancy_detail.html', {'vacancy': vacancy})
class SearchResultsView(ListView):
model = Vacancy
template_name = 'vacancy_list/search_results.html'
paginate_by = 2
page_kwarg = 'vacancy'
context_object_name = 'vacancies'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['query'] = self.request.GET.get('q')
# added param
context['query2'] = self.request.GET.get('q2')
return context
def get_queryset(self): # new
query = self.request.GET.get('q')
query2 = self.request.GET.get('q2')
object_list = Vacancy.objects.filter(
Q(title__icontains=query) and Q(department__icontains=query2)
)
return object_list
vacancy_list.html
{% block content %}
<div class="container col-md-8" style="margin:20px;">
<div class="container" style="margin-top: 40px; font-size: 2rem; padding-left: 0px;">
<form action="{% url 'search_results' %}" method="get">
<div class="row">
<div class="col-lg-8 col-md-6 col-xs-12">
<input name="q" type="text" placeholder="Search..." class="form-control">
</div>
<div class="col-lg-3 col-md-4 col-xs-12">
<select name="q2" class="form-control" id="exampleFormControlSelect1">
<option>ALL</option>
<option>IT</option>
<option>Finance</option>
<option>Other</option>
</select>
</div>
<div class="col-lg-1 col-md-2 col-xs-12" style="padding-left: 0px;">
<button class="btn btn-primary">Primary</button>
</div>
</div>
</form>
</div>
{% for vacancy in vacancies %}
<div class="card">
<div class="card-header">
<div class="row">
<div class="col-md-8">
<h1>{{vacancy.title}}</h1>
</div>
<div class="col-md-4 text-right">
<p> {{ vacancy.salary}} </p>
</div>
</div>
</div>
....
{% endfor %}
search_result.html
{% extends 'vacancy_list/base.html' %}
{% block content %}
<h1> {{request}}</h1>
<div class="container col-md-8" style="margin:20px;">
<div class="container" style="margin-top: 40px; font-size: 2rem; padding-left: 0px;">
<form action="{% url 'search_results' %}" method="get">
<div class="row">
<div class="col-lg-8 col-md-6 col-xs-12">
<input name="q" type="text" placeholder="Search..." class="form-control">
</div>
<div class="col-lg-3 col-md-4 col-xs-12">
<select name="q2" class="form-control" id="exampleFormControlSelect1">
<option>ALL</option>
<option>IT</option>
<option>Finance</option>
<option>Other</option>
</select>
</div>
<div class="col-lg-1 col-md-2 col-xs-12" style="padding-left: 0px;">
<button class="btn btn-primary">Primary</button>
</div>
</div>
</form>
</div>
{% for vacancy in vacancies %}
...
{% endfor %}
{% endblock %}
In your search results template, you should use {{ query }} and {{ query2 }} and a little bit of logic to populate the text and drop-down boxes.

How to filter foreign key in django filter

I want to get the username using the field user (foreignkey)
I don't know how get the username in the view
model.py
class Publication(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
filters.py
class PublicationFilter(django_filters.FilterSet):
user = django_filters.CharFilter(lookup_expr='exact')
class Meta:
model = Publication
fields = ['user']
views.py
def publication_list(request):
f = PublicationFilter(request.GET, queryset=Publication.objects.all())
return render(request, 'info/filter.html', {'filter':f})
html
<h2>Lista de sus informes</h2>
<p class="profile-data">
<div class="col-md-4 mt-2 mb-3 ">
<div class="row p-1">
<div class="col-md-12">
<form action="" method="get" >
<b> {{ filter.form.as_p }} </b><br>
<button type="submit">Search</button>
</form>
<ul>
<b>{% for profile in filter.qs %} </b><br>
<b>{{ profile.nombre }} </b><br>
<b>{{ profile.user }} </b><br>
Ver perfil<br>
{% endfor %}
You can use '__' : Publication.objects.filter(user__username="John Doe")

Categories

Resources