python - Django: User Reporting Some URL on Website -
so i'm trying build something, users able report on site. here's model,
class report(models.model): reporting_url = models.urlfield() message = models.textfield()
i created form model including 'message' field because 'reporting_url' needs populate depending upon specific page user has clicked "report" button.
def report(request): url_report = ??? if request.method == 'post': form = reportform(request.post or none) if form.is_valid(): new_form = form.save(commit=false) new_form.reporting_url = url_report new_form.save()
i wondering how can pass specific url 'reporting_url' field in form depending on page user has clicked "report" button? (much s see on social networks).
am doing correctly, or there better way doing this? please me code. in advance!
if there report button on specific page believe write custom context processor.
more info: django: url of current page, including parameters, in template
https://docs.djangoproject.com/en/1.11/ref/templates/api/
or maybe write directly in views.py in function , set
url_report = request.get_full_path()
Comments
Post a Comment