Python 在基于Django的我的博客应用程序中创建个人资料搜索功能

Python 在基于Django的我的博客应用程序中创建个人资料搜索功能,python,django,Python,Django,我想通过为基于用户模型的配置文件创建搜索表单来扩展我的django博客应用程序。 当前,任何配置文件页面都只能由当前登录用户使用与以下url模式对应的简单基本url访问 urlpatterns = [ path('profile/', views_register.profile, name='profile'), ] 我正在从以下html模板获取用户搜索查询 <form method="GET" action="" id="searchform">

我想通过为基于用户模型的配置文件创建搜索表单来扩展我的django博客应用程序。 当前,任何配置文件页面都只能由当前登录用户使用与以下url模式对应的简单基本url访问

urlpatterns = [
    path('profile/', views_register.profile, name='profile'),  
]
我正在从以下html模板获取用户搜索查询

<form method="GET" action="" id="searchform">
            <input class="searchfield" id="searchbox" name="q" type="text" value="{{ request.GET.q }}" placeholder="Search..."/>
        </form>
如何将查询启动器重定向到此新配置文件页面?我知道这个函数什么都不做,因为它不做任何动态重定向,但我不知道

以下是配置文件模型,在新用户注册时通过信号自动创建

class Profile(models.Model):


user = models.OneToOneField(User, on_delete=models.CASCADE)
    image = models.ImageField(default= 'default.jpg', upload_to='profile_pics')

    def __str__(self):
        return f'{self.user.username} Profile'

    def save(self, *args, **kwargs):
        super().save(*args, **kwargs)
        img = Image.open(self.image.path)

        if img.height > 300 or img.width > 300:
            output_size = (300, 300)
            img.thumbnail(output_size)
            img.save(self.image.path)

我认为您需要在提交html表单时进行操作,例如URL。如果提交了搜索参数,则请求者将重定向到URL。这个URL可能是一个带有显示搜索结果的ListView的页面。我认为您需要在提交html表单时执行操作,例如URL。如果提交了搜索参数,则请求者将重定向到URL。此URL可能是包含显示搜索结果的ListView的页面。
class Profile(models.Model):


user = models.OneToOneField(User, on_delete=models.CASCADE)
    image = models.ImageField(default= 'default.jpg', upload_to='profile_pics')

    def __str__(self):
        return f'{self.user.username} Profile'

    def save(self, *args, **kwargs):
        super().save(*args, **kwargs)
        img = Image.open(self.image.path)

        if img.height > 300 or img.width > 300:
            output_size = (300, 300)
            img.thumbnail(output_size)
            img.save(self.image.path)